active_scaffold_mcp 0.1.1 → 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 +18 -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 +1 -1
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
|
@@ -167,6 +167,22 @@ can override hooks such as `list_authorized?`, `beginning_of_chain`,
|
|
|
167
167
|
`conditions_for_collection`, and named-filter security methods. Keep HTTP-only
|
|
168
168
|
methods out of shared modules.
|
|
169
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
|
+
|
|
170
186
|
Record serialization is handled by `ActiveScaffold::MCP::Presenter`, separately
|
|
171
187
|
from the ActiveScaffold action modules included by the generated tool. A custom
|
|
172
188
|
presenter class may replace it for an action:
|
|
@@ -297,8 +313,7 @@ the original task runs. The class may be namespaced and must respond to `find`;
|
|
|
297
313
|
the gem does not assume a particular user class or persistence library:
|
|
298
314
|
|
|
299
315
|
```sh
|
|
300
|
-
|
|
301
|
-
bin/rails 'action_mcp:show_profile[primary]'
|
|
316
|
+
MCP_USER='User#123' bin/rails 'action_mcp:show_profile[primary]'
|
|
302
317
|
```
|
|
303
318
|
|
|
304
319
|
For a namespaced class, use a value such as
|
|
@@ -309,7 +324,7 @@ The full accepted arguments are in each tool's `inputSchema`. ActionMCP can
|
|
|
309
324
|
print all registered schemas as JSON:
|
|
310
325
|
|
|
311
326
|
```sh
|
|
312
|
-
|
|
327
|
+
bin/rails action_mcp:apps:schema |
|
|
313
328
|
jq '.tools[] | select(.name == "list_support_tickets")'
|
|
314
329
|
```
|
|
315
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?
|