rails_mcp_engine 0.4.1 → 0.5.0

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: 3448e618eae50c7f5357c7948986b5208a308f685d5bb88e311790e4a3467825
4
- data.tar.gz: 0ca92186f069f550157bf15dfb8df68e954cd14db58688af06af981cacf65d1b
3
+ metadata.gz: 4fbb05874281e54c77a8c73b712a7961f0f4fa70c052602334eaee0a90512ecb
4
+ data.tar.gz: ea63d1877987cfabe4ed411ba71e101f188f373566a65ced6e484234a17a8892
5
5
  SHA512:
6
- metadata.gz: ffe2fddbaf4dce4ae4e93f38ae5200de091558849f779ff93a4d2f4237a81789717b8945f73f9def02ba0972971cac76516cbdd21ddc3201456acedd825e8751
7
- data.tar.gz: 92b5d6c89ec0ed02fc3b1bfbda1dff9b643d2abcdf81900802937d3755a3d3f2c9ae0c5b44d2c9bf980d21c1246976ca1e01e36fd5952449ff8ff540d4085f83
6
+ metadata.gz: afd050e10d5ff10fe4aa6b4beb57ef19169be804714d61ccb361fa1e6c793726a260c7da6886dc0726bb9f5c5296159d56cbad8cefbb68f41768b0411b9a2529
7
+ data.tar.gz: 815636ce20fab4d2d94fc7f65afa2b5fb4c4675fd0bc6758617bbb1b54696cd62f6707549862508a5bd32cf59971b9d9fe099f5b6789fe321857ef4b6a0ef1c8
data/README.md CHANGED
@@ -6,7 +6,7 @@ Rails MCP Engine provides a unified tool-definition pipeline for Rails 8 applica
6
6
 
7
7
  This engine is built on top of these powerful libraries:
8
8
 
9
- - **[RubyLLM](https://github.com/crmne/ruby_llm)**: For generating LLM-compatible tool definitions.
9
+ - **[RubyLLM](https://github.com/crmne/ruby_llm)**: For generating LLM-compatible tool definitions. Supports versions `>= 1.9, < 3` (1.x and 2.x).
10
10
  - **[FastMCP](https://github.com/yjacquin/fast-mcp)**: For creating Model Context Protocol (MCP) servers.
11
11
  - **[Sorbet](https://github.com/sorbet/sorbet)**: For static type checking and signature definitions.
12
12
 
@@ -61,7 +61,7 @@ end
61
61
  ```
62
62
 
63
63
  On boot, the engine generates:
64
- - `Tools::BookMeeting < RubyLLM::Tool` with a matching `params` block.
64
+ - `Tools::BookMeeting < RubyLLM::Tool` with a matching `params` block on RubyLLM 1.x or `parameters` block on 2.x.
65
65
  - `Mcp::BookMeetingTool < ApplicationTool` with a matching `arguments` block.
66
66
 
67
67
  ## Default meta tool
@@ -108,11 +108,8 @@ You can easily fetch the generated RubyLLM tool classes for use in your host app
108
108
  tool_classes = Tools::MetaToolService.ruby_llm_tools(['book_meeting', 'calculator'])
109
109
 
110
110
  # Use them with RubyLLM
111
- response = RubyLLM.chat(
112
- messages: messages,
113
- tools: tool_classes,
114
- model: 'gpt-4o'
115
- )
111
+ chat = RubyLLM.chat(model: 'gpt-4o').with_tools(*tool_classes)
112
+ response = chat.ask('Book a meeting with the team.')
116
113
  ```
117
114
 
118
115
 
@@ -120,7 +117,25 @@ response = RubyLLM.chat(
120
117
 
121
118
  After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rails test` to run the tests.
122
119
 
123
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
120
+ ### Gem release
121
+
122
+ `ruby script/release.rb` adapts [Collavre's release script](https://github.com/sh1nj1/plan42/blob/main/script/release.rb) for this single gem repository.
123
+
124
+ Run it from a clean `main` checkout with Ruby 3.2+, Bundler, Git push access, and RubyGems credentials (`gem signin`, including MFA when prompted). It pulls `main` with fast-forward only, shows commits since the last version change, and prompts for a higher `MAJOR.MINOR.PATCH` version (default: next patch).
125
+
126
+ To use a known release commit instead of the last version-file change:
127
+
128
+ ```sh
129
+ ruby script/release.rb --last-release-commit <SHA>
130
+ ```
131
+
132
+ The full or abbreviated commit SHA must exist locally and be an ancestor of the updated `HEAD`. Changes after that commit (excluding the commit itself) are shown and used in release notes. Invalid, ambiguous, or unrelated commits stop the script before version input or file changes. Omit the option to keep the existing last-version-change behavior. Use `--help` to see available options.
133
+
134
+ The script creates a release branch, updates the version, `RELEASE_NOTES.md`, and lockfile, runs Rails unit and system tests, commits those files, builds into `build/gems`, and publishes to RubyGems. It then fast-forwards `main`, pushes it, and pushes only the new `vVERSION` tag. System tests require Chrome/Chromium, as in CI.
135
+
136
+ Dependency or test failures restore the original files and return to `main`, keeping the release branch for diagnosis. Failures after the commit leave the commit and build available. If upload fails, retry the printed `gem push` command; after a successful upload, finish the Git steps manually if necessary. RubyGems publication cannot be undone by Git rollback; do not rerun the whole script after a successful upload.
137
+
138
+ To install this gem onto your local machine, run `bundle exec rake install`. Use `ruby script/release.rb` for releases as described above.
124
139
 
125
140
  ### Playground & Chat
126
141
 
@@ -42,14 +42,11 @@ module RailsMcpEngine
42
42
  end
43
43
 
44
44
  # Create RubyLLM chat instance with configuration
45
- chat = RubyLLM.chat(
46
- provider: provider,
47
- model: model
48
- )
45
+ chat = build_chat(model, provider)
49
46
 
50
47
  # Register all available tools
51
48
  tool_classes = get_tool_classes
52
- chat = tool_classes.reduce(chat) { |c, tool_class| c.with_tool(tool_class) }
49
+ chat = tool_classes.reduce(chat) { |c, tool_class| c.with_tools(tool_class) }
53
50
 
54
51
  # Prepare the message with conversation history context
55
52
  if conversation_history.empty?
@@ -94,6 +91,14 @@ module RailsMcpEngine
94
91
 
95
92
  private
96
93
 
94
+ def build_chat(model, provider)
95
+ options = { model: model, provider: provider }
96
+ if provider == :openai && defined?(RubyLLM::Protocols::ChatCompletions)
97
+ options[:protocol] = :chat_completions
98
+ end
99
+ RubyLLM.chat(**options)
100
+ end
101
+
97
102
  def schemas
98
103
  ToolMeta.registry.map { |service_class| ToolSchema::Builder.build(service_class) }
99
104
  end
@@ -21,9 +21,15 @@ module ToolSchema
21
21
  parent = Tools
22
22
  parent.send(:remove_const, tool_constant) if parent.const_defined?(tool_constant, false)
23
23
 
24
+ tool_name = T.let(schema[:name], String)
24
25
  klass = Class.new(RubyLLM::Tool) do
25
26
  description(schema[:description])
26
- params(&RubyLlmBuilder.params_block(schema[:params]))
27
+ public_send(RubyLLM::Tool.respond_to?(:params) ? :params : :parameters,
28
+ &RubyLlmBuilder.params_block(schema[:params]))
29
+
30
+ # Override RubyLLM::Tool#name to use the tool_name from ToolMeta
31
+ # instead of the auto-generated name from the Ruby class name.
32
+ define_method(:name) { tool_name }
27
33
 
28
34
  define_method(:execute) do |**kwargs|
29
35
  before_call&.call(kwargs)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsMcpEngine
2
- VERSION = '0.4.1'
4
+ VERSION = "0.5.0"
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_mcp_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soonoh Jung
@@ -47,16 +47,22 @@ dependencies:
47
47
  name: ruby_llm
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - "~>"
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.9'
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: '3'
53
56
  type: :runtime
54
57
  prerelease: false
55
58
  version_requirements: !ruby/object:Gem::Requirement
56
59
  requirements:
57
- - - "~>"
60
+ - - ">="
58
61
  - !ruby/object:Gem::Version
59
62
  version: '1.9'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '3'
60
66
  - !ruby/object:Gem::Dependency
61
67
  name: sorbet-runtime
62
68
  requirement: !ruby/object:Gem::Requirement