modelcontextprotocol / modelcontextprotocol/java-sdk

Support parameter deserialisation to Java Objects using the MCPJsonMapper

Open
#836 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting for triage
Dominant language
Java
Stars
3.7k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
9

Description

Expected Behavior
Although all the transports provided with the SDK require a jsonMapper they only deserialize inputs as Java maps.
It should be possible to specifiy the Java input types along with the schema so that the transports can deserialize into real Java objects

Same applies for output serialisation. Complex Java types cannot be used directly as output.

Current Behavior

Currently transports use the static method McpSchema.deserializeJsonRpcMessage(jsonMapper, <string>); that cannot be extended and does jsonMapper.readValue(jsonText, MAP_TYPE_REF);

Context

This would greatly simplify applying each request to real java methods with matching parameters. Without that an additional jackson deserialisation is necessary, making the first deserialisation to Map redundant. It's unnecessary code that each implementor must produce.

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 tracing the transports that call McpSchema.deserializeJsonRpcMessage(jsonMapper, string) and inspect how MCPJsonMapper is supplied. Determine how transports can accept Java input types and schemas, then verify that request inputs deserialize to Java objects and complex outputs serialize without an additional Map-based conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.