modelcontextprotocol / modelcontextprotocol/java-sdk

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

Đang mở
#703 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement P3
Ngôn ngữ chính
Java
Star
3.7k
Fork
1.1k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
9

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi phương thức private generateRequestId() và bộ đếm nội bộ, sau đó kiểm tra cách builder của McpClient và transport truyền các request ID. Hoàn thành khi SDK cung cấp một generator có thể cấu hình để tạo các ID dạng số mà vẫn giữ nguyên hành vi hiện tại; hãy xác minh rằng các request ID và response ID vẫn tương thích.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.