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:
222
224
@@ -363,7 +365,7 @@ When an exception occurs:
363
365
364
366
If no exception reporter is configured, a default no-op reporter is used that silently ignores exceptions.
365
367
366
-
## Tools
368
+
###Tools
367
369
368
370
MCP spec includes [Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) which provide functionality to LLM apps.
369
371
@@ -428,7 +430,7 @@ Tools can include annotations that provide additional metadata about their behav
428
430
429
431
Annotations can be set either through the class definition using the `annotations` class method or when defining a tool using the `define` method.
430
432
431
-
## Prompts
433
+
###Prompts
432
434
433
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.
434
436
@@ -554,7 +556,7 @@ The data contains the following keys:
554
556
`tool_name`, `prompt_name` and `resource_uri` are only populated if a matching handler is registered.
555
557
This is to avoid potential issues with metric cardinality
556
558
557
-
## Resources
559
+
###Resources
558
560
559
561
MCP spec includes [Resources](https://modelcontextprotocol.io/specification/2025-06-18/server/resources).
560
562
@@ -590,6 +592,101 @@ end
590
592
591
593
otherwise `resources/read` requests will be a no-op.
592
594
595
+
## Building an MCP Client
596
+
597
+
The `MCP::Client` class provides an interface for interacting with MCP servers.
598
+
Clients are initialized with a transport layer instance that handles the low-level communication mechanics.
599
+
600
+
## Transport Layer Interface
601
+
602
+
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:
603
+
604
+
```ruby
605
+
classCustomTransport
606
+
# Sends a JSON-RPC request to the server and returns the raw response.
607
+
#
608
+
#@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
678
+
```
679
+
680
+
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.
681
+
682
+
### Tool Objects
683
+
684
+
The client provides a wrapper class for tools returned by the server:
685
+
686
+
-`MCP::Client::Tool` - Represents a single tool with its metadata
687
+
688
+
This class provide easy access to tool properties like name, description, and input schema.
689
+
593
690
## Releases
594
691
595
692
This gem is published to [RubyGems.org](https://rubygems.org/gems/mcp)
0 commit comments