You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will make all new server instances use the specified protocol version instead of the default version. The protocol version can be reset to the default by setting it to `nil`:
338
339
339
340
```ruby
340
-
MCP::Server.protocol_version=nil
341
+
MCP::Configuration.new(protocol_version:nil)
341
342
```
342
343
343
344
If an invalid `protocol_version` value is set, an `ArgumentError` is raised.
344
345
345
-
Be sure to check the [MCP spec](https://modelcontextprotocol.io/specification) for the protocol version to understand the supported features for the version being set.
346
+
Be sure to check the [MCP spec](https://modelcontextprotocol.io/specification/versioning) for the protocol version to understand the supported features for the version being set.
346
347
347
348
### Exception Reporting
348
349
@@ -366,14 +367,15 @@ If no exception reporter is configured, a default no-op reporter is used that si
366
367
367
368
### Tools
368
369
369
-
MCP spec includes [Tools](https://modelcontextprotocol.io/docs/concepts/tools) which provide functionality to LLM apps.
370
+
MCP spec includes [Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) which provide functionality to LLM apps.
370
371
371
372
This gem provides a `MCP::Tool` class that can be used to create tools in two ways:
372
373
373
374
1. As a class definition:
374
375
375
376
```ruby
376
377
classMyTool < MCP::Tool
378
+
title "My Tool"# WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
377
379
description "This tool performs specific functionality..."
378
380
input_schema(
379
381
properties: {
@@ -382,11 +384,11 @@ class MyTool < MCP::Tool
382
384
required: ["message"]
383
385
)
384
386
annotations(
385
-
title:"My Tool",
386
387
read_only_hint:true,
387
388
destructive_hint:false,
388
389
idempotent_hint:true,
389
-
open_world_hint:false
390
+
open_world_hint:false,
391
+
title:"My Tool"
390
392
)
391
393
392
394
defself.call(message:, server_context:)
@@ -402,10 +404,11 @@ tool = MyTool
402
404
```ruby
403
405
tool =MCP::Tool.define(
404
406
name:"my_tool",
407
+
title:"My Tool", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
405
408
description:"This tool performs specific functionality...",
@@ -419,17 +422,17 @@ e.g. around authentication state.
419
422
420
423
Tools can include annotations that provide additional metadata about their behavior. The following annotations are supported:
421
424
422
-
-`title`: A human-readable title for the tool
423
-
-`read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
424
425
-`destructive_hint`: Indicates if the tool performs destructive operations
425
426
-`idempotent_hint`: Indicates if the tool's operations are idempotent
426
427
-`open_world_hint`: Indicates if the tool operates in an open world context
428
+
-`read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
429
+
-`title`: A human-readable title for the tool
427
430
428
431
Annotations can be set either through the class definition using the `annotations` class method or when defining a tool using the `define` method.
429
432
430
433
### Prompts
431
434
432
-
MCP spec includes [Prompts](https://modelcontextprotocol.io/docs/concepts/prompts), which enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs.
435
+
MCP spec includes [Prompts](https://modelcontextprotocol.io/specification/2025-06-18/server/prompts), which enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs.
433
436
434
437
The `MCP::Prompt` class provides two ways to create prompts:
435
438
@@ -438,6 +441,7 @@ The `MCP::Prompt` class provides two ways to create prompts:
438
441
```ruby
439
442
classMyPrompt < MCP::Prompt
440
443
prompt_name "my_prompt"# Optional - defaults to underscored class name
444
+
title "My Prompt"# WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
441
445
description "This prompt performs specific functionality..."
442
446
arguments [
443
447
MCP::Prompt::Argument.new(
@@ -474,6 +478,7 @@ prompt = MyPrompt
474
478
```ruby
475
479
prompt =MCP::Prompt.define(
476
480
name:"my_prompt",
481
+
title:"My Prompt", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
477
482
description:"This prompt performs specific functionality...",
478
483
arguments: [
479
484
MCP::Prompt::Argument.new(
@@ -540,26 +545,28 @@ end
540
545
```
541
546
542
547
The data contains the following keys:
543
-
`method`: the method called, e.g. `ping`, `tools/list`, `tools/call` etc
544
-
`tool_name`: the name of the tool called
545
-
`prompt_name`: the name of the prompt called
546
-
`resource_uri`: the uri of the resource called
547
-
`error`: if looking up tools/prompts etc failed, e.g. `tool_not_found`
548
-
`duration`: the duration of the call in seconds
548
+
549
+
-`method`: the method called, e.g. `ping`, `tools/list`, `tools/call` etc
550
+
-`tool_name`: the name of the tool called
551
+
-`prompt_name`: the name of the prompt called
552
+
-`resource_uri`: the uri of the resource called
553
+
-`error`: if looking up tools/prompts etc failed, e.g. `tool_not_found`
554
+
-`duration`: the duration of the call in seconds
549
555
550
556
`tool_name`, `prompt_name` and `resource_uri` are only populated if a matching handler is registered.
551
557
This is to avoid potential issues with metric cardinality
552
558
553
559
### Resources
554
560
555
-
MCP spec includes [Resources](https://modelcontextprotocol.io/docs/concepts/resources)
561
+
MCP spec includes [Resources](https://modelcontextprotocol.io/specification/2025-06-18/server/resources).
556
562
557
563
The `MCP::Resource` class provides a way to register resources with the server.
558
564
559
565
```ruby
560
566
resource =MCP::Resource.new(
561
567
uri:"https://example.com/my_resource",
562
-
name:"My Resource",
568
+
name:"my-resource",
569
+
title:"My Resource", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
563
570
description:"Lorem ipsum dolor sit amet",
564
571
mime_type:"text/html",
565
572
)
@@ -577,7 +584,7 @@ server.resources_read_handler do |params|
577
584
[{
578
585
uri: params[:uri],
579
586
mimeType:"text/plain",
580
-
text: params[:uri],
587
+
text:"Hello from example resource! URI: #{params[:uri]}"
0 commit comments