Skip to content

Conversation

eeaters
Copy link

@eeaters eeaters commented Aug 25, 2025

  • Added a function in Client to set tool annotations received from server
  • Updated Client builder to support configuring ToolAnnotations
  • Enables downstream clients to handle server-provided tool metadata

Motivation and Context

When local function_call logic is split into an MCP Server service, metadata such as returnDirect may be lost, causing inconsistent semantics after service splitting. This change adds support in the MCP Java SDK Client for setting ToolAnnotations and provides builder configuration to enable preservation and propagation of server-provided metadata.

When directly accepting properties from an MCP server, some attributes may be unsafe or potentially destructive. Therefore, the client should enforce its own priorities. For example, by default, returnDirect should always be treated as false unless explicitly overridden in a controlled manner.

How Has This Been Tested?

No test classes were modified. Testing with the Docker server image was
ineffective because the server did not send the relevant attributes. Verification
was done by running the project locally, ensuring the Client correctly receives
and handles ToolAnnotations.

Breaking Changes

None. No configuration changes are required. The feature is opt-in and only
affects applications that explicitly use the SDK support (e.g., Spring AI). If
not used, it has no impact.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [ x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • [ x ] I have read the MCP Documentation
  • [ x ] My code follows the repository's style guidelines
  • [ x ] New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This feature enables the Client to optionally handle ToolAnnotations sent from the server, which was previously ignored.

By default, the Builder does not activate ToolAnnotation support; applications must explicitly configure it to take effect (e.g., in Spring AI).

The change is safe and backward-compatible: it does not affect existing functionality or code that does not use ToolAnnotations.

Provides flexibility for future features that rely on server-sent metadata without introducing breaking changes.

- Added a function in Client to set tool annotations received from server
- Updated Client builder to support configuring ToolAnnotations
- Enables downstream clients to handle server-provided tool metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant