llm.rb 15.0.1 → 15.0.2
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/CHANGELOG.md +18 -0
- data/README.md +7 -0
- data/lib/llm/mcp.rb +31 -6
- data/lib/llm/version.rb +1 -1
- data/llm.gemspec +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c86e9ccde2cc0844b5172935bc222c1adf3cda8b0f49e84730179bcc635b2d2b
|
|
4
|
+
data.tar.gz: 60c740c3dc2c20d8b1d86de55ae5ef25eb7bbe5b5b567f3766c059b37520efcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd1901c5bebd659b242db55ed91ea4f538832c24b4ab119b80f46ae987fc5166823fa70174d9f545c079addd90487eb379b1dfd6eeea2365d045a831b861134e
|
|
7
|
+
data.tar.gz: 5949efbaa7381fb0cab7328e64c08af4022a8b976a24b8b24901c167c67cd060f912a7054956a7942cd7cf67b3f0aa226ad5aec608bcd273bfa1aa25d3ffb5d0
|
data/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,24 @@
|
|
|
15
15
|
|
|
16
16
|
## What's next
|
|
17
17
|
|
|
18
|
+
## v15.0.2
|
|
19
|
+
|
|
20
|
+
Changes since `v15.0.1`.
|
|
21
|
+
|
|
22
|
+
This release fixes a concurrency race in MCP tool calls by
|
|
23
|
+
reference-counting the transport session, so overlapping tool calls
|
|
24
|
+
reuse the running transport instead of racing `start`/`stop`.
|
|
25
|
+
|
|
26
|
+
### Fix
|
|
27
|
+
|
|
28
|
+
* **mcp: fix concurrent MCP tool call race** <br>
|
|
29
|
+
`LLM::MCP` now reference-counts its transport session: the first
|
|
30
|
+
caller starts the transport and the last caller stops it. Concurrent
|
|
31
|
+
or overlapping tool calls reuse the running transport instead of
|
|
32
|
+
racing `start`/`stop`, avoiding "MCP transport is not running" errors
|
|
33
|
+
that could occur with the `async` strategy. An externally started
|
|
34
|
+
transport is never stopped by a borrower.
|
|
35
|
+
|
|
18
36
|
## v15.0.1
|
|
19
37
|
|
|
20
38
|
Changes since `v15.0.0`.
|
data/README.md
CHANGED
|
@@ -25,6 +25,13 @@ Once you learn the fundamentals, everything else falls into place
|
|
|
25
25
|
naturally. Some features, such as ActiveRecord support, require
|
|
26
26
|
optional dependencies that are opt-in.
|
|
27
27
|
|
|
28
|
+
The best way to learn about llm.rb is to ask [the official chatbot](https://r.uby.dev)
|
|
29
|
+
a question. It is connected to the llm.rb GitHub repository, backed by
|
|
30
|
+
ActiveRecord and uses the builtin MCP feature to connect to GitHub. If
|
|
31
|
+
you want to know more then simply [ask the chatbot](https://r.uby.dev) and
|
|
32
|
+
you should get an answer that is grounded in the source code. It is 100%
|
|
33
|
+
free to use and powered by DeepSeek under the hood.
|
|
34
|
+
|
|
28
35
|
## Install
|
|
29
36
|
|
|
30
37
|
```bash
|
data/lib/llm/mcp.rb
CHANGED
|
@@ -87,7 +87,10 @@ class LLM::MCP
|
|
|
87
87
|
# @return [LLM::MCP] A new MCP instance
|
|
88
88
|
def initialize(stdio: nil, http: nil, timeout: 30)
|
|
89
89
|
@timeout = timeout
|
|
90
|
-
|
|
90
|
+
@lock = Mutex.new
|
|
91
|
+
@borrowers = 0
|
|
92
|
+
@owned = false
|
|
93
|
+
if stdio and http
|
|
91
94
|
raise ArgumentError, "stdio and http are mutually exclusive"
|
|
92
95
|
elsif stdio
|
|
93
96
|
@command = Command.new(**stdio)
|
|
@@ -125,7 +128,10 @@ class LLM::MCP
|
|
|
125
128
|
# Propagates errors raised by {#start}, the block itself, or {#stop}
|
|
126
129
|
# @return [void]
|
|
127
130
|
def run
|
|
128
|
-
|
|
131
|
+
@lock.synchronize do
|
|
132
|
+
start
|
|
133
|
+
@owned = false
|
|
134
|
+
end
|
|
129
135
|
yield
|
|
130
136
|
ensure
|
|
131
137
|
stop
|
|
@@ -182,13 +188,32 @@ class LLM::MCP
|
|
|
182
188
|
|
|
183
189
|
attr_reader :command, :transport, :timeout
|
|
184
190
|
|
|
191
|
+
##
|
|
192
|
+
# Borrows the transport for the duration of the block.
|
|
193
|
+
#
|
|
194
|
+
# The first borrower starts the transport, concurrent borrowers reuse
|
|
195
|
+
# it, and the last borrower stops it, so overlapping tool calls never
|
|
196
|
+
# race `start`/`stop` and trip over "MCP transport is not running".
|
|
197
|
+
# An externally started transport is never stopped by a borrower.
|
|
198
|
+
# @yield Runs while the transport is running
|
|
199
|
+
# @return [void]
|
|
185
200
|
def with_session
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
@lock.synchronize do
|
|
202
|
+
@borrowers += 1
|
|
203
|
+
unless transport.running?
|
|
204
|
+
start
|
|
205
|
+
@owned = true
|
|
206
|
+
end
|
|
207
|
+
end
|
|
189
208
|
yield
|
|
190
209
|
ensure
|
|
191
|
-
|
|
210
|
+
@lock.synchronize do
|
|
211
|
+
@borrowers -= 1
|
|
212
|
+
if @borrowers.zero? and @owned
|
|
213
|
+
@owned = false
|
|
214
|
+
stop
|
|
215
|
+
end
|
|
216
|
+
end
|
|
192
217
|
end
|
|
193
218
|
|
|
194
219
|
def adapt_content(content)
|
data/lib/llm/version.rb
CHANGED
data/llm.gemspec
CHANGED
|
@@ -40,13 +40,13 @@ DESCRIPTION
|
|
|
40
40
|
spec.post_install_message = "\n" \
|
|
41
41
|
"Got a question about llm.rb? " \
|
|
42
42
|
"\n" \
|
|
43
|
-
"Ask
|
|
43
|
+
"Ask the https://r.uby.dev chatbot." \
|
|
44
44
|
"\n" \
|
|
45
45
|
"It is connected to the official GitHub repository." \
|
|
46
46
|
"\n" \
|
|
47
47
|
"100% free to use." \
|
|
48
48
|
"\n" \
|
|
49
|
-
"
|
|
49
|
+
"Built with llm.rb and DeepSeek." \
|
|
50
50
|
"\n\n"
|
|
51
51
|
|
|
52
52
|
spec.add_development_dependency "webmock", "~> 3.24.0"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: llm.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 15.0.
|
|
4
|
+
version: 15.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Gleeson
|
|
@@ -652,8 +652,9 @@ metadata:
|
|
|
652
652
|
source_code_uri: https://github.com/r-uby-dev/llm
|
|
653
653
|
documentation_uri: https://r.uby.dev
|
|
654
654
|
changelog_uri: https://github.com/r-uby-dev/llm/blob/main/CHANGELOG.md
|
|
655
|
-
post_install_message: "\nGot a question about llm.rb? \nAsk
|
|
656
|
-
to the official GitHub repository.\n100% free to use.\
|
|
655
|
+
post_install_message: "\nGot a question about llm.rb? \nAsk the https://r.uby.dev
|
|
656
|
+
chatbot.\nIt is connected to the official GitHub repository.\n100% free to use.\nBuilt
|
|
657
|
+
with llm.rb and DeepSeek.\n\n"
|
|
657
658
|
rdoc_options: []
|
|
658
659
|
require_paths:
|
|
659
660
|
- lib
|