modelcontextprotocol / modelcontextprotocol/java-sdk

Allow custom or numeric request ID generation (Snowflake MCP server rejects string IDs)

未关闭
#703 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement P3
主要语言
Java
星标
3.7k
派生
1.1k
平均合并
1 天 15 小时
30 天内合并 PR
9

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先跟踪 private generateRequestId() 方法和内部计数器,然后检查 McpClient builder 和 transport 如何传递请求 ID。完成标准是 SDK 提供一个可配置的生成器,能够生成数字 ID,同时保留现有行为;验证请求 ID 和响应 ID 仍然兼容。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。