Skip to content

fix: upgrade MCP SDK to 2.0.0 and update schema handling - #1455

Open
hemasekhar-p wants to merge 1 commit into
google:mainfrom
hemasekhar-p:issue1453-fix
Open

fix: upgrade MCP SDK to 2.0.0 and update schema handling#1455
hemasekhar-p wants to merge 1 commit into
google:mainfrom
hemasekhar-p:issue1453-fix

Conversation

@hemasekhar-p

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
When using google-adk alongside spring-ai 2.0.x, invoking MCP tool declarations (AbstractMcpTool.declaration()) fails with a runtime java.lang.NoSuchMethodError. This is caused by a version incompatibility: google-adk pinned io.modelcontextprotocol.sdk:mcp to 1.1.2 where Tool.inputSchema() returned a McpSchema.JsonSchema record. In MCP Java SDK 2.0.0 (used by Spring AI 2.0.x), Tool.inputSchema() returns Map<String, Object>. Additionally, MCP SDK 2.0 removes the deprecated customizeRequest(...) method on SSE transport builders and strictly enforces non-null inputSchema on Tool instances.

Solution:

  • Upgrade MCP SDK Version: Bumped <mcp.version> from 1.1.2 to 2.0.0 in root pom.xml.
  • Update Tool Declaration: Updated AbstractMcpTool.java to handle Map<String, Object> returned by mcpTool.inputSchema() and passed it directly to FunctionDeclaration.builder().parametersJsonSchema(inputSchema).
  • Handle Empty/Null Schema Conversion: Updated ConversionUtils.adkToMcpToolType() to provide a spec-compliant default empty schema ({"type": "object"}) when a tool declaration omits parameters, satisfying MCP SDK 2.0's strict non-null validation.
  • Update SSE Transport Builder: Replaced the removed .customizeRequest(...) call on HttpClientSseClientTransport.Builder with .requestBuilder(HttpRequest.Builder) in DefaultMcpTransportBuilder.java.

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • I have added or updated unit tests for my change.

  • All unit tests pass locally.

  • ConversionUtilsTest: Verified conversions for ADK tools with parameters, no parameters, and no declarations without throwing IllegalArgumentException.

  • AbstractMcpToolTest: Verified tool declarations and JSON schema mappings using MCP SDK 2.0.0 Map<String, Object> schemas.

  • DefaultMcpTransportBuilderTest: Verified Stdio, SSE (with custom headers via requestBuilder), and Streamable HTTP transport builders.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

@hemasekhar-p hemasekhar-p self-assigned this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using adk with spring boot ai 2.0.x does not seem to work as expected due to differing io.modelcontextprotocol.sdk versions

1 participant