Skip to content

Commit a4288e8

Browse files
committed
improved eliciation docs
1 parent dd5617c commit a4288e8

File tree

1 file changed

+12
-119
lines changed

1 file changed

+12
-119
lines changed

docs/client/elicitation.md

Lines changed: 12 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ This is useful for servers that need user input or clarification during complex
3333
{: .new }
3434
Elicitation is a new feature in MCP Protocol 2025-06-18.
3535

36+
**Note:** Elicitation is only available for clients that support the `2025-06-18` protocol version.
37+
38+
Additional, in this current version the original request still needs to complete in the bounds of the initial request timeout. In some cases (like if you were to get real user input) that may take longer than what a normal request would take. A solution to this will come out in future versions.
39+
3640
## Basic Elicitation Configuration
3741

3842
### Global Configuration
@@ -250,74 +254,6 @@ elicitation.structured_response = {
250254

251255
---
252256

253-
## Advanced Patterns
254-
255-
### Interactive User Input
256-
257-
```ruby
258-
client.on_elicitation do |elicitation|
259-
puts "\n#{elicitation.message}"
260-
261-
schema = elicitation.requested_schema
262-
response = {}
263-
264-
# Collect input based on schema properties
265-
schema["properties"].each do |key, property|
266-
print "#{key.capitalize}: "
267-
value = gets.chomp
268-
269-
# Convert based on type
270-
case property["type"]
271-
when "number"
272-
response[key] = value.to_f
273-
when "boolean"
274-
response[key] = ["true", "yes", "y"].include?(value.downcase)
275-
else
276-
response[key] = value
277-
end
278-
end
279-
280-
elicitation.structured_response = response
281-
true
282-
end
283-
```
284-
285-
### Conditional Logic
286-
287-
```ruby
288-
client.on_elicitation do |elicitation|
289-
case elicitation.message
290-
when /approval required/i
291-
# Handle approval requests
292-
elicitation.structured_response = { "approved": confirm_approval() }
293-
true
294-
when /preference/i
295-
# Handle preference requests
296-
elicitation.structured_response = { "choice": get_user_preference() }
297-
true
298-
else
299-
# Reject unknown requests
300-
false
301-
end
302-
end
303-
```
304-
305-
### Async Processing
306-
307-
```ruby
308-
client.on_elicitation do |elicitation|
309-
# For complex processing, you might want to handle this asynchronously
310-
Thread.new do
311-
response = complex_processing(elicitation.message, elicitation.requested_schema)
312-
elicitation.structured_response = response
313-
end
314-
315-
true # Accept the elicitation
316-
end
317-
```
318-
319-
---
320-
321257
## Error Handling
322258

323259
### Schema Validation Errors
@@ -358,57 +294,6 @@ end
358294

359295
---
360296

361-
## Testing Elicitation
362-
363-
### Mock Elicitation Requests
364-
365-
```ruby
366-
# In your tests
367-
RSpec.describe "Elicitation handling" do
368-
it "handles user preferences" do
369-
client = create_test_client
370-
371-
# Mock elicitation response
372-
client.on_elicitation do |elicitation|
373-
expect(elicitation.message).to include("preference")
374-
elicitation.structured_response = { "choice": "test_option" }
375-
true
376-
end
377-
378-
# Trigger elicitation through server interaction
379-
result = client.tool("preference_tool").execute
380-
expect(result).to be_successful
381-
end
382-
end
383-
```
384-
385-
### Integration Tests
386-
387-
```ruby
388-
# Test with real server that sends elicitation requests
389-
def test_elicitation_workflow
390-
client = RubyLLM::MCP.client(
391-
name: "test-server",
392-
transport_type: :stdio,
393-
config: { command: "test-mcp-server" }
394-
)
395-
396-
responses = []
397-
client.on_elicitation do |elicitation|
398-
responses << elicitation.message
399-
elicitation.structured_response = { "test": "response" }
400-
true
401-
end
402-
403-
# Execute operation that triggers elicitation
404-
client.tool("interactive_tool").execute
405-
406-
expect(responses).not_to be_empty
407-
end
408-
```
409-
410-
---
411-
412297
## Best Practices
413298

414299
### Security Considerations
@@ -438,3 +323,11 @@ end
438323
- **Implement async processing** for complex input collection
439324
- **Set reasonable timeouts** for user interactions
440325
- **Monitor elicitation frequency** to detect issues
326+
327+
## Next Steps
328+
329+
Once you understand client interactions, explore:
330+
331+
- **[Server Interactions]({% link server/index.md %})** - Working with server capabilities
332+
- **[Configuration]({% link configuration.md %})** - Advanced client configuration options
333+
- **[Rails Integration]({% link guides/rails-integration.md %})** - Using MCP with Rails applications

0 commit comments

Comments
 (0)