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 schema
call - 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.
This class is deprecated and will be removed in 0.9.0. Use McpServerFeatures.SyncToolSpecification.
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 Details

  • Method Details

    • toSpecification

      public McpServerFeatures.SyncToolSpecification toSpecification()
      Deprecated.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tool

      public McpSchema.Tool tool()
      Deprecated.
      Returns the value of the tool record component.
      Returns:
      the value of the tool record component
    • call

      Deprecated.
      Returns the value of the call record component.
      Returns:
      the value of the call record component