spree_core, so an extension or a host application adds to it without depending on the MCP gem. Anything registered is offered to the admin MCP server and to any other adapter reading the same registry.
The catalog is a registry in spree_core, so an extension or a host application adds to it without depending on the MCP gem. Two kinds of thing to add.
A back-office operation you already have as a workflow. Name its Spree::Dependencies key and the permission that should gate it:
server/config/initializers/spree.rb
suppliers.sync becomes suppliers_sync), its description from the class’s leading comment, and its parameters from perform’s signature and the YARD @param lines above it — so the tool and the workflow cannot drift apart. Two rules the derivation relies on: every parameter needs an @param with a type, and a parameter naming a record must be typed as a model the agent can already read.
Something that is not a workflow — a lookup against another system, a report of your own. Subclass Spree::AgentTool and register the class by name:
app/tools/my_shop/agent_tools/supplier_stock.rb
server/config/initializers/spree.rb
- Registration is by name, not by class, so your edits to a description or a parameter take effect on the next request rather than needing a restart.
contextis who is asking:context.storeis always the caller’s store, andcontext.principalis the admin or the API key — pass it to anything that records who acted.- A refusal is
{ error: '…' }, not an exception. The model reads that text and corrects itself, so write it as an instruction rather than a stack trace. - Keep the result small. It lands in the model’s context. Return a
summaryline plus the few fields that answer the question, and let the caller ask for more.
permission, so a key that cannot read purchasing never learns supplier_stock exists.
Which registry
There is one registry per surface, named the way the authentication strategies are::admin, so registering one in the wrong place raises rather than being discovered when a storefront visitor is offered the back office:
See also
Tool reference
The tools that ship, and the shape yours should follow.
Workflows
What
expose_workflows is exposing.
