ruby_llm-mcp 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 328e09780647e7ef9a35aac8a8fd8e0b1c84aded38239b4ad9b08803e1d638d3
4
- data.tar.gz: f0f1022e6917f56b95ecfd4540fb517245f6b5450f9369d4cee2cc34e2eb0934
3
+ metadata.gz: 871fadee0f0166df56c6e8ef4ce2a6598c7875af9ca05631687cab1966ccb4e9
4
+ data.tar.gz: 6cbefa984fd7b541005be0f3f05c3970ab511c90afec9d135212dca33127d992
5
5
  SHA512:
6
- metadata.gz: d52fcbfb4fe1c1ebae1fece801a0f9b20a9aa467f7a3333c65e0db4fcc1ee0038df571ad4d7cdae2d8863d4d4ddd29c019a3ff245de5970142dcdccf7228ae45
7
- data.tar.gz: 471a551100918f7a86c6fe22b0065f340ec7ed87a4b1d709f49ce8c782b564532e840b6f160d5c082ef5f08734d1bd3ad59fb514f119150ec37f42e626678cc4
6
+ metadata.gz: 43b1fcb2d2fd8d6d1ebf7b8a43266443e72be5551ae9866a565bd38f7a90b98832294aadadb562d58a82dae24ff72251fe9eda91aab06a75df061413885c0560
7
+ data.tar.gz: 9a72ae094803de509b3ec447a43899a001ebd857d7f1085cb31f36a923d189324f7766ed37249866f0fc38e82fb962c11b00737f6821a7e6d723c6a30aa537aa
data/README.md CHANGED
@@ -399,6 +399,23 @@ end
399
399
 
400
400
  You can also avoid this completely manually start and stop the clients if you so choose.
401
401
 
402
+ If you want to use the clients outside of the block, you can use the `clients` method to get the clients.
403
+
404
+ ```ruby
405
+ clients = RubyLLM::MCP.establish_connection
406
+ chat = RubyLLM.chat(model: "gpt-4")
407
+ chat.with_tools(*clients.tools)
408
+
409
+ response = chat.ask("Hello, world!")
410
+ puts response
411
+ ```
412
+
413
+ However, you will be responsible for closing the connection when you are done with it.
414
+
415
+ ```ruby
416
+ RubyLLM::MCP.close_connection
417
+ ```
418
+
402
419
  ## Client Lifecycle Management
403
420
 
