adk-java icon indicating copy to clipboard operation
adk-java copied to clipboard

NoSuchMethodError in DefaultMcpTransportBuilder when using Spring AI 2.0 (MCP 1.x classpath collision)

Open akbarkanso opened this issue 6 months ago • 2 comments

🔴 Required Information

Describe the Bug: The google-adk-spring-ai library is binary-incompatible with Spring AI 2.0.0 (GA) and the MCP 1.x SDK. This is due to a classpath collision in the io.modelcontextprotocol.json.McpJsonMapper class. ADK calls a static method (.getDefault()) that existed in the legacy MCP 0.17.x SDK but has been removed in the 1.x line used by Spring AI 2.0.

Steps to Reproduce:

  1. Create a Spring Boot project and include the Spring AI 2.0.0 BOM and dependencies.
  2. Add the com.google.adk:google-adk-spring-ai:1.2.0 dependency.
  3. Attempt to initialize an McpToolset or any code path that triggers the DefaultMcpTransportBuilder.
  4. Observe the runtime crash during class loading/initialization.

Expected Behavior: The ADK McpToolset should be compatible with the modern mcp-core:1.x architecture, allowing users to leverage the stable release of Spring AI 2.0 alongside Google ADK.

Observed Behavior: The application fails with the following stack trace:

java.lang.NoSuchMethodError: 'io.modelcontextprotocol.json.McpJsonMapper io.modelcontextprotocol.json.McpJsonMapper.getDefault()'
    at com.google.adk.tools.mcp.DefaultMcpTransportBuilder.<clinit>(DefaultMcpTransportBuilder.java:...)

Environment Details:

  • ADK Library Version: 1.2.0
  • OS: macOS / Linux
  • TS Version: N/A (Java Environment)

Model Information:

  • Which model is being used: N/A (This is a protocol/library level initialization error)

🟡 Optional Information

Regression: No. This is an incompatibility introduced by the architectural shift between MCP 0.17.x (which ADK pins) and MCP 1.x (which Spring AI 2.0 pins).

Additional Context: Both google-adk and spring-ai now share a dependency on the same Fully Qualified Class Name (FQCN): io.modelcontextprotocol.json.McpJsonMapper.

  • ADK's DefaultMcpTransportBuilder expects a static getDefault() method.
  • Spring AI 2.0 pulls in mcp-core:1.x, where this method was removed/renamed to createDefault(). Since Gradle/Maven resolves the conflict to version 1.x to satisfy Spring AI, the ADK code attempts to call a non-existent method on the 1.x class.

Minimal Reproduction Code: In a standard Spring AI 2.0 project, simply attempting to use the default MCP transport via ADK will fail:

// This triggers the static initializer of DefaultMcpTransportBuilder
McpToolset toolset = McpToolset.builder()
    .parameters(StreamableHttpServerParameters.builder()
        .uri("https://mcp-server/mcp")
        .build())
    .build();

How often has this issue occurred?:

  • Always (100%) when Spring AI 2.0 and Google ADK 1.2.0 are present on the same classpath.

akbarkanso avatar May 11 '26 15:05 akbarkanso

Hi @akbarkanso, thank you for reporting this issue. I have been able to reproduce the NoSuchMethodError as described. The reason you are getting this error because Spring transitive dependency version conflict. The ADK currently expects mcp-core:0.17.0, while Spring AI 2.0 transitively pulls in mcp-core:1.1.0. To resolve this, could you please pin the io.modelcontextprotocol.sdk:mcp-core version to <version>0.17.0</version> like below and let us know if your issue is resolved?

<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>io.modelcontextprotocol.sdk</groupId>
				<artifactId>mcp-core</artifactId>
				<version>0.17.0</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

hemasekhar-p avatar May 12 '26 11:05 hemasekhar-p

Closing this issue since it has been stale for more than 14 days.

hemasekhar-p avatar May 29 '26 06:05 hemasekhar-p