-
Notifications
You must be signed in to change notification settings - Fork 783
Add Support for Jackson 3 and use it by default #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@filiphr I was about to submit such PR, so thanks for creating it. I think I would prefer to have consistency between |
|
Thanks for your comment @sdeleuze. I've read your comment #562 (comment) and I've added an alternative idea in #562 (comment). In any case, I stumbled onto this since I wanted to contribute Jackson 3 support for Spring AI, but that depends on this project, so I started here first. |
|
@filiphr Thanks, just be aware I am already working on the Jackson 3 support for Spring AI, and have it pretty advanced locally, so no need to contribute it. That said, I will welcome your review on my upcoming PR. |
|
After the discussion on #562, my proposal is the following: 0.18:
0.19:
@filiphr @tzolov @chemicL @graemerocher @sdelamo Are you ok with that? If we are, this PR could be refined with the proposed |
|
I'm OK with your proposal @sdeleuze. In an hour or two I can adjust this PR and the the changes in relation to
Thanks for letting me know @sdeleuze. I have not spend a lot of time on it anyways, I stumbled fast on the different dependencies. I would be happy to review your PR for Spring AI, feel free to ping me when you have it ready. |
This plan makes sense. Please go ahead |
It requires for now installing locally: - modelcontextprotocol/java-sdk#742 - https://github.com/victools/jsonschema-generator main branch JsonMapper is used instead of ObjectMapper, following Jackson 3 best practicies and the same pattern used by Spring Framework and Spring Boot. JacksonUtils#instantiateAvailableModules now leverages Jackson service loader based discovery of Jackson module. TODO: - Upgrade to com.github.victools:jsonschema-generator:5.0.0 - Upgrade to MCP Java SDK 0.18.0
It requires for now installing locally: - modelcontextprotocol/java-sdk#742 - https://github.com/victools/jsonschema-generator main branch JsonMapper is used instead of ObjectMapper, following Jackson 3 best practicies and the same pattern used by Spring Framework and Spring Boot. JacksonUtils#instantiateAvailableModules now leverages Jackson server loader based discovery of Jackson module. TODO: - Upgrade to com.github.victools:jsonschema-generator:5.0.0 - Upgrade to MCP Java SDK 0.18.0
chemicL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I added a tiny javadoc remark, probably worth rebasing the PR against main and fixing that one.
As a follow up, we should look into unifying the tests between modules as currently they're a copy.
...ckson3/src/main/java/io/modelcontextprotocol/json/jackson3/JacksonMcpJsonMapperSupplier.java
Outdated
Show resolved
Hide resolved
It requires for now installing locally: - modelcontextprotocol/java-sdk#742 - https://github.com/victools/jsonschema-generator main branch JsonMapper is used instead of ObjectMapper, following Jackson 3 best practicies and the same pattern used by Spring Framework and Spring Boot. JacksonUtils#instantiateAvailableModules now leverages Jackson service loader based discovery of Jackson module. TODO: - Upgrade to com.github.victools:jsonschema-generator:5.0.0 - Upgrade to MCP Java SDK 0.18.0
It requires for now installing locally: - modelcontextprotocol/java-sdk#742 - https://github.com/victools/jsonschema-generator main branch JsonMapper is used instead of ObjectMapper, following Jackson 3 best practicies and the same pattern used by Spring Framework and Spring Boot. JacksonUtils#instantiateAvailableModules now leverages Jackson service loader based discovery of Jackson module. TODO: - Upgrade to com.github.victools:jsonschema-generator:5.0.0 - Upgrade to MCP Java SDK 0.18.0 Signed-off-by: Sébastien Deleuze <sdeleuze@users.noreply.github.com>
It requires for now installing locally: - modelcontextprotocol/java-sdk#742 - https://github.com/victools/jsonschema-generator main branch JsonMapper is used instead of ObjectMapper, following Jackson 3 best practices and the same pattern used by Spring Framework and Spring Boot. JacksonUtils#instantiateAvailableModules now leverages Jackson service loader based discovery of Jackson module. TODO: - Upgrade to com.github.victools:jsonschema-generator:5.0.0 - Upgrade to MCP Java SDK 0.18.0 Signed-off-by: Sébastien Deleuze <sdeleuze@users.noreply.github.com>
sdelamo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks good to me.
c4617ac to
1a7b9f5
Compare
|
Thanks everyone for the review. I had to do some additional changes to make sure everything works with Jackson 3.
I agree with you @chemicL it would be good to have some unified tests, maybe tests where all the different json mappers are tested. Btw, I also had some problems with some of the tests in |
|
IMO we can't just bump spring-framework from 6.x to 7.x and render the mcp-spring-* modules unusable by anyone with spring-framework 6. I'll gather ideas and come back with feedback. |
|
What I can suggest is the following:
@filiphr Would this work to make the tests pass? @sdeleuze would you be able to verify that with these changes the java-sdk can be used both with Spring Framework 6 in Spring AI 1.0 and Framework 7 in Spring AI 2.0? As a next step, we can deprecate mcp-spring/* modules in MCP Java SDK and have the implementation for Spring in the Spring portfolio as suggested in #127 |
deprecate classes for removal in `io.modelcontextprotocol.json.jackson`/`io.modelcontextprotocol.json.schema.jackson` and copy them to `io.modelcontextprotocol.json.jackson2`/`io.modelcontextprotocol.json.schema.jackson2` in non-deprecated form.
…hould use McpJsonMapper when handling messages for serialization / deserialization
|
@chemicL thanks for pointing it out. The fact that it does not work with Spring 7 is actually a bug in the I've updated the PR to also fix the places in the I think the tests should be passing now. |
|
Thank you for taking my feedback into account. Please do follow the contributing guidelines - force pushing every change makes reviewing the incremental changes difficult. Can you elaborate on why in the spring modules using the underlying Jackson implementation and not utilizing the |
Sorry about that. I didn't realize about the force pushing. I won't do that anymore.
It is a bug because it relies on how the The 2 changes I did it more or less aligns with what is being done in other places in the
The approach fully decouples how the Spring WebClient is configured and whether or not the users have decided to use Jackson 2 or Jackson 3 in their global configuration. |
|
Thanks for explaining, that does make sense to me. In such case, let's bring back jackson2 to the mcp-spring modules and I think we are good to go. |
A dedicated |
@sdelamo, Is it OK to do this in a subsequent PR or you want it as part of this one?
Thanks @chemicL. I'll do that adjustment. I'll also see if I can adjust the tests to run both with jackson2 and jackson3 present. |
|
IMO ok to do it as part of this PR unless somebody objects. |
The goal of this PR is to add support for Jackson 3.
Motivation and Context
Jackson 3 is the latest version from Jackson and it is the next iteration of Jackson.
How Has This Been Tested?
The existing tests were enough
Breaking Changes
The Java MCP SDK now pulls in Jackson 3 instead of Jackson 2. This can be potentially a breaking change in case someone was using
io.modelcontextprotocol.json.jackson.JacksonMcpJsonMapperthen they would need to switch toio.modelcontextprotocol.json.jackson3.JacksonMcpJsonMapperand / or adjust the dependencies so that they pullmcp-coreandmcp-json-jackson3Types of changes
Checklist
Additional context