Skip to content

[Doc] Use registered callable names in examples/README.md#437

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
yuki3738:fix_tool_name_in_http_server_example
Jul 2, 2026
Merged

[Doc] Use registered callable names in examples/README.md#437
koic merged 1 commit into
modelcontextprotocol:mainfrom
yuki3738:fix_tool_name_in_http_server_example

Conversation

@yuki3738

@yuki3738 yuki3738 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

The tools/call cURL example in examples/README.md uses "name": "ExampleTool", but a tool registered by class without an explicit tool_name gets a snake_case name derived from its class name (via StringUtils.handle_from_class_name), so the example fails with Tool not found: ExampleTool. The Tools/Prompts lists in the same file had the same mismatch (ExampleTool, ExamplePrompt, NotificationTool). All entries now use the registered callable names.

How Has This Been Tested?

Ran ruby examples/http_server.rb locally and exercised the cURL flow against it (SSE event payloads shown without the data: prefix):

## tools/list
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"example_tool",...},{"name":"echo",...}]}}

## tools/call with "name":"ExampleTool" (before)
{"jsonrpc":"2.0","id":3,"error":{"code":-32602,"message":"Invalid params","data":"Tool not found: ExampleTool"}}

## tools/call with "name":"example_tool" (after)
{"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"The sum of 5 and 3 is 8"}],"isError":false}}

## prompts/list
{"jsonrpc":"2.0","id":5,"result":{"prompts":[{"name":"example_prompt",...}]}}

The full unit suite and RuboCop pass locally.

Breaking Changes

None (documentation only).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added or updated documentation as needed

The `tools/call` cURL example in `examples/README.md` uses `"name": "ExampleTool"`, but a tool registered by class without an explicit `tool_name` gets a snake_case name derived from its class name (via `StringUtils.handle_from_class_name`), so the example fails with `Tool not found: ExampleTool`. The Tools/Prompts lists in the same file had the same mismatch (`ExampleTool`, `ExamplePrompt`, `NotificationTool`). All entries now use the registered callable names.

How Tested: Ran `ruby examples/http_server.rb` and exercised the cURL flow. `tools/list` returned `example_tool` and `echo`; `tools/call` with `"name": "ExampleTool"` returned `Tool not found: ExampleTool`; with `"name": "example_tool"` returned `The sum of 5 and 3 is 8`. `prompts/list` returned `example_prompt`. The full unit suite and RuboCop pass locally.

Breaking Changes: None (documentation only).
@koic koic merged commit 8b1a41a into modelcontextprotocol:main Jul 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants