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
+121-2Lines changed: 121 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,13 +103,39 @@ response = chat.ask("Can you help me search for recent files in my project?")
103
103
puts response
104
104
```
105
105
106
+
### Human in the Loop
107
+
108
+
You can use the `on_human_in_the_loop` callback to allow the human to intervene in the tool call. This is useful for tools that require human input or programic input to verify if the tool should be executed.
109
+
110
+
For tool calls that have access to do important operations, there SHOULD always be a human in the loop with the ability to deny tool invocations.
111
+
112
+
```ruby
113
+
client.on_human_in_the_loop do |name, params|
114
+
name =="add"&& params[:a] ==1&& params[:b] ==2
115
+
end
116
+
117
+
tool = client.tool("add")
118
+
result = tool.execute(a:1, b:2)
119
+
puts result # 3
120
+
121
+
# If the human in the loop returns false, the tool call will be cancelled
122
+
result = tool.execute(a:2, b:2)
123
+
puts result # Tool execution error: Tool call was cancelled by the client
124
+
```
125
+
126
+
tool = client.tool("add")
127
+
result = tool.execute(a: 1, b: 2)
128
+
puts result
129
+
130
+
````
131
+
106
132
### Support Complex Parameters
107
133
108
134
If you want to support complex parameters, like an array of objects it currently requires a patch to RubyLLM itself. This is planned to be temporary until the RubyLLM is updated.
109
135
110
136
```ruby
111
137
RubyLLM::MCP.support_complex_parameters!
112
-
```
138
+
````
113
139
114
140
### Streaming Responses with Tool Calls
115
141
@@ -341,6 +367,14 @@ client.restart!
341
367
client.stop
342
368
```
343
369
370
+
### Ping
371
+
372
+
You can ping the MCP server to check if it is alive:
373
+
374
+
```ruby
375
+
client.ping # => true or false
376
+
```
377
+
344
378
## Refreshing Cached Data
345
379
346
380
The client caches tools, resources, prompts, and resource templates list calls are cached to reduce round trips back to the MCP server. You can refresh this cache:
MCPs can produce notifications that happen in an async nature outside normal calls to the MCP server.
403
+
404
+
### Subscribing to a Resource Update
405
+
406
+
By default, the client will look for any resource cha to resource updates and refresh the resource content when it changes.
407
+
408
+
### Logging Notifications
409
+
410
+
MCPs can produce logging notifications for long-running tool operations. Logging notifications allow tools to send real-time updates about their execution status.
# Execute a tool that supports logging notifications
434
+
tool = client.tool("long_running_operation")
435
+
result = tool.execute(operation:"data_processing")
436
+
437
+
# Logging: warning - Something went wrong but not major...
438
+
```
439
+
440
+
### Progress Notifications
441
+
442
+
MCPs can produce progress notifications for long-running tool operations. Progress notifications allow tools to send real-time updates about their execution status.
443
+
444
+
**Note:** that we only support progress notifications for tool calls today.
0 commit comments