Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was called

Đang mở Phù hợp với người mới
#1,346 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Tìm trong McpAsyncServer.java và McpStatelessAsyncServer.java handler tools/call xây dựng McpError với thông báo cố định "Unknown tool: invalid_tool_name". Thay placeholder bằng tên được yêu cầu đã có trong phạm vi dưới dạng callToolRequest.name(), giữ nguyên trường data. Chạy các bài kiểm thử máy chủ hiện có để xác nhận cả hai biến thể async và stateless giờ đây trả về ví dụ Unknown tool: delete_order.

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

Mô tả

The error for a tools/call with an unknown tool name has a fixed message, Unknown tool: invalid_tool_name, whatever name was called:

// McpAsyncServer.java (and McpStatelessAsyncServer.java)
return Mono.error(McpError.builder(McpSchema.ErrorCodes.INVALID_PARAMS)
    .message("Unknown tool: invalid_tool_name")
    .data("Tool not found: " + callToolRequest.name())
    .build());

A call to delete_order, which the server does not have, gets:

{"code": -32602, "message": "Unknown tool: invalid_tool_name", "data": "Tool not found: delete_order"}

The text looks like it was taken from the error example in the MCP specification, where invalid_tool_name is a placeholder. Clients and logs usually show only message, so the name of the tool is lost, and it looks as if the tool were called invalid_tool_name.

Expected: the message names the tool that was called, such as Unknown tool: delete_order, in both McpAsyncServer and McpStatelessAsyncServer. data can stay as it is.

Seen with mcp-core 2.2.0, and still in main (779893c).

Claude Code on behalf of Claus Ibsen

Ngôn ngữ chính
Java
Star
3.8k
Fork
1.1k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
38

Chuẩn bị môi trường

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.

Issue khác của modelcontextprotocol/java-sdk

Tất cả issue của modelcontextprotocol/java-sdk

Issue tương tự

Thêm issue về Java

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.