Skip to content

Migrate MCP Java SDK 0.8.1 → 2.0.0#1

Open
jerodj-cdata wants to merge 1 commit into
mainfrom
mcp-sdk-2.0
Open

Migrate MCP Java SDK 0.8.1 → 2.0.0#1
jerodj-cdata wants to merge 1 commit into
mainfrom
mcp-sdk-2.0

Conversation

@jerodj-cdata

Copy link
Copy Markdown
Contributor

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 Tables property.

Key decisions

  • Stay on Jackson 2. The default mcp:2.0.0 bundle pulls Jackson 3. To avoid rewriting our own Jackson usage (JsonSchemaBuilder, tests), we depend on mcp-json-jackson2:2.0.0 and wire the transport with JacksonMcpJsonMapper(new ObjectMapper()). Verified mvn dependency:tree resolves Jackson 2 only — no Jackson 3.

Changes

  • pom.xmlmcp:0.8.1mcp-json-jackson2:2.0.0; pin jackson-databind 2.18.3.
  • ProgramServerMcpTransport/StdioServerTransport(ObjectMapper)McpServerTransportProvider/StdioServerTransportProvider(McpJsonMapper); register via Sync{Tool,Resource}Specification lists passed to .tools()/.resources().
  • Tools (ITool + 3 impls) — register(spec)specification() returning a SyncToolSpecification (Tool.builder() + callHandler((exchange, request) -> ...)); results via CallToolResult.builder(); TextContent(roles, priority, text)TextContent(text).
  • ResourceSyncResourceRegistrationSyncResourceSpecification; Resource.builder(uri, name); read handler takes (exchange, request).
  • JsonSchemaBuilder — add buildMap() (Tool.inputSchema is now a Map); build() delegates to it.
  • Tests — added a buildMap() assertion.

Verification

  • mvn clean test12 tests pass.
  • Live stdio JSON-RPC round-trip against the CData CSV JDBC driver: initialize (serverInfo honors ServerName/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

  • draft-07 $schema passes 2.0's default tool-input validation (non-2020-12 dialects are accepted without meta-validation).
  • Resources remain empty unless Tables is set — unchanged from 0.8.1.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant