Introduce McpJsonMapper interface to decouple from Jackson#543
Closed
graemerocher wants to merge 7 commits intomodelcontextprotocol:mainfrom
Closed
Introduce McpJsonMapper interface to decouple from Jackson#543graemerocher wants to merge 7 commits intomodelcontextprotocol:mainfrom
graemerocher wants to merge 7 commits intomodelcontextprotocol:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The current MCP SDK is coupled to Jackson which prevents the use of other JSON serialization libraries and techniques.
This PR is an initial go and abstracting away Jackson usage in order to generate discussion. Left in draft to gather feedback.
This pull request creates two modules,
mcp-jsonandmcp-json-jackson. It removes thecom.fasterxml.jackson.core:jackson-databindandcom.networknt:json-schema-validatordependencies from themcpmodule. Themcpmodule now only depends oncom.fasterxml.jackson.core:jackson-annotations.To use Jackson, you have to add
mcp-jacksonto your dependencies in addition tomcp. I added the dependencymcp-jacksonto bothmcp-spring-mvcandmcp-spring-webfluxto avoid a breaking change in those modules.It provides two SPI
JsonSchemaValidatorSupplierandJsonSchemaValidatorSupplierto allow easy replacement for consumers who don't want to use Jackson.This pull request also ensures no
McpJsonMapperis instantiated if one is provided via a builder method. Only if the builders don't receive aMcpJsonMappermapper, one is instantiated in thebuildmethod of the builder.The logic behind this is to allow frameworks to provide a
McpJsonMappermapper singleton implementation and feed it to the builders without paying the price of instantiatingMcpJsonMappers, which will not be used. The goal is to be able to use theObjectMappersingleton of an application also for the MCP code.How Has This Been Tested?
Yes tests included.
Breaking Changes
Toolconstructors, and it updates every test to use the builder API to instantiate tools.McpJsonMapperhave been removed.Types of changes
Checklist
Additional context