Skip to content

Commit 1a2750d

Browse files
authored
Merge pull request #222 from koic/update_readme_for_instrumentation_callback
[Doc] Add `tool_arguments` to instrumentation callback documentation
2 parents ebd658d + 1c449ae commit 1a2750d

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

README.md

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,17 @@ The instrumentation callback receives a hash with the following possible keys:
396396

397397
- `method`: (String) The protocol method called (e.g., "ping", "tools/list")
398398
- `tool_name`: (String, optional) The name of the tool called
399+
- `tool_arguments`: (Hash, optional) The arguments passed to the tool
399400
- `prompt_name`: (String, optional) The name of the prompt called
400401
- `resource_uri`: (String, optional) The URI of the resource called
401402
- `error`: (String, optional) Error code if a lookup failed
402403
- `duration`: (Float) Duration of the call in seconds
403404
- `client`: (Hash, optional) Client information with `name` and `version` keys, from the initialize request
404405

406+
> [!NOTE]
407+
> `tool_name`, `prompt_name` and `resource_uri` are only populated if a matching handler is registered.
408+
> This is to avoid potential issues with metric cardinality.
409+
405410
**Type:**
406411

407412
```ruby
@@ -412,9 +417,11 @@ instrumentation_callback = ->(data) { ... }
412417
**Example:**
413418

414419
```ruby
415-
config.instrumentation_callback = ->(data) {
416-
puts "Instrumentation: #{data.inspect}"
417-
}
420+
MCP.configure do |config|
421+
config.instrumentation_callback = ->(data) {
422+
puts "Instrumentation: #{data.inspect}"
423+
}
424+
end
418425
```
419426

420427
### Server Protocol Version
@@ -864,31 +871,6 @@ The server will handle prompt listing and execution through the MCP protocol met
864871
- `prompts/list` - Lists all registered prompts and their schemas
865872
- `prompts/get` - Retrieves and executes a specific prompt with arguments
866873

867-
### Instrumentation
868-
869-
The server allows registering a callback to receive information about instrumentation.
870-
To register a handler pass a proc/lambda to as `instrumentation_callback` into the server constructor.
871-
872-
```ruby
873-
MCP.configure do |config|
874-
config.instrumentation_callback = ->(data) {
875-
puts "Got instrumentation data #{data.inspect}"
876-
}
877-
end
878-
```
879-
880-
The data contains the following keys:
881-
882-
- `method`: the method called, e.g. `ping`, `tools/list`, `tools/call` etc
883-
- `tool_name`: the name of the tool called
884-
- `prompt_name`: the name of the prompt called
885-
- `resource_uri`: the uri of the resource called
886-
- `error`: if looking up tools/prompts etc failed, e.g. `tool_not_found`
887-
- `duration`: the duration of the call in seconds
888-
889-
`tool_name`, `prompt_name` and `resource_uri` are only populated if a matching handler is registered.
890-
This is to avoid potential issues with metric cardinality
891-
892874
### Resources
893875

894876
MCP spec includes [Resources](https://modelcontextprotocol.io/specification/latest/server/resources).

0 commit comments

Comments
 (0)