Agents and the API

How AI agents use the app through MCP and WebMCP tools scoped to who's signed in, how to manage those tools, and where to find the API reference.

Updated · 3 min read

Agents can use your app through tools instead of scraping pages. A remote agent, such as a coding agent or a desktop assistant, connects to the MCP endpoint at /api/mcp. A visitor's browser agent gets the same tools through WebMCP on every page. Both run the same code on the server, and each caller sees only the tools for who they are.

The tools

WhoTools
Anyone, signed outlist_site_pages, get_pricing, get_affiliate_terms
Any signed-in userget_my_account, get_my_subscription, get_my_affiliate_summary
Adminsget_admin_overview, get_experiments_dashboard, get_experiment_results, list_affiliate_applications, decide_affiliate_application, set_experiment_status, and three tools that read your internal handbook

Audiences nest: a signed-in user also gets the public tools, and an admin gets all of them. Viewers get the admin tools that read, never the ones that write.

Tools that read are on by default. Tools that write, today decide_affiliate_application and set_experiment_status, stay off until an admin switches them on at Admin → Agents. Only admins can call them, and each call that writes is recorded in the audit log.

Connect an agent

Admin → Agents has a Connect an agent panel with the MCP endpoint to copy. By default it's https://<your domain>/api/mcp. To give agents their own address, add an mcp. host to the web service, set MCP_HOST on web and MCP_URL=https://mcp.<domain> on server; agents then connect to https://mcp.<domain>. See Deploy to Railway.

The endpoint is a stateless Streamable HTTP MCP server. It supports the initialize handshake most clients use (protocol revisions 2025-03-26, 2025-06-18 and 2025-11-25) and the 2026-07-28 revision without it. MCP clients authenticate with the same session cookie as the browser; there is no separate token system. Without a cookie, a client gets the public tools.

A request with an Origin header other than your app's own is refused, which also guards the endpoint against DNS rebinding. Clients that send no Origin, as most MCP clients do, pass.

WebMCP in the browser

In a browser that supports WebMCP, every page registers the caller's tools, plus two that run in the page: navigate (same-site paths only) and get_current_page. The set refreshes every minute and on focus, so signing in or out changes the tools at once. Tools that write are marked as consequential. In other browsers nothing is fetched or registered.

Manage the tools

At Admin → Agents an admin can:

  • switch each tool on or off; a disabled tool is never listed and answers as if it didn't exist;
  • reword a tool's description for agents, up to 1,000 characters, or clear it to restore the original;
  • see each tool's calls and errors over 30 days, with daily sparklines, and read the recent call log;
  • run a tool as themselves, with a form built from its inputs.

Calls are limited to 60 a minute per signed-in user and 120 per address. The log keeps the tool, user, audience, source, result, duration and error code for 30 days. Inputs are never stored. Errors come back with a code and message, never server internals.

The API reference

The app's API is described by an OpenAPI document. Read it two ways:

  • Interactive reference at /docs/api, where you can browse every route and its request and response shapes.
  • The raw document at /openapi.json, for generating clients or loading into other tools.

Every route checks access on the server. Signed-out requests to protected routes get 401; a signed-in user without the right role or membership gets 403. Admin routes need an admin session, and admin changes need the passkey step-up described in The admin panel.

Agent tools also have REST routes: GET /api/agent/tools lists the caller's tools, and POST /api/agent/tools/{name} with { "input": ... } calls one. For read-only affiliate reports from a script, set AFFILIATES_READ_TOKEN and send it as a bearer token; see The affiliate program.

Adding your own tools

Tools are defined in code, in one registry, each with a name, a description, who may call it, an input schema and whether it reads or writes. A new tool shows up in MCP, WebMCP and Admin → Agents at once. Tools that write start switched off. Have each tool call the same server code your routes use, so the same access checks apply.

Something unclear or missing? Ask us and we'll answer, then fix the page.