An MCP server also serves
prompt() and resource() objects, and an agent or MCP server can
have a connection trigger (agentTrigger, mcpServerTrigger) that decides what each connection
sees.
A tool
tests, as an endpoint does. See
Tests.
An agent, called from an endpoint
Agents have no public endpoint of their own. You run one from any stack:- The answer is at
.result.ref("answer")is the whole run envelope (finishReason,stepsand more). llmpicks the provider:xano-ai,anthropic,openaiorgoogle-genai, each with its own typed fields.xano-aineeds no API key: Xano bills it as Xano AI.xano-freeis deprecated. Xano runs axano-freeagent asxano-ai, with the default model and the workspace’s Xano AI location, on Xano’s cloud and on the Xano Engine alike. Amodelorlocationstored under it is ignored. Existingxano-freecode still compiles and deploys unchanged; writexano-aifor a new agent.- Tools run by default.
allowToolExecutiondefaults to true. Setting it toc.bool(false)does not hide the tools: the model still asks for one, the call never runs, and the run ends with an emptyresult(export()warnsstack.agent-tools-off). - Structured output. Give the agent
output: { schema: { ... } }withinput.*fields and.resultis typed from it at every call site. - Prompts are templates. String settings resolve
{{ $args.NAME }}and{{ $env.NAME }}at run time. - Fall back when the provider fails. Wrap the run in
s.try_catch. In the catch arm,caught("result")is{ name: "AI_APICallError", statusCode, isRetryable, data }, so branch onwithFilters(caught("result"), fl.get("statusCode"))(a401means the key was refused).caught("message")holds the provider’s error text.
Control each connection: agent triggers
AnagentTrigger runs when a client connects to the agent it is bound to. t.toolset is the
agent (t.toolset("name") reads one field) and t.tools is its list of tools, each
{ id, name, instructions }. What the trigger returns is the toolset and tools that connection
gets, so the trigger can gate the connection, or log and annotate it on the way through:
- The stack is a callback. A trigger has no
input; its inputs arrive ont, typed to the trigger, so a wrong name is a compile error. - Bind with the handle. Pass the
agent()def, not an id. A trigger bound to nothing deploys and never fires. - Omit
responseand the connection gets every tool unchanged.
Xano AI models
Xano AI runs models for you with no provider key. You reach it two ways: an agent withllm: { type: "xano-ai" }, or one of eight statements under s.ai that you call from any stack:
Every result also carries the
model that ran.
modelis optional. Leave it out and the statement runs its suggested model. It takes any string, so a model released after your SDK version still compiles; the editor autocompletes the models that were current when the SDK was built.- List the current models with
npx @xano/sdk ai models. It reads the live catalog, needs no sign-in, and shows each statement’s models, the suggested one, where each can run, its options and its price.--jsonis for agents;--alladds retired models. Seeai models. - Values the engine would reject fail at build time.
location,aspect_ratio,image_size,resolution,response_formatandsave_to_filesare checked when you export, and a statement refuses alocationits model cannot run at. save_to_filesstores the result as a file. On video, music and speech it needs a paid plan; on images it does not.- On an agent,
modelmust be a literal name: the engine picks the model before it renders templates, soexport()refuses a{{ … }}or an expression. A model the catalog does not list for agents (agent.modelsinai models --json) runs the default model with no error.
Where Xano AI runs
location is "", us, global or eu. A statement’s or agent’s own location wins. Left
blank, it inherits the workspace’s location; blank there too, the model runs at its default. An
explicit "global" opts one call out of a workspace set to "eu". Set the workspace default in
code:
"". A
deploy that leaves out the xano-ai block keeps the location set in the dashboard, and an empty
block or location: "" clears it. A block without model clears a model set in the dashboard;
the live diff shows that before you deploy. A merge with deploy --to writes no workspace
settings.
Xano AI on the Xano Engine
Eachdeploy --local, and each engine start or restart, hands the engine a Xano AI credential from
your npx @xano/sdk login sign-in. It lasts as long as the engine runs, a day at most, and the
next deploy renews it. Usage is billed to you. To bill the instance owner instead (you must be the
owner or a billing member), pass --ai-billing instance or set "aiBilling": "instance" under
"xanosdk"."@xano/sdk" in package.json; the flag wins.
The deploy prints one Xano AI: line saying it is on and who pays, or why it is off and how to
fix it. It never fails the deploy, and --json carries an ai object. If it reports a sign-in
without Xano AI access, run npx @xano/sdk login again: a sign-in from before 1.0.20 cannot
spend AI credits. A pasted meta API token cannot either.
The Xano Engine uses the credential only from an engine release that reads it. Until that release
ships, the deploy hands the credential over and the engine ignores it. An engine started by an
earlier SDK needs
npx @xano/sdk local stop <name>, then a deploy.An MCP server
An MCP server exposes tools, prompts and resources to any MCP client, such as Claude, ChatGPT or another agent. Prompts and resources are their own kinds: define them, then list them on the server.A prompt
A prompt is a reusable message a client can ask for. Itsinput is the prompt’s arguments; an
enum’s values also answer the client’s completion requests:
{ role: "user" | "assistant", content }.
Resources
A resource is data a client reads byuri. A literal uri is a static resource. A uri with a
{variable} is a template: each variable is one input field, and a client reads a concrete
URI such as blog://posts/42.
The server, with sign-in
List the tools, prompts and resources on the server. Addoauth to make every MCP request carry
a signed-in user from your auth table:
- Entries.
tools,promptsandresourceseach take handles, or a{ tool | prompt | resource, enabled?, auth? }wrapper.authnames the auth table and is what gives that entry’s stack a caller forauth(). A bare handle is public. blogMcp.getUrl(HOST)returns the Streamable HTTP URL a client connects to. A frontend gets the same address frommcpUrl("blog_mcp", XANO_HOST)inxano/routes.gen.ts(see Typed frontend).- Gate every entry that needs one. The endpoint is open to browsers too: it answers every
Origin, preflight included, withaccess-control-allow-origin: *. Per-entryauthand the server’soauthare the only gates. - Names. An
mcpServerand anagentwith the same name collide, because both are stored as toolsets.
Hosted sign-in
Withmode: "hosted", Xano is the authorization server. A client that connects is sent to your
loginUrl with an mcp_request parameter. That page is also the consent screen: it shows who is
asking, signs the user in, then calls an endpoint that completes the sign-in and redirects the
browser to the URL it returns. Two endpoints back the page:
MCP_LOGIN_URL in workspaceConfig({ env: { MCP_LOGIN_URL: "" } }) and set its value
per environment in xano/.env (see Env and secrets).
s.mcp.oauth.revoke ends a user’s sign-ins on a server.
Your own identity provider
To accept tokens from Auth0, Clerk, WorkOS, Entra, Okta or Cognito instead, usemode: "external". The token’s claim (default sub) is matched against a column in your auth
table, here an auth0_id text column on users that holds each user’s provider id:
Control each connection: MCP server triggers
AnmcpServerTrigger runs when an MCP client connects to the server it is bound to, and its
response decides what that one connection lists. t carries the server’s toolset, tools,
prompts and resources. Return a list filtered to narrow it; a key you leave out lists
everything the server has. This one hides the resources from every connection:
t.authis the signed-in user when the server hasoauth:{ dbo, id, extras }of the auth-table row, read ast.auth("id"). It is null on a server without sign-in, so check it before reading a field.- An entry you return can change its description. A returned prompt or resource’s
descriptionreplaces the listed one for that connection. - Omit
responseand the connection lists all four unchanged.
Knowledge
Aknowledge() item is markdown shared by every AI that builds your backend. Xano’s own AI
reads it before it acts: the workspace’s builder agent, and outside agents that read the
workspace through the Meta API or MCP. Your coding agent reads the same .md files in the repo,
and the AGENTS.md that init writes tells it to. A deploy and a pull keep the two copies in
sync. It does not reach an agent() you run with s.ai.agent.run. Put what that agent must
know in its llm.systemPrompt.
mode: "always" sends the whole body on every request, and a type: "agents.md" item is
always sent in full. Write the description of an auto item to match the requests it should
answer.
Register them
Next
- Every
llmfield, MCP prompts and resources, elicitation and background runs: object kinds reference. - Run work on a schedule or on Xano platform events: Tasks and platform events.
- Call code the typed surface cannot express, from a tool or anywhere else: Custom code.