Skip to content

Commit de45377

Browse files
committed
Experimental MCP Support
1 parent 829bdd0 commit de45377

File tree

8 files changed

+150
-384
lines changed

8 files changed

+150
-384
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Metrics/PerceivedComplexity:
3636
Metrics/ParameterLists:
3737
Enabled: false
3838

39-
Style/FrozenLiteralComment:
39+
Style/FrozenStringLiteralComment:
4040
Enabled: false
4141

4242
Style/MultilineBlockChain:

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## [0.8.0] - 2025-05-08
1+
## [0.8.0] - 2024-05-08
22
### Added
3-
* **MCP integration** — new `Raix::MCP` concern and `mcp` DSL for declaring remote MCP servers.
3+
* **MCP integration (Experimental)** — new `Raix::MCP` concern and `mcp` DSL for declaring remote MCP servers.
44
* Automatically fetches `tools/list`, registers remote tools as OpenAI‑compatible function schemas, and defines proxy methods that forward `tools/call`.
55
* `ChatCompletion#tools` now returns remote MCP tools alongside local `function` declarations.
66

Gemfile.lock

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ PATH
33
specs:
44
raix (0.8.0)
55
activesupport (>= 6.0)
6-
async-http-faraday (~> 0.21)
76
faraday-retry (~> 2.0)
87
open_router (~> 0.2)
98
ruby-openai (~> 7)
@@ -24,38 +23,13 @@ GEM
2423
addressable (2.8.6)
2524
public_suffix (>= 2.0.2, < 6.0)
2625
ast (2.4.2)
27-
async (2.23.1)
28-
console (~> 1.29)
29-
fiber-annotation
30-
io-event (~> 1.9)
31-
metrics (~> 0.12)
32-
traces (~> 0.15)
33-
async-http (0.88.0)
34-
async (>= 2.10.2)
35-
async-pool (~> 0.9)
36-
io-endpoint (~> 0.14)
37-
io-stream (~> 0.6)
38-
metrics (~> 0.12)
39-
protocol-http (~> 0.49)
40-
protocol-http1 (~> 0.30)
41-
protocol-http2 (~> 0.22)
42-
traces (~> 0.10)
43-
async-http-faraday (0.21.0)
44-
async-http (~> 0.42)
45-
faraday
46-
async-pool (0.10.3)
47-
async (>= 1.25)
4826
backport (1.2.0)
4927
base64 (0.2.0)
5028
benchmark (0.3.0)
5129
bigdecimal (3.1.8)
5230
coderay (1.1.3)
5331
concurrent-ruby (1.3.3)
5432
connection_pool (2.4.1)
55-
console (1.30.2)
56-
fiber-annotation
57-
fiber-local (~> 1.1)
58-
json
5933
crack (0.4.5)
6034
rexml
6135
diff-lcs (1.5.1)
@@ -74,10 +48,6 @@ GEM
7448
faraday (~> 2.0)
7549
ffi (1.17.2-arm64-darwin)
7650
ffi (1.17.2-x86_64-linux-gnu)
77-
fiber-annotation (0.2.0)
78-
fiber-local (1.1.0)
79-
fiber-storage
80-
fiber-storage (1.0.1)
8151
formatador (1.1.0)
8252
guard (2.18.1)
8353
formatador (>= 0.2.4)
@@ -96,9 +66,6 @@ GEM
9666
hashdiff (1.0.1)
9767
i18n (1.14.5)
9868
concurrent-ruby (~> 1.0)
99-
io-endpoint (0.15.2)
100-
io-event (1.10.0)
101-
io-stream (0.6.1)
10269
jaro_winkler (1.6.0)
10370
json (2.7.1)
10471
kramdown (2.4.0)
@@ -111,7 +78,6 @@ GEM
11178
rb-inotify (~> 0.9, >= 0.9.10)
11279
lumberjack (1.2.10)
11380
method_source (1.1.0)
114-
metrics (0.12.2)
11581
minitest (5.24.0)
11682
multipart-post (2.4.1)
11783
mutex_m (0.2.0)
@@ -136,13 +102,6 @@ GEM
136102
ast (~> 2.4.1)
137103
racc
138104
prism (0.30.0)
139-
protocol-hpack (1.5.1)
140-
protocol-http (0.49.0)
141-
protocol-http1 (0.34.0)
142-
protocol-http (~> 0.22)
143-
protocol-http2 (0.22.1)
144-
protocol-hpack (~> 1.4)
145-
protocol-http (~> 0.47)
146105
pry (0.14.2)
147106
coderay (~> 1.1)
148107
method_source (~> 1.0)
@@ -236,7 +195,6 @@ GEM
236195
yard-sorbet
237196
thor (1.3.1)
238197
tilt (2.3.0)
239-
traces (0.15.2)
240198
tzinfo (2.0.6)
241199
concurrent-ruby (~> 1.0)
242200
unicode-display_width (2.5.0)

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,50 @@ question.ask("Any question")
452452
# => RuntimeError: Please define a yes and/or no block
453453
```
454454

455+
## Model Context Protocol (Experimental)
456+
457+
The `Raix::MCP` module provides integration with the Model Context Protocol, allowing you to connect your Raix-powered application to remote MCP servers. This feature is currently **experimental**.
458+
459+
### Usage
460+
461+
Include the `Raix::MCP` module in your class and declare MCP servers using the `mcp` DSL:
462+
463+
```ruby
464+
class McpConsumer
465+
include Raix::ChatCompletion
466+
include Raix::FunctionDispatch
467+
include Raix::MCP
468+
469+
mcp "https://your-mcp-server.example.com/sse"
470+
end
471+
```
472+
473+
### Features
474+
475+
- Automatically fetches available tools from the remote MCP server using `tools/list`
476+
- Registers remote tools as OpenAI-compatible function schemas
477+
- Defines proxy methods that forward requests to the remote server via `tools/call`
478+
- Seamlessly integrates with the existing `FunctionDispatch` workflow
479+
- Handles transcript recording to maintain consistent conversation history
480+
481+
### Filtering Tools
482+
483+
You can filter which remote tools to include:
484+
485+
```ruby
486+
class FilteredMcpConsumer
487+
include Raix::ChatCompletion
488+
include Raix::FunctionDispatch
489+
include Raix::MCP
490+
491+
# Only include specific tools
492+
mcp "https://server.example.com/sse", only: [:tool_one, :tool_two]
493+
494+
# Or exclude specific tools
495+
mcp "https://server.example.com/sse", except: [:tool_to_exclude]
496+
end
497+
```
498+
455499
## Response Format (Experimental)
456500

457501
The `ResponseFormat` class provides a way to declare a JSON schema for the response format of an AI chat completion. It's particularly useful when you need structured responses from AI models, ensuring the output conforms to your application's requirements.

0 commit comments

Comments
 (0)