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
The gem can be configured using the `MCP.configure` block:
224
226
@@ -365,7 +367,7 @@ When an exception occurs:
365
367
366
368
If no exception reporter is configured, a default no-op reporter is used that silently ignores exceptions.
367
369
368
-
## Tools
370
+
###Tools
369
371
370
372
MCP spec includes [Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) which provide functionality to LLM apps.
371
373
@@ -430,7 +432,7 @@ Tools can include annotations that provide additional metadata about their behav
430
432
431
433
Annotations can be set either through the class definition using the `annotations` class method or when defining a tool using the `define` method.
432
434
433
-
## Prompts
435
+
###Prompts
434
436
435
437
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.
436
438
@@ -556,7 +558,7 @@ The data contains the following keys:
556
558
`tool_name`, `prompt_name` and `resource_uri` are only populated if a matching handler is registered.
557
559
This is to avoid potential issues with metric cardinality
558
560
559
-
## Resources
561
+
###Resources
560
562
561
563
MCP spec includes [Resources](https://modelcontextprotocol.io/specification/2025-06-18/server/resources).
562
564
@@ -612,6 +614,102 @@ server = MCP::Server.new(
612
614
)
613
615
```
614
616
617
+
## Building an MCP Client
618
+
619
+
The `MCP::Client` class provides an interface for interacting with MCP servers.
620
+
621
+
This class supports:
622
+
623
+
- Tool listing via the `tools/list` method
624
+
- Tool invocation via the `tools/call` method
625
+
- Automatic JSON-RPC 2.0 message formatting
626
+
- UUID request ID generation
627
+
628
+
Clients are initialized with a transport layer instance that handles the low-level communication mechanics.
629
+
Authorization is handled by the transport layer.
630
+
631
+
## Transport Layer Interface
632
+
633
+
If the transport layer you need is not included in the gem, you can build and pass your own instances so long as they conform to the following interface:
634
+
635
+
```ruby
636
+
classCustomTransport
637
+
# Sends a JSON-RPC request to the server and returns the raw response.
638
+
#
639
+
#@paramrequest[Hash] A complete JSON-RPC request object.
By default, the HTTP transport layer provides no authentication to the server, but you can provide custom headers if you need authentication. For example, to use Bearer token authentication:
client.tools # will make the call using Bearer auth
701
+
```
702
+
703
+
You can add any custom headers needed for your authentication scheme, or for any other purpose. The client will include these headers on every request.
704
+
705
+
### Tool Objects
706
+
707
+
The client provides a wrapper class for tools returned by the server:
708
+
709
+
-`MCP::Client::Tool` - Represents a single tool with its metadata
710
+
711
+
This class provide easy access to tool properties like name, description, and input schema.
712
+
615
713
## Releases
616
714
617
715
This gem is published to [RubyGems.org](https://rubygems.org/gems/mcp)
0 commit comments