active_scaffold_mcp 0.1.0 → 0.1.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/README.md +31 -3
- data/lib/active_scaffold/mcp/list_tool.rb +6 -0
- data/lib/active_scaffold/mcp/show_tool.rb +7 -1
- data/lib/active_scaffold/mcp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c59d457c311f62fe1e9ca64acb45db411b81ef9324cee89f2d144561d8468d66
|
|
4
|
+
data.tar.gz: 560aa4999ae0a8e00fefd2877b5ad0f96cd446c946faa0b3a767e6391b17bec6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4326c49641a1c348eea8b952bddee0ebc3fbf1a6c269908a19d9d488ae91ced936c29bb1f95f5c7e17888b67824c9b8bf181de9b90c5bd65dc28716c47a28f03
|
|
7
|
+
data.tar.gz: dd3232549b00915f8687c90d4402a078dc43a0d9425536f2839a145a30ed27827c5622ae448836d7d4a8b34bf246e9d8d0dc1201de0931ffd3b7c0e718ef4922
|
data/README.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
The gem is under initial development. The first implementation will provide a configuration DSL, a generated-tool registry, and read-only list and show tools.
|
|
6
6
|
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Ruby 3.4 or newer
|
|
10
|
+
- Rails 8.1 or newer
|
|
11
|
+
- Active Scaffold 4.4 or newer
|
|
12
|
+
- ActionMCP 0.200 or newer
|
|
13
|
+
|
|
14
|
+
Add the gem to your application:
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
gem "active_scaffold_mcp", "~> 0.1.1"
|
|
18
|
+
```
|
|
19
|
+
|
|
7
20
|
Association columns use ActiveScaffold's list settings in MCP results. An
|
|
8
21
|
unlimited collection (`associated_limit = nil`) is returned as an array. A
|
|
9
22
|
positive limit returns `{records: [...], count: N}` when the complete
|
|
@@ -154,6 +167,22 @@ can override hooks such as `list_authorized?`, `beginning_of_chain`,
|
|
|
154
167
|
`conditions_for_collection`, and named-filter security methods. Keep HTTP-only
|
|
155
168
|
methods out of shared modules.
|
|
156
169
|
|
|
170
|
+
List and show tools delegate their default JSON response to the protected
|
|
171
|
+
`render_result` hook after records have been loaded and validated. Override it
|
|
172
|
+
in an action's configured `modules` when the tool needs to emit different MCP
|
|
173
|
+
content while preserving the generated action's lookup, filtering,
|
|
174
|
+
authorization, and error handling:
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
module AttachmentMCPResult
|
|
178
|
+
def render_result
|
|
179
|
+
render(image: encoded_attachment(@record), mime_type: @record.file.type)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
config.mcp.expose :show, modules: AttachmentMCPResult
|
|
184
|
+
```
|
|
185
|
+
|
|
157
186
|
Record serialization is handled by `ActiveScaffold::MCP::Presenter`, separately
|
|
158
187
|
from the ActiveScaffold action modules included by the generated tool. A custom
|
|
159
188
|
presenter class may replace it for an action:
|
|
@@ -284,8 +313,7 @@ the original task runs. The class may be namespaced and must respond to `find`;
|
|
|
284
313
|
the gem does not assume a particular user class or persistence library:
|
|
285
314
|
|
|
286
315
|
```sh
|
|
287
|
-
|
|
288
|
-
bin/rails 'action_mcp:show_profile[primary]'
|
|
316
|
+
MCP_USER='User#123' bin/rails 'action_mcp:show_profile[primary]'
|
|
289
317
|
```
|
|
290
318
|
|
|
291
319
|
For a namespaced class, use a value such as
|
|
@@ -296,7 +324,7 @@ The full accepted arguments are in each tool's `inputSchema`. ActionMCP can
|
|
|
296
324
|
print all registered schemas as JSON:
|
|
297
325
|
|
|
298
326
|
```sh
|
|
299
|
-
|
|
327
|
+
bin/rails action_mcp:apps:schema |
|
|
300
328
|
jq '.tools[] | select(.name == "list_support_tickets")'
|
|
301
329
|
```
|
|
302
330
|
|
|
@@ -29,6 +29,12 @@ module ActiveScaffold
|
|
|
29
29
|
do_list
|
|
30
30
|
return if report_disallowed_filters
|
|
31
31
|
|
|
32
|
+
render_result
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
protected
|
|
36
|
+
|
|
37
|
+
def render_result
|
|
32
38
|
columns = mcp_output_columns
|
|
33
39
|
render(text: JSON.generate(
|
|
34
40
|
records: @records.map { |record| mcp_record_hash(record, columns) },
|
|
@@ -16,11 +16,17 @@ module ActiveScaffold
|
|
|
16
16
|
return unless resolve_lookup_id
|
|
17
17
|
|
|
18
18
|
do_show
|
|
19
|
-
|
|
19
|
+
render_result
|
|
20
20
|
rescue ActiveRecord::RecordNotFound
|
|
21
21
|
report_error("No record found for id #{params[:id].inspect}")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def render_result
|
|
27
|
+
render(text: JSON.generate(record: mcp_record_hash(@record, mcp_output_columns)))
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
private
|
|
25
31
|
|
|
26
32
|
def tool_authorized?
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_scaffold_mcp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergio Cambra
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '4.
|
|
32
|
+
version: '4.4'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '4.
|
|
39
|
+
version: '4.4'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rails
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|