rails_mcp_engine 0.4.2 → 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 +4 -4
- data/README.md +23 -8
- data/app/controllers/rails_mcp_engine/chat_controller.rb +10 -5
- data/app/lib/tool_schema/ruby_llm_factory.rb +2 -1
- data/lib/rails_mcp_engine/version.rb +3 -1
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fbb05874281e54c77a8c73b712a7961f0f4fa70c052602334eaee0a90512ecb
|
|
4
|
+
data.tar.gz: ea63d1877987cfabe4ed411ba71e101f188f373566a65ced6e484234a17a8892
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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 =
|
|
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.
|
|
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
|
|
@@ -24,7 +24,8 @@ module ToolSchema
|
|
|
24
24
|
tool_name = T.let(schema[:name], String)
|
|
25
25
|
klass = Class.new(RubyLLM::Tool) do
|
|
26
26
|
description(schema[:description])
|
|
27
|
-
|
|
27
|
+
public_send(RubyLLM::Tool.respond_to?(:params) ? :params : :parameters,
|
|
28
|
+
&RubyLlmBuilder.params_block(schema[:params]))
|
|
28
29
|
|
|
29
30
|
# Override RubyLLM::Tool#name to use the tool_name from ToolMeta
|
|
30
31
|
# instead of the auto-generated name from the Ruby class name.
|
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
|
+
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
|