Skip to content

McpSchema.Tool requires the annotations attribute. #312

Closed

Description

@sunyuhan1998

Expected Behavior

The McpSchema.Tool class should support the annotations attribute.

Current Behavior
The McpSchema.Tool class currently only has the name, description, and inputSchema properties.

Context

I believe we need to support the annotations property in the McpSchema.Tool class for the following reasons:

  1. It is part of the MCP specification: As stated in the MCP specification (https://modelcontextprotocol.io/docs/concepts/tools#tool-definition-structure
    ), this property is very useful as it allows the MCP server to provide additional descriptions about a tool’s behavior to the client.

  2. Better integration with the Spring ecosystem (e.g., Spring AI): Supporting this property would enable better interoperability with frameworks like Spring AI. In Spring AI, there is a returnDirect attribute for tools(https://docs.spring.io/spring-ai/reference/1.1-SNAPSHOT/api/tools.html#_return_direct), which indicates that the result of the tool call should be returned directly to the user instead of being sent back to the model. However, since McpSchema.Tool currently lacks a way to carry this attribute, returnDirect becomes ineffective in MCP scenarios(for details on this point, please refer to: @Tool returnDirect Attribute Ignored spring-projects/spring-ai#3481 (comment) ). I believe it's a good approach to pass this value through annotations.

  3. Support and extension in other language SDKs: The annotations property is already supported in MCP SDKs for languages such as Python and Swift, and each has extended it in their own way.

Activity

  1. tzolov commented on Jun 24, 2025

    @tzolov
    Contributor

    Resolved by #313

  2. sunyuhan1998 commented on Jun 24, 2025

    @sunyuhan1998
    ContributorAuthor

    Resolved by #313

    Hi @tzolov thank you very much for your time, it's really great that this PR can be merged, I think when the next version is released (maybe v0.11.0?) we'll be able to integrate it in Spring AI and with the help of it solve the problem we discussed in spring-projects/spring-ai#3481 (comment)

    I will keep an eye on MCP's java-sdk release, and submit a PR to Spring AI as soon as it is available! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions