modelcontextprotocol / modelcontextprotocol/java-sdk
Allow custom or numeric request ID generation (Snowflake MCP server rejects string IDs)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Description
Expected Behavior
The Java SDK should provide a way to configure how request IDs are generated. This could include:
- A public interface or callback for supplying a custom RequestIdGenerator.
- Configuration options to choose between UUID-based, string-based, or numeric-only IDs.
This would help support MCP servers that require strict numeric IDs or forbid UUID/string-based request IDs.
Current Behavior
Currently, the Java SDK:
- Uses a private generateRequestId() method.
- Uses an internal private counter.
- Produces UUID-counter formatted IDs like "62d0970d-0".
- Provides no public extension point to override or customize ID generation.
This causes compatibility issues with MCP servers (such as Snowflake's MCP implementation) that accept only numeric IDs.
Example (hypothetical API):
McpClient client = McpClient.builder()
.withRequestIdGenerator(() -> String.valueOf(counter.incrementAndGet()))
.build();
Context
When integrating with the Snowflake MCP server, requests are rejected because the Java SDK always generates UUID-based IDs.
Workarounds include:
- Implementing a custom transport such as SimpleHttpTransport.
- Remapping request and response IDs manually.
These solutions work but duplicate SDK logic and introduce unnecessary complexity. Providing a built-in, configurable ID generation mechanism would make the SDK more flexible and easier to use.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the private generateRequestId() method and internal counter, then inspect how the McpClient builder and transport pass request IDs. Done means the SDK exposes a configurable generator that can produce numeric IDs while preserving existing behavior; verify request and response IDs remain compatible.
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
- 38/100