-
Notifications
You must be signed in to change notification settings - Fork 800
Moves mcp-json API back into mcp-core for simplified dependencies and support of osgi runtimes #762
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
Open
scottslewis
wants to merge
14
commits into
modelcontextprotocol:main
Choose a base branch
from
scottslewis:issue_612_jackson3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+366
−346
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
003eb6e
Rebasing on main after #742 merged. Moves mcp-json API back into
scottslewis bedf075
Fix for missing <scope>test</scope> in mcp-core. Thanks to
scottslewis fbda61f
Update mcp-core/src/main/java/io/modelcontextprotocol/util/McpService…
scottslewis 76ce84d
Removed DefaultMcpJsonMapperSupplier
scottslewis e6041be
Merge branch 'issue_612_jackson3' of https://github.com/scottslewis/m…
scottslewis e8d3fff
Deleted mcp-json
scottslewis 75a99f9
Formatting fix
scottslewis 2efdff1
Added copyright headers.
scottslewis fb71dbd
Added non-OSGi vs. OSGi initialization behavior for
scottslewis bf8a450
Added javadocs about non-OSGi and OSGi initialization of McpJsonDefaults
scottslewis a5662c5
Fix for previously omitted Service-Component manifest entry.
scottslewis 30e2765
Update mcp-core/src/main/java/io/modelcontextprotocol/util/McpService…
scottslewis 454a5ea
Documentation fix
scottslewis 8f8d14a
Merge branch 'issue_612_jackson3' of https://github.com/scottslewis/m…
scottslewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
mcp-core/src/main/java/io/modelcontextprotocol/json/McpJsonDefaults.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /** | ||
| * Copyright 2026 - 2026 the original author or authors. | ||
| */ | ||
| package io.modelcontextprotocol.json; | ||
scottslewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import io.modelcontextprotocol.json.schema.JsonSchemaValidator; | ||
| import io.modelcontextprotocol.json.schema.JsonSchemaValidatorSupplier; | ||
| import io.modelcontextprotocol.util.McpServiceLoader; | ||
|
|
||
| /** | ||
| * This class is to be used to provide access to the default McpJsonMapper and to the | ||
| * default JsonSchemaValidator instances via the static methods: getDefaultMcpJsonMapper | ||
| * and getDefaultJsonSchemaValidator. | ||
| * <p> | ||
| * </p> | ||
| * The initialization of (singleton) instances of this class is different in non-OSGi | ||
| * environments and OSGi environments. Specifically, in non-OSGi environments The | ||
| * McpJsonDefaults class will be loaded by whatever classloader is used to call one of the | ||
| * existing static get methods for the first time. For servers, this will usually be in | ||
| * response to the creation of the first McpServer instance. At that first time, the | ||
| * mcpMapperServiceLoader and mcpValidatorServiceLoader will be null, and the | ||
| * McpJsonDefaults constructor will be called, creating/initializing the | ||
| * mcpMapperServiceLoader and the mcpValidatorServiceLoader...which will then be used to | ||
| * call the ServiceLoader.load method. | ||
| * <p> | ||
| * </p> | ||
| * In OSGi environments, upon bundle activation SCR will create a new (singleton) instance | ||
| * of McpJsonDefaults (via the constructor), and then inject suppliers via the | ||
| * setMcpJsonMapperSupplier and setJsonSchemaValidatorSupplier methods with the | ||
| * SCR-discovered instances of those services. This does depend upon the jars/bundles | ||
| * providing those suppliers to be started/activated. This SCR behavior is dictated by xml | ||
| * files in OSGi-INF directory of mcp-core (this project/jar/bundle), and the jsonmapper | ||
| * and jsonschemvalidator provider jars/bundles (e.g. mcp-json-jackson2, 3, or others). | ||
| * | ||
| * <p> | ||
| * </p> | ||
| * | ||
| */ | ||
| public class McpJsonDefaults { | ||
scottslewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| protected static McpServiceLoader<McpJsonMapperSupplier, McpJsonMapper> mcpMapperServiceLoader; | ||
|
|
||
| protected static McpServiceLoader<JsonSchemaValidatorSupplier, JsonSchemaValidator> mcpValidatorServiceLoader; | ||
|
|
||
| public McpJsonDefaults() { | ||
| mcpMapperServiceLoader = new McpServiceLoader<McpJsonMapperSupplier, McpJsonMapper>( | ||
| McpJsonMapperSupplier.class); | ||
| mcpValidatorServiceLoader = new McpServiceLoader<JsonSchemaValidatorSupplier, JsonSchemaValidator>( | ||
| JsonSchemaValidatorSupplier.class); | ||
| } | ||
|
|
||
| void setMcpJsonMapperSupplier(McpJsonMapperSupplier supplier) { | ||
| mcpMapperServiceLoader.setSupplier(supplier); | ||
| } | ||
|
|
||
| void unsetMcpJsonMapperSupplier(McpJsonMapperSupplier supplier) { | ||
| mcpMapperServiceLoader.unsetSupplier(supplier); | ||
| } | ||
|
|
||
| public synchronized static McpJsonMapper getDefaultMcpJsonMapper() { | ||
scottslewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (mcpMapperServiceLoader == null) { | ||
| new McpJsonDefaults(); | ||
| } | ||
| return mcpMapperServiceLoader.getDefault(); | ||
| } | ||
scottslewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void setJsonSchemaValidatorSupplier(JsonSchemaValidatorSupplier supplier) { | ||
| mcpValidatorServiceLoader.setSupplier(supplier); | ||
| } | ||
|
|
||
| void unsetJsonSchemaValidatorSupplier(JsonSchemaValidatorSupplier supplier) { | ||
| mcpValidatorServiceLoader.unsetSupplier(supplier); | ||
| } | ||
|
|
||
| public synchronized static JsonSchemaValidator getDefaultJsonSchemaValidator() { | ||
| if (mcpValidatorServiceLoader == null) { | ||
| new McpJsonDefaults(); | ||
| } | ||
| return mcpValidatorServiceLoader.getDefault(); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.