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 摘要。