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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14d936da45136d5c9bf0a9febed42a083ec51c33f1254330ca57a40e920e0531
4
- data.tar.gz: 1c806cc168401908ac0d14ea1f563504651c518307b3196d724e1120934422d3
3
+ metadata.gz: c59d457c311f62fe1e9ca64acb45db411b81ef9324cee89f2d144561d8468d66
4
+ data.tar.gz: 560aa4999ae0a8e00fefd2877b5ad0f96cd446c946faa0b3a767e6391b17bec6
5
5
  SHA512:
6
- metadata.gz: 8656fae010d09c02fded86e285cf4ca85c0313db2c3028b82545adfade8184f154db51da033d1fb11ef23f688343c30e5c8505b9459c498b14a020465d435994
7
- data.tar.gz: 46032d4681a0116c28acb2537a66e2d3cb8f5fa95f0a76c2bcf70a6997e761630125780c55aeb0a03c48cad12b41093fdeef3ff2df06ffaee98f3de4d236a9a9
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
- READONLY=1 RAILS_ENV=production MCP_USER='User#123' \
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
- READONLY=1 RAILS_ENV=production bin/rails action_mcp:apps:schema |
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
- render(text: JSON.generate(record: mcp_record_hash(@record, mcp_output_columns)))
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?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveScaffold
4
4
  module MCP
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra