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,101 @@ 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
+
Clients are initialized with a transport layer instance that handles the low-level communication mechanics.
621
+
622
+
## Transport Layer Interface
623
+
624
+
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:
625
+
626
+
```ruby
627
+
classCustomTransport
628
+
# Sends a JSON-RPC request to the server and returns the raw response.
629
+
#
630
+
#@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
700
+
```
701
+
702
+
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.
703
+
704
+
### Tool Objects
705
+
706
+
The client provides a wrapper class for tools returned by the server:
707
+
708
+
-`MCP::Client::Tool` - Represents a single tool with its metadata
709
+
710
+
This class provide easy access to tool properties like name, description, and input schema.
711
+
615
712
## Releases
616
713
617
714
This gem is published to [RubyGems.org](https://rubygems.org/gems/mcp)
0 commit comments