Skip to content

Commit 9ed51ff

Browse files
committed
attempt to break up readme between server and client
1 parent 50ad8c8 commit 9ed51ff

File tree

1 file changed

+70
-88
lines changed

1 file changed

+70
-88
lines changed

README.md

Lines changed: 70 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,9 @@ Add this line to your application's Gemfile:
1010
gem 'mcp'
1111
```
1212

13-
### Optional Dependencies
13+
You may need to add additional dependencies depending on which features you wish to access.
1414

15-
The MCP gem has different dependency requirements depending on your use case:
16-
17-
**For Server-only usage:**
18-
```ruby
19-
gem 'mcp'
20-
```
21-
22-
**For client HTTP transport usage:**
23-
```ruby
24-
gem 'mcp'
25-
gem 'faraday', '>= 2.0'
26-
```
27-
28-
And then execute:
29-
30-
```console
31-
$ bundle install
32-
```
33-
34-
Or install it yourself as:
35-
36-
```console
37-
$ gem install mcp
38-
```
39-
40-
## MCP Server
15+
## Building an MCP Server
4116

4217
The `MCP::Server` class is the core component that handles JSON-RPC requests and responses.
4318
It implements the Model Context Protocol specification, handling model context requests and responses.
@@ -231,67 +206,6 @@ $ ruby examples/stdio_server.rb
231206
{"jsonrpc":"2.0","id":"2","method":"tools/list"}
232207
```
233208

234-
## MCP Client
235-
236-
The `MCP::Client` module provides client implementations for interacting with MCP servers. Currently, it supports HTTP transport for making JSON-RPC requests to MCP servers.
237-
238-
**Note:** The client HTTP transport requires the `faraday` gem. Add `gem 'faraday', '>= 2.0'` to your Gemfile if you plan to use the client HTTP transport functionality.
239-
240-
### HTTP Client
241-
242-
The `MCP::Client::Http` class provides a simple HTTP client for interacting with MCP servers:
243-
244-
```ruby
245-
client = MCP::Client::Http.new(url: "https://api.example.com/mcp")
246-
247-
# List available tools
248-
tools = client.tools
249-
tools.each do |tool|
250-
puts "Tool: #{tool.name}"
251-
puts "Description: #{tool.description}"
252-
puts "Input Schema: #{tool.input_schema}"
253-
end
254-
255-
# Call a specific tool
256-
response = client.call_tool(
257-
tool: tools.first,
258-
input: { message: "Hello, world!" }
259-
)
260-
```
261-
262-
The HTTP client supports:
263-
- Tool listing via the `tools/list` method
264-
- Tool invocation via the `tools/call` method
265-
- Automatic JSON-RPC 2.0 message formatting
266-
- UUID v7 request ID generation
267-
- Setting headers for things like authorization
268-
269-
### HTTP Authorization
270-
271-
By default, the HTTP client has no authentication, but it supports custom headers for authentication. For example, to use Bearer token authentication:
272-
273-
```ruby
274-
client = MCP::Client::Http.new(
275-
url: "https://api.example.com/mcp",
276-
headers: {
277-
"Authorization" => "Bearer my_token"
278-
}
279-
)
280-
281-
client.tools # will make the call using Bearer auth
282-
```
283-
284-
You can add any custom headers needed for your authentication scheme. The client will include these headers in all requests.
285-
286-
### Tool Objects
287-
288-
The client provides wrapper objects for tools returned by the server:
289-
290-
- `MCP::Client::Tool` - Represents a single tool with its metadata
291-
- `MCP::Client::Tools` - Collection of tools with enumerable functionality
292-
293-
These objects provide easy access to tool properties like name, description, and input schema.
294-
295209
## Configuration
296210

297211
The gem can be configured using the `MCP.configure` block:
@@ -659,6 +573,74 @@ end
659573

660574
otherwise `resources/read` requests will be a no-op.
661575

576+
## Building an MCP Client
577+
578+
The `MCP::Client` module provides client implementations for interacting with MCP servers. Currently, it supports HTTP transport for making JSON-RPC requests to MCP servers.
579+
580+
**Note:** The client HTTP transport requires the `faraday` gem. Add `gem 'faraday', '>= 2.0'` to your Gemfile if you plan to use the client HTTP transport functionality.
581+
582+
### HTTP Transport Layer
583+
584+
You'll need to add `faraday` as a dependency to use the HTTP transport layer.
585+
586+
```ruby
587+
gem 'mcp'
588+
gem 'faraday', '>= 2.0'
589+
```
590+
591+
The `MCP::Client::Http` class provides a simple HTTP client for interacting with MCP servers:
592+
593+
```ruby
594+
client = MCP::Client::Http.new(url: "https://api.example.com/mcp")
595+
596+
# List available tools
597+
tools = client.tools
598+
tools.each do |tool|
599+
puts "Tool: #{tool.name}"
600+
puts "Description: #{tool.description}"
601+
puts "Input Schema: #{tool.input_schema}"
602+
end
603+
604+
# Call a specific tool
605+
response = client.call_tool(
606+
tool: tools.first,
607+
input: { message: "Hello, world!" }
608+
)
609+
```
610+
611+
The HTTP client supports:
612+
- Tool listing via the `tools/list` method
613+
- Tool invocation via the `tools/call` method
614+
- Automatic JSON-RPC 2.0 message formatting
615+
- UUID v7 request ID generation
616+
- Setting headers for things like authorization
617+
618+
#### HTTP Authorization
619+
620+
By default, the HTTP client has no authentication, but it supports custom headers for authentication. For example, to use Bearer token authentication:
621+
622+
```ruby
623+
client = MCP::Client::Http.new(
624+
url: "https://api.example.com/mcp",
625+
headers: {
626+
"Authorization" => "Bearer my_token"
627+
}
628+
)
629+
630+
client.tools # will make the call using Bearer auth
631+
```
632+
633+
You can add any custom headers needed for your authentication scheme. The client will include these headers in all requests.
634+
635+
### Tool Objects
636+
637+
The client provides wrapper objects for tools returned by the server:
638+
639+
- `MCP::Client::Tool` - Represents a single tool with its metadata
640+
- `MCP::Client::Tools` - Collection of tools with enumerable functionality
641+
642+
These objects provide easy access to tool properties like name, description, and input schema.
643+
662644
## Releases
663645

664646
This gem is published to [RubyGems.org](https://rubygems.org/gems/mcp)

0 commit comments

Comments
 (0)