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 RubyLLM::MCP client provides support functionality that can be exposed to MCP servers. These features must be explicitly configured before creating client objects to ensure you're opting into this functionality.
469
+
470
+
### Roots
471
+
472
+
Roots provide MCP servers with access to underlying file system information. The implementation starts with a lightweight approach due to the MCP specification's current limitations on root usage.
473
+
474
+
When roots are configured, the client will:
475
+
476
+
- Expose roots as a supported capability to MCP servers
477
+
- Support dynamic addition and removal of roots during the client lifecycle
478
+
- Fire `notifications/roots/list_changed` events when roots are modified
Sampling allows MCP servers to offload LLM requests to the MCP client rather than making them directly from the server. This enables MCP servers to optionally use LLM connections through the client.
511
+
512
+
#### Configuration
513
+
514
+
```ruby
515
+
RubyLLM::MCP.configure do |config|
516
+
config.sampling.enabled =true
517
+
config.sampling.preferred_model ="gpt-4.1"
518
+
519
+
# Optional: Use a block for dynamic model selection
520
+
config.sampling.preferred_model do |model_preferences|
521
+
model_preferences.hints.first
522
+
end
523
+
524
+
# Optional: Add guards to filter sampling requests
525
+
config.sampling.guard do |sample|
526
+
sample.message.include("Hello")
527
+
end
528
+
end
529
+
```
530
+
531
+
#### How It Works
532
+
533
+
With the above configuration:
534
+
535
+
- Clients will respond to all incoming sample requests using the specified model (`gpt-4.1`)
536
+
- Sample messages will only be approved if they contain the word "Hello" (when using the guard)
537
+
- The `preferred_model` can be a string or a proc that provides dynamic model selection based on MCP server characteristics
538
+
539
+
The `preferred_model` proc receives model preferences from the MCP server, allowing you to make intelligent model selection decisions based on the server's requirements for success.
0 commit comments