Interface ToolProvider

All Known Implementing Classes:
TnsAIToolProvider

public interface ToolProvider
Interface for providing tools to an MCP server.

Implement this interface to expose your tools to MCP clients. Each tool provider can supply multiple tools with their definitions and handle tool execution requests.

Example implementation:


 public class MyToolProvider implements ToolProvider {
     @Override
     public List<McpToolDefinition> listTools() {
         return List.of(
             McpToolDefinition.builder()
                 .name("my_tool")
                 .description("Does something useful")
                 .inputSchema(schemaNode)
                 .build()
         );
     }

     @Override
     public ToolResult executeTool(String name, JsonNode arguments) {
         if ("my_tool".equals(name)) {
             String result = doSomething(arguments);
             return ToolResult.success(result);
         }
         return ToolResult.error("Unknown tool: " + name);
     }
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Result of a tool execution.
  • Method Summary

    Modifier and Type
    Method
    Description
    executeTool(String toolName, com.fasterxml.jackson.databind.JsonNode arguments)
    Executes a tool with the given arguments.
    Returns the list of tools provided by this provider.
  • Method Details

    • listTools

      List<McpToolDefinition> listTools()
      Returns the list of tools provided by this provider.
      Returns:
      list of tool definitions
    • executeTool

      ToolProvider.ToolResult executeTool(String toolName, com.fasterxml.jackson.databind.JsonNode arguments)
      Executes a tool with the given arguments.
      Parameters:
      toolName - the name of the tool to execute
      arguments - the tool arguments as JSON
      Returns:
      the result of the tool execution