404
421
  You can manage the MCP client connection lifecycle:
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ module RubyLlm
6
+ module Mcp
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ source_root File.expand_path("templates", __dir__)
10
+
11
+ desc "Install RubyLLM MCP configuration files"
12
+
13
+ def create_initializer
14
+ template "initializer.rb", "config/initializers/ruby_llm_mcp.rb"
15
+ end
16
+
17
+ def create_config_file
18
+ template "mcps.yml", "config/mcps.yml"
19
+ end
20
+
21
+ def display_readme
22
+ readme "README.txt" if behavior == :invoke
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ RubyLLM MCP has been successfully installed!
2
+
3
+ The following files have been created:
4
+
5
+ config/initializers/ruby_llm_mcp.rb - Main configuration file
6
+ config/mcps.json - MCP servers configuration
7
+
8
+ Next steps:
9
+
10
+ 1. Edit config/initializers/ruby_llm_mcp.rb to configure your MCP settings
11
+ 2. Edit config/mcps.json to define your MCP servers
12
+ 3. Install any MCP servers you want to use (e.g., npm install @modelcontextprotocol/server-filesystem) or use remote MCPs
13
+ 4. Update environment variables for any MCP servers that require authentication
14
+
15
+ Example usage in your Rails application:
16
+
17
+ # With Ruby::MCP installed in a controller or service
18
+ clients = RubyLLM::MCP.clients
19
+
20
+ # Get all tools use the configured client
21
+ tools = RubyLLM::MCP.tools
22
+
23
+ # Or use the configured client
24
+ client = RubyLLM::MCP.clients["file-system"]
25
+
26
+ # Or use the configured client
27
+ tools = client.tools
28
+
29
+
30
+ For more information, visit: https://github.com/patvice/ruby_llm-mcp
31
+
32
+ ===============================================================================
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure RubyLLM MCP
4
+ RubyLLM::MCP.configure do |config|
5
+ # Request timeout in milliseconds
6
+ config.request_timeout = 8000
7
+
8
+ # Maximum connections in the pool
9
+ config.max_connections = Float::INFINITY
10
+
11
+ # Pool timeout in seconds
12
+ config.pool_timeout = 5
13
+
14
+ # Enable complex parameter support for various providers
15
+ config.support_complex_parameters!
16
+
17
+ # Path to MCPs configuration file
18
+ config.config_path = Rails.root.join("config", "mcps.yml")
19
+
20
+ # Launch MCPs (:automatic, :manual)
21
+ config.launch_control = :automatic
22
+
23
+ # Configure roots for file system access
24
+ # config.roots = [
25
+ # Rails.root.to_s
26
+ # ]
27
+
28
+ # Configure sampling (optional)
29
+ config.sampling.enabled = false
30
+
31
+ # Set preferred model for sampling
32
+ # config.sampling.preferred_model do
33
+ # # Return the preferred model name
34
+ # "claude-3-5-sonnet-20240620"
35
+ # end
36
+
37
+ # Set a guard for sampling
38
+ # config.sampling.guard do
39
+ # # Return true to enable sampling, false to disable
40
+ # Rails.env.development?
41
+ # end
42
+ end
@@ -0,0 +1,9 @@
1
+ mcp_servers:
2
+ filesystem:
3
+ transport_type: stdio
4
+ command: npx
5
+ args:
6
+ - "@modelcontextprotocol/server-filesystem"
7
+ - "<%%= Rails.root %>"
8
+ env: {}
9
+ with_prefix: true
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLLM
4
4
  module MCP
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
data/lib/ruby_llm/mcp.rb CHANGED
@@ -33,8 +33,18 @@ module RubyLLM
33
33
 
34
34
  def establish_connection(&)
35
35
  clients.each(&:start)
36
- yield clients
37
- ensure
36
+ if block_given?
37
+ begin
38
+ yield clients
39
+ ensure
40
+ close_connection
41
+ end
42
+ else
43
+ clients
44
+ end
45
+ end
46
+
47
+ def close_connection
38
48
  clients.each do |client|
39
49
  client.stop if client.alive?
40
50
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :release do
4
+ desc "Release a new version of the gem"
5
+ task :version do
6
+ # Load the current version from version.rb
7
+ require_relative "../../lib/ruby_llm/schema/version"
8
+ version = RubyLlm::Schema::VERSION
9
+
10
+ puts "Releasing version #{version}..."
11
+
12
+ # Make sure we are on the main branch
13
+ system "git checkout main"
14
+ system "git pull origin main"
15
+
16
+ # Create a new tag for the version
17
+ system "git tag -a v#{version} -m 'Release version #{version}'"
18
+ system "git push origin v#{version}"
19
+
20
+ system "gem build ruby_llm-mcp.gemspec"
21
+ system "gem push ruby_llm-mcp-#{version}.gem"
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_llm-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Vice
@@ -65,6 +65,10 @@ extra_rdoc_files: []
65
65
  files:
66
66
  - LICENSE
67
67
  - README.md
68
+ - lib/generators/ruby_llm/mcp/install_generator.rb
69
+ - lib/generators/ruby_llm/mcp/templates/README.txt
70
+ - lib/generators/ruby_llm/mcp/templates/initializer.rb
71
+ - lib/generators/ruby_llm/mcp/templates/mcps.yml
68
72
  - lib/ruby_llm/chat.rb
69
73
  - lib/ruby_llm/mcp.rb
70
74
  - lib/ruby_llm/mcp/attachment.rb
@@ -121,6 +125,7 @@ files:
121
125
  - lib/ruby_llm/mcp/transports/streamable_http.rb
122
126
  - lib/ruby_llm/mcp/transports/timeout.rb
123
127
  - lib/ruby_llm/mcp/version.rb
128
+ - lib/tasks/release.rake
124
129
  homepage: https://github.com/patvice/ruby_llm-mcp
125
130
  licenses:
126
131
  - MIT