ruby_llm-mcp 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -637
- data/lib/ruby_llm/mcp/client.rb +56 -2
- data/lib/ruby_llm/mcp/completion.rb +3 -2
- data/lib/ruby_llm/mcp/configuration.rb +30 -1
- data/lib/ruby_llm/mcp/coordinator.rb +30 -6
- data/lib/ruby_llm/mcp/elicitation.rb +46 -0
- data/lib/ruby_llm/mcp/errors.rb +2 -0
- data/lib/ruby_llm/mcp/prompt.rb +4 -3
- data/lib/ruby_llm/mcp/protocol.rb +34 -0
- data/lib/ruby_llm/mcp/requests/completion_prompt.rb +13 -3
- data/lib/ruby_llm/mcp/requests/completion_resource.rb +13 -3
- data/lib/ruby_llm/mcp/resource.rb +1 -2
- data/lib/ruby_llm/mcp/resource_template.rb +4 -3
- data/lib/ruby_llm/mcp/response_handler.rb +10 -1
- data/lib/ruby_llm/mcp/responses/elicitation.rb +33 -0
- data/lib/ruby_llm/mcp/result.rb +2 -1
- data/lib/ruby_llm/mcp/tool.rb +33 -5
- data/lib/ruby_llm/mcp/transports/sse.rb +69 -25
- data/lib/ruby_llm/mcp/transports/stdio.rb +2 -2
- data/lib/ruby_llm/mcp/transports/streamable_http.rb +87 -19
- data/lib/ruby_llm/mcp/transports/support/http_client.rb +28 -0
- data/lib/ruby_llm/mcp/transports/support/rate_limit.rb +47 -0
- data/lib/ruby_llm/mcp/transports/support/timeout.rb +34 -0
- data/lib/ruby_llm/mcp/version.rb +1 -1
- data/lib/ruby_llm/mcp.rb +11 -9
- metadata +40 -11
- data/lib/ruby_llm/mcp/transports/http_client.rb +0 -26
- data/lib/ruby_llm/mcp/transports/timeout.rb +0 -32
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubyLLM
|
4
|
-
module MCP
|
5
|
-
module Transports
|
6
|
-
module Timeout
|
7
|
-
def with_timeout(seconds, request_id: nil)
|
8
|
-
result = nil
|
9
|
-
exception = nil
|
10
|
-
|
11
|
-
worker = Thread.new do
|
12
|
-
result = yield
|
13
|
-
rescue StandardError => e
|
14
|
-
exception = e
|
15
|
-
end
|
16
|
-
|
17
|
-
if worker.join(seconds)
|
18
|
-
raise exception if exception
|
19
|
-
|
20
|
-
result
|
21
|
-
else
|
22
|
-
worker.kill # stop the thread (can still have some risk if shared resources)
|
23
|
-
raise RubyLLM::MCP::Errors::TimeoutError.new(
|
24
|
-
message: "Request timed out after #{seconds} seconds",
|
25
|
-
request_id: request_id
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|