AI agents (MCP)
An Elyra app can be an MCP server: an AI agent in Claude, Cursor or VS Code calls the commands you choose, as tools. They are the same commands the frontend calls, through the same middleware and validation. Nothing is exposed until you say so. The design is RFC 0003.
In five lines
App::new()
.commands(resources::commands())
.mcp(Mcp::new()
.allow_abilities(["customers.view", "customers.create"])
.allow_ability("customers.delete")
.confirm("customers.delete"))
rata mcp inspect # what the agent will see
rata mcp install # the config that connects Claude to this app
The client launches myapp --mcp. If the app is open, the agent works in it:
the windows update as it adds a customer. If it isn't, the app runs headless,
without a window.
What's a tool
A command is a tool when the ability its #[command(can = "…")] declares is
granted with Mcp::allow_ability / allow_abilities. An exact name or a
namespace (customers.*) works. A command without an ability is never a tool.
This grant is separate from the frontend's App::allow_abilities.
Each tool is a projection of its command:
| MCP | From |
|---|---|
name |
the command's name (customers_store) |
description |
its /// doc comment |
inputSchema |
a JSON Schema of its arguments, built from the specta types, after serde's renames, tagging and flattening |
outputSchema |
the same, for its result |
annotations.readOnlyHint |
true for a #[command(live)] |
annotations.destructiveHint |
true when its ability is in Mcp::confirm |
Arguments arrive by name: { "input": { "name": "Ada" } } for
customers_store(ctx, input: CustomerInput). An Option argument, or an
Option field, may be left out.
When a call fails, the model gets an error it can act on (isError), not a
protocol error. That covers a validation bag (with the messages per field), a
command's Err, a panic, an unknown argument, and a type that doesn't decode.
Write the doc comments for the model: what the command does, and when to use it. Only the first line is shown when the user is asked to confirm.
Confirmation
Mcp::confirm("customers.delete") makes the server ask the user before such a
call runs. The question appears in the MCP client: who is asking, which tool,
the first line of its description, and the arguments.
- A 2026-07-28 client gets a multi round-trip:
input_requiredwith anelicitation/create, then a retry carrying the user's answer. - A legacy client that declared elicitation gets a server-initiated
elicitation/create. - A client that can't ask gets an error, and the tool doesn't run. So does a decline, a dismissal, or no answer within 10 minutes.
The server enforces this; it isn't a hint the client may ignore. The round
trip's requestState is signed, bound to the tool, the arguments and the
client, and expires after 5 minutes. It also runs the call only once.
Resources
A granted #[command(live)] that can run with no arguments given is also a
resource, app://<command>. That means every argument is an Option, or
a struct whose fields all are. resources/read runs it.
A client can subscribe (subscriptions/listen, or resources/subscribe
before 2026-07-28). It's then told whenever the live registry would push a new
result to a window: coalesced, only when the result changed, and only for
what the command read. See live queries. The agent watches
"today's orders" the way a window does.
Resource templates
A granted live command that takes arguments is a resource template (RFC 0004). It's a URI with variables, which the agent fills in:
app://customers_show/{id}
app://customers_index{?direction,page,per_page,search,sort}
- Which commands: each argument must be a scalar (a string, number,
boolean or unit-variant enum, optionally an
Option), or a struct of scalars, one level deep. A command that needs confirmation has no template. Neither does one with a list, a nested object orserde_json::Valueargument.rata mcp inspectsays why. - Variables: required ones are path segments, in argument order. Optional ones are the query, with a struct's fields in name order.
- Values: they're percent-decoded (
+is a plus) and converted by the variable's type.app://customers_show/12reads customer 12;app://customers_index?search=ada&page=2reads that page of that search. - Subscribing:
subscriptions/listentoapp://customers_index?search=adais told only when that search's result changes. - Errors: a value that doesn't convert, a parameter the template doesn't
name, or a repeated one is
-32602"Invalid arguments", with what's wrong per variable indata.errors. So is the command's own validation failing. - Completion:
completion/completeoffers an enum variable's values, andtrue/falsefor a boolean. For others, the app can give a source:Mcp::complete("customers_show", "id", Completion::new("customers_index", "id"))(see completions).
Templates add no reach. The agent can already call the command as a tool with any arguments; a template lets it watch the result.
Prompts
A prompt is a task the app offers by name: the client lists it
(prompts/list), and the user picks one to start from (prompts/get). The
same Prompt can be the assistant's suggestion
too.
use elyra::Prompt;
let summary = Prompt::new("customer_summary", "Summarize a customer",
"Summarize {customer}: open invoices, last contact, notes.")
.description("A customer at a glance")
.argument("customer", "The customer's name or number")
.needs("customers.view");
App::new().mcp(Mcp::new().allow_ability("customers.*").prompt(&summary))
- Listed where it's granted. A prompt is listed only when the grant
covers every ability it
needs; one with none is always listed. - Arguments are
{name}in its text:argument(..)is required,optional_argument(..)is empty when left out. Each value is text, at most 2000 characters. A required one missing is-32602"Invalid arguments". - Checked at start. A
{name}that isn't an argument, an argument that isn't in the text, or two prompts with one name stop the server from starting. - Completion: an argument is free text, with no values to offer,
unless it has a source:
.complete("customer", Completion::new("customers_index", "name")).
A prompt adds no reach: it's words for the agent, which still calls the tools its grant allows.
Completions
A client asks completion/complete for a template variable's or a prompt
argument's values as the user types them. With a source, the app answers
from its own data: customer names as the user types "gr".
use elyra::{Completion, Prompt};
let summary = Prompt::new("customer_summary", "Summarize a customer", "Summarize {customer}.")
.argument("customer", "The customer's name")
.complete("customer", Completion::new("customers_index", "name"));
App::new().mcp(Mcp::new()
.allow_ability("customers.view")
.prompt(&summary)
.complete("customers_show", "id", Completion::new("customers_index", "id")))
- A source is a live command, and each row's field is a value (the
rows of a page's
data, or the list it returns), each once, at most 100. What's typed goes in itsquery.search, 20 to a page, asmake:resource's_indextakes it;.search("term")(or"filter.name") puts it elsewhere. - It runs as the agent's calls do: through its grant, the inspector's mask and the rate limit, each completion counted. So it suggests only what the agent could read with the tool itself. A refused or failing source gives no values rather than an error.
- Checked at start. For a prompt the grant offers, and for each
template given one, the source must be a tool the grant offers, live
(it only reads), and not one
Mcp::confirmasks about; the template must be one the grant offers, with that variable. Otherwise the server doesn't start. - In the assistant, the same prompt's argument is suggested in the panel as the user types it (see suggestions).
Seeing what it does
-
Logs: every call and read is logged under
elyra::mcp, with its outcome and duration. The arguments aren't logged, since they may be personal data. -
An event, for an audit log:
App::new().listen(|e: elyra::mcp::AgentCalled, ctx: Ctx| async move { // e.tool, e.client, e.ok, e.millis Ok(()) }) -
A channel, for the UI:
elyra:mcpcarries astartedand afinishedfor every call:import { onAgent, toast } from "@elyra/runtime"; onAgent((a) => { if (a.phase === "started") toast(`${a.client} is running ${a.tool}…`); }); -
Who's calling, in middleware:
CommandRequest::originisOrigin::Agent { client }for an MCP call, andOrigin::Frontendotherwise. Refuse an agent there, or audit it (middleware).
Rate limits
Every tool takes at most 60 calls a minute by default, counted per tool across all connections. That's plenty for an agent at work, and a stop for one caught in a loop. Change it per ability, namespace, or for everything:
Mcp::new()
.allow_abilities(["customers.*"])
.rate_limit("*", 120, Duration::from_secs(60))
.rate_limit("customers.create", 10, Duration::from_secs(60))
The last limit that matches wins. A throttled call is an error the model sees, and it's refused before the user is asked to confirm it. Reads count; re-runs for a subscription don't.
Connecting a client
rata mcp install # Claude Code and Claude Desktop
rata mcp install --client cursor
rata mcp install --client vscode
rata mcp install --client workspace # Elyra Workspace: the project's .mcp.json
rata mcp install --release # the optimized build
rata mcp install builds the app and prints the config for that binary.
It edits nothing; you paste the config where the client reads it. The
exception is --client workspace: Elyra Workspace gives the servers in the
project's own .mcp.json to every agent (Claude Code, Codex, Gemini CLI, …)
once you allow the file, so rata adds the app there, next to the servers
already in it. The command is this machine's path to the binary. The
database URL goes in only for SQLite, since a server URL may hold a
password and .mcp.json is often committed.
This is the app's own commands as tools. For an agent working on the app's
code, rata ai:install and rata mcp dev give it the framework's guides,
the app's commands, models, schema and log, and the running debug build's
windows to look at and click in: see coding agents. For a
shipped app, point command at the installed binary instead
(/Applications/CRM.app/Contents/MacOS/crm), with "args": ["--mcp"].
When the app has no App::database(..), a headless run reads DATABASE_URL.
rata mcp install puts the one from elyra.toml in the config's env.
The running app, or headless
myapp --mcp is a small shim:
- When the app is open, the shim connects to it over a private local endpoint, and the agent works inside the app. It shares the app's database connection, live queries and events, so the windows update, and one agent sees another's changes.
- When it isn't, the shim serves MCP itself, without a window. Everything works, but nothing shows it, and two headless agents don't hear about each other's writes.
The endpoint exists only when the app calls .mcp(..). It's a 0600 Unix
socket, or loopback on Windows, and a connection is served only after a
challenge-response on a per-install token (see security).
Testing
TestApp::mcp() is an in-process client, so a test checks what an agent
sees:
let app = TestApp::new(App::new().commands(resources::commands()).mcp(mcp()));
let agent = app.mcp();
assert!(agent.list_tools().await.iter().any(|t| t["name"] == "customers_store"));
let added = agent.call("customers_store", json!({ "input": { "name": "Ada" } })).await;
assert!(!added.is_error, "{}", added.text);
// Confirmation, answered as the user would.
let gone = app.mcp().confirming("accept").call("customers_destroy", json!({ "id": 1 })).await;
assert!(gone.confirmation.unwrap().contains("customers_destroy"));
// Resources, templates and subscriptions.
let page = agent.read("app://customers_index").await.unwrap();
let ada = agent.read("app://customers_index?search=ada").await.unwrap();
let (_id, watching) = agent.listen(&["app://customers_show/12"]).await;
Protocol support
- 2026-07-28, the stateless revision. It covers per-request
_meta,server/discover,tools/listandprompts/listwithttlMsandcacheScope, multi round-trip confirmation, andsubscriptions/listen. - 2025-11-25, 2025-06-18 and 2025-03-26, for clients that open with
initialize. Elicitation came in 2025-06-18.
The transport is stdio only. There's no network listener.
CI drives the example app with the official
MCP Inspector CLI:
scripts/mcp-inspector.sh.
Related
- Commands · Middleware · Live queries · Security · Testing
- The app's assistant: the same commands for an assistant inside the app, held to the signed-in user's abilities.