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
Copy file name to clipboardExpand all lines: README.md
+16-11Lines changed: 16 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -588,26 +588,30 @@ otherwise `resources/read` requests will be a no-op.
588
588
## Building an MCP Client
589
589
590
590
The `MCP::Client` class provides an interface for interacting with MCP servers.
591
-
Clients are initialized with a transport layer instance that instructs them how to interact with the server.
591
+
Clients are initialized with a transport layer instance that handles the low-level communication mechanics.
592
+
593
+
## Transport Layer Interface
592
594
593
595
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:
594
596
595
597
```ruby
596
598
classCustomTransport
597
-
deftools
598
-
# Must return Array<MCP::Client::Tool>
599
-
end
600
-
601
-
defcall_tool(tool:, input:)
602
-
# tool: MCP::Client::Tool
603
-
# input: Hash - the arguments to pass to the tool
604
-
# Returns: Hash - the content from the response (typically response.dig("result", "content"))
599
+
# Sends a JSON-RPC request to the server and returns the raw response
600
+
#
601
+
#@paramrequest[Hash] A complete JSON-RPC request object.
**Note:** We strongly recommend returning `MCP::Client::Tool` instances rather than custom tool objects with the same interface, as this ensures compatibility with future SDK features and provides a consistent interface.
610
-
611
615
### HTTP Transport Layer
612
616
613
617
Use the `MCP::Client::Http` transport to interact with MCP servers using simple HTTP requests.
@@ -685,3 +689,4 @@ Releases are triggered by PRs to the `main` branch updating the version number i
685
689
1.**Merge your PR to the main branch** - This will automatically trigger the release workflow via GitHub Actions
686
690
687
691
When changes are merged to the `main` branch, the GitHub Actions workflow (`.github/workflows/release.yml`) is triggered and the gem is published to RubyGems.
0 commit comments