Package io.modelcontextprotocol.server
Record Class McpServerFeatures.SyncToolRegistration
java.lang.Object
java.lang.Record
io.modelcontextprotocol.server.McpServerFeatures.SyncToolRegistration
- Record Components:
tool- The tool definition including name, description, and parameter schemacall- The function that implements the tool's logic, receiving arguments and returning results
- Enclosing class:
- McpServerFeatures
@Deprecated
public static record McpServerFeatures.SyncToolRegistration(McpSchema.Tool tool, Function<Map<String,Object>,McpSchema.CallToolResult> call)
extends Record
Deprecated.
Registration of a tool with its synchronous handler function. Tools are the primary
way for MCP servers to expose functionality to AI models. Each tool represents a
specific capability, such as:
- Performing calculations
- Accessing external APIs
- Querying databases
- Manipulating files
- Executing system commands
Example tool registration:
new McpServerFeatures.SyncToolRegistration(
new Tool(
"calculator",
"Performs mathematical calculations",
new JsonSchemaObject()
.required("expression")
.property("expression", JsonSchemaType.STRING)
),
args -> {
String expr = (String) args.get("expression");
return new CallToolResult("Result: " + evaluate(expr));
}
)
-
Constructor Summary
ConstructorsConstructorDescriptionSyncToolRegistration(McpSchema.Tool tool, Function<Map<String, Object>, McpSchema.CallToolResult> call) Deprecated.Creates an instance of aSyncToolRegistrationrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncall()Deprecated.Returns the value of thecallrecord component.final booleanDeprecated.Indicates whether some other object is "equal to" this one.final inthashCode()Deprecated.Returns a hash code value for this object.tool()Deprecated.Returns the value of thetoolrecord component.Deprecated.final StringtoString()Deprecated.Returns a string representation of this record class.
-
Constructor Details
-
SyncToolRegistration
public SyncToolRegistration(McpSchema.Tool tool, Function<Map<String, Object>, McpSchema.CallToolResult> call) Deprecated.Creates an instance of aSyncToolRegistrationrecord class.
-
-
Method Details
-
toSpecification
Deprecated. -
toString
Deprecated.Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Deprecated.Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Deprecated.Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
tool
Deprecated.Returns the value of thetoolrecord component.- Returns:
- the value of the
toolrecord component
-
call
Deprecated.Returns the value of thecallrecord component.- Returns:
- the value of the
callrecord component
-
McpServerFeatures.SyncToolSpecification.