Skip to content

ToolConverter fails to convert MCP tools - uses empty parameters instead of parametersJsonSchema #1064

@abhadra2

Description

@abhadra2

Describe the Bug:

Google ADK's ToolConverter in the Spring AI adapter fails to convert MCP (Model Context Protocol) tools to Spring AI FunctionCallback objects, throwing IllegalArgumentException: inputType cannot be null. The converter incorrectly checks the parameters field (which is empty for MCP tools) instead of using the parametersJsonSchema field (which contains the correct parameter schema).

Steps to Reproduce:

Set up an MCP server using Spring AI MCP Server (spring-ai-starter-mcp-server-webflux) with tool methods annotated with @mcptool and @ToolParam
Configure an agent in ADK to use MCP tools from the server:
Use the Spring AI adapter to create the agent model:
LlmAgent.Builder builder = LlmAgent.builder()
.model(new SpringAI(chatModel, modelName)) // Using Spring AI adapter
.tools(mcpTools); // MCP tools from McpToolset
Execute the agent with a user query
Error occurs in ToolConverter.convertToSpringAiTools() when calling callbackBuilder.build()

Expected Behavior:

The ToolConverter should successfully convert MCP tools to Spring AI function callbacks by extracting parameter schema from the FunctionDeclaration.parametersJsonSchema() field, which contains valid JSON Schema with correct parameter names and types.

Observed Behavior:

The conversion fails with:

java.lang.IllegalArgumentException: inputType cannot be null
at ToolConverter.convertToSpringAiTools()
at callbackBuilder.build()

Debugging shows that FunctionDeclaration has:

parameters=Optional.empty ← ToolConverter incorrectly uses this
parametersJsonSchema=Optional[JsonSchema[type=object, properties={ids={type=string}, vsCurrencies={type=string}}, required=[ids, vsCurrencies]]] ← Contains correct schema
Environment Details:

ADK Library Version: 1.0.0-alpha (google-adk, google-adk-spring-ai)
OS: macOS (darwin 25.2.0)
Java Version: 21
Spring AI Version: 1.1.0
Spring Boot Version: 3.4.2
Model Information:

Model being used: gemini-2.5-flash via Spring AI's ChatModel
Issue occurs with Spring AI adapter; native ADK models (e.g., gemini-2.5-flash) work correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions