Skip to content

Use configured MCP mapper for annotated tools - #6698

Open
minsuking wants to merge 1 commit into
spring-projects:mainfrom
minsuking:issue-4479-mcp-tool-json-mapper
Open

Use configured MCP mapper for annotated tools#6698
minsuking wants to merge 1 commit into
spring-projects:mainfrom
minsuking:issue-4479-mcp-tool-json-mapper

Conversation

@minsuking

Copy link
Copy Markdown

Summary

Fixes #4479.

Annotation-based MCP tool callbacks did not use the configured
mcpServerJsonMapper when converting tool arguments and results.

As a result, custom Jackson configurations (for example,
snake_case property naming strategies) were ignored for
methods annotated with @McpTool.

This change propagates the configured McpJsonMapper
from the annotation-based providers to generated tool callbacks.

Root Cause

The MCP server auto-configuration correctly created providers
using the configured mapper, but the generated callbacks
continued using their default JSON helper.

Solution

  • Reuse the configured McpJsonMapper
  • Pass it to generated callbacks
  • Preserve existing behavior when no custom mapper is configured
  • Avoid introducing new JsonMapper overloads or constructors

Tests

Executed:

  • McpToolInputSchemaIT
  • MCP annotation module tests
  • git diff --check

Targeted MCP tests passed.

Limitations

./mvnw clean package did not complete successfully on my
local Windows environment because the build stopped on
assertion failures in unrelated modules before reaching
the modified MCP modules.

The targeted MCP regression tests completed successfully.

Pass the configured MCP server JsonMapper into annotated tool providers so @mcptool result serialization follows the server mapper configuration.

Add a regression test that verifies a custom snake_case mapper is used for annotated tool results.

See spring-projects#4479

Signed-off-by: Minsu <minsu.kim@khmc.or.kr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to specify custom Jackson object mapper when using @McpTool

3 participants