spring-projects / spring-projects/spring-ai

deserialization doesn't work with kotlin and @McpToolParam

Open
#4,481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 10h
Merged PRs (30d)
5

Description

Bug description
When using @Tool+@ToolParam with a bean that returns ToolCallbackProvider for the class, if the ToolParam is an object, such as

@Serialization
data class UserSearchRequest(
  userId: UUID? = null,
  username: String? = null,
)

It will be deserialized as expected. When using @McpTool+@McpToolParam, I instead get the error

"Cannot construct instance of `net.package.UserSearchRequest` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]"

Environment
spring-ai-starter-mcp-server-webmvc:1.1.0-M2
spring-boot 3.5.4
running in stateless mode side by side with a spring webmvc service.

Expected behavior
The data object to be deserialized successfully.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the shown UserSearchRequest and @McpTool/@McpToolParam setup, then compare it with the working @Tool/@ToolParam path. Inspect the Spring MVC MCP server deserialization entry point and verify that the Kotlin data object is deserialized successfully without the no-Creators error.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.