public static class McpServerFeatures.SyncToolSpecification
extends java.lang.Object
Example tool specification:
McpServerFeatures.SyncToolSpecification.builder()
.tool(Tool.builder()
.name("calculator")
.title("Performs mathematical calculations")
.inputSchema(new JsonSchemaObject()
.required("expression")
.property("expression", JsonSchemaType.STRING))
.build()
.toolHandler((exchange, req) -> {
String expr = (String) req.arguments().get("expression");
return CallToolResult.builder()
.content(List.of(new McpSchema.TextContent("Result: " + evaluate(expr))))
.isError(false)
.build();
}))
.build();
| 限定符和类型 | 类和说明 |
|---|---|
static class |
McpServerFeatures.SyncToolSpecification.Builder
Builder for creating SyncToolSpecification instances.
|
| 构造器和说明 |
|---|
SyncToolSpecification(McpSchema.Tool tool,
java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> call)
已过时。
|
SyncToolSpecification(McpSchema.Tool tool,
java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> call,
java.util.function.BiFunction<McpSyncServerExchange,McpSchema.CallToolRequest,McpSchema.CallToolResult> callHandler) |
| 限定符和类型 | 方法和说明 |
|---|---|
static McpServerFeatures.SyncToolSpecification.Builder |
builder()
Creates a new builder instance.
|
java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> |
call() |
java.util.function.BiFunction<McpSyncServerExchange,McpSchema.CallToolRequest,McpSchema.CallToolResult> |
callHandler() |
McpSchema.Tool |
tool() |
public SyncToolSpecification(McpSchema.Tool tool, java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> call, java.util.function.BiFunction<McpSyncServerExchange,McpSchema.CallToolRequest,McpSchema.CallToolResult> callHandler)
tool - The tool definition including name, description, and parameter schemacall - (Deprected) The function that implements the tool's logic, receiving
arguments and returning results. The function's first argument is an
McpSyncServerExchange upon which the server can interact with the connectedcallHandler - The function that implements the tool's logic, receiving a
McpSyncServerExchange and a
McpSchema.CallToolRequest and returning
results. The function's first argument is an McpSyncServerExchange upon
which the server can interact with the client. The second arguments is a map of
arguments passed to the tool.@Deprecated public SyncToolSpecification(McpSchema.Tool tool, java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> call)
public McpSchema.Tool tool()
public java.util.function.BiFunction<McpSyncServerExchange,java.util.Map<java.lang.String,java.lang.Object>,McpSchema.CallToolResult> call()
public java.util.function.BiFunction<McpSyncServerExchange,McpSchema.CallToolRequest,McpSchema.CallToolResult> callHandler()
public static McpServerFeatures.SyncToolSpecification.Builder builder()