Migrate MCP Java SDK 0.8.1 → 2.0.0#1
Open
jerodj-cdata wants to merge 1 commit into
Open
Conversation
Upgrades from the pre-1.0 SDK to 2.0.0, which is a breaking API change
across transport, tool/resource registration, and content construction.
Behavior for end users is unchanged (same tools, same CSV output).
- pom.xml: replace mcp:0.8.1 with mcp-json-jackson2:2.0.0 (keeps JSON on
Jackson 2 instead of the 2.0 default of Jackson 3); pin jackson-databind
to 2.18.3
- Program: ServerMcpTransport/StdioServerTransport(ObjectMapper) ->
McpServerTransportProvider/StdioServerTransportProvider(McpJsonMapper via
JacksonMcpJsonMapper); register tools/resources by collecting
Sync{Tool,Resource}Specification lists into .tools()/.resources()
- Tools: ITool.register(spec) -> specification() returning a
SyncToolSpecification (Tool.builder + callHandler(exchange, request));
CallToolResult.builder(); simple TextContent(text)
- Resource: SyncResourceRegistration -> SyncResourceSpecification;
Resource.builder(uri, name); read handler takes (exchange, request)
- JsonSchemaBuilder: add buildMap() (Tool.inputSchema is now Map);
build() delegates to it
- Tests: add a buildMap() assertion (12 tests total)
Verified with mvn clean test and a live stdio JSON-RPC round-trip
(initialize, tools/list, tools/call, resources/list, resources/read)
against the CData CSV JDBC driver.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
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.
Summary
Upgrades the MCP Java SDK from the pre-1.0 0.8.1 to 2.0.0. This is an API-breaking jump across transport, tool/resource registration, and content construction — but end-user behavior is unchanged: same three tools, same CSV output, resources still opt-in via the
Tablesproperty.Key decisions
mcp:2.0.0bundle pulls Jackson 3. To avoid rewriting our own Jackson usage (JsonSchemaBuilder, tests), we depend onmcp-json-jackson2:2.0.0and wire the transport withJacksonMcpJsonMapper(new ObjectMapper()). Verifiedmvn dependency:treeresolves Jackson 2 only — no Jackson 3.Changes
mcp:0.8.1→mcp-json-jackson2:2.0.0; pinjackson-databind2.18.3.ServerMcpTransport/StdioServerTransport(ObjectMapper)→McpServerTransportProvider/StdioServerTransportProvider(McpJsonMapper); register viaSync{Tool,Resource}Specificationlists passed to.tools()/.resources().ITool+ 3 impls) —register(spec)→specification()returning aSyncToolSpecification(Tool.builder()+callHandler((exchange, request) -> ...)); results viaCallToolResult.builder();TextContent(roles, priority, text)→TextContent(text).SyncResourceRegistration→SyncResourceSpecification;Resource.builder(uri, name); read handler takes(exchange, request).buildMap()(Tool.inputSchemais now aMap);build()delegates to it.buildMap()assertion.Verification
mvn clean test— 12 tests pass.initialize(serverInfo honorsServerName/ServerVersion),tools/list(3 tools, correct schemas),tools/call csv_run_query(correct CSV,isError=false),resources/list+resources/read(column metadata). Zero errors — coverage the old code never had.Notes / risks checked
$schemapasses 2.0's default tool-input validation (non-2020-12 dialects are accepted without meta-validation).Tablesis set — unchanged from 0.8.1.🤖 Generated with Claude Code