Named MCP Servers
Additional MCP servers with their own path, tools and audience — MCP Apps, attendee servers, vanity hosts, login pages, transport.
Declare extra MCP servers, each with its own path, tool set and OAuth audience, alongside the default one. Start at The MCP Server for tools and authentication.
Named MCP servers
One /mcp exposing every operation is a lot of tools for a model to choose from, and the right set differs by audience — staff need the admin surface, attendees need a handful of "my" tools. agents.mcp.servers adds named servers next to /mcp, served by the same Worker, each with a curated tool list, its own exact OAuth resource URL and its own protected-resource metadata:
export default defineConfig({
// …
agents: {
mcp: {
requireAuth: true, // the default /mcp — unchanged
servers: {
guest: {
path: "/guest/mcp",
// Optional vanity URL, per named environment (a plain string when
// the project has no `environments`).
publicUrl: {
production: "https://mcp.attend.vip/guest",
dev: "https://mcp-dev.attend.vip/guest",
},
name: "Attend for attendees", // serverInfo.title
instructions: "Tools for event attendees: your agenda, RSVPs and events.",
tools: {
include: ["agenda_items__listMyAgenda", "agenda_items__selfRsvp", "user_profiles__listMyEvents"],
// groups: ["agenda_items"], // every tool in a group (the part before `__`)
// exclude: ["agenda_items__agendaItemsApprove"],
overrides: {
agenda_items__selfRsvp: { title: "RSVP to a session", description: "Accept or decline one agenda item." },
},
},
},
},
},
},
});| Option | Required | Description |
|---|---|---|
path | Yes | Where the server answers, e.g. /guest/mcp. Plain segments, no trailing slash, outside every system prefix (/api, /auth, /.well-known, /mcp, /storage, …) and every apps.*.path. |
tools.include | One of include / groups | Exact tool names, as the default /mcp server lists them (<group>__<operationId>). |
tools.groups | One of include / groups | Every tool whose name starts with <group>__. |
tools.exclude | No | Tool names removed after include and groups. |
tools.overrides | No | Per-tool title / description shown by this server only, and ui — the MCP App view the tool renders with. Keys must be selected tools. |
resources | No | MCP App views this server serves, keyed by ui:// URI. |
name | No | Server title (serverInfo.title). Defaults to <project> (<key> MCP); serverInfo.name is <project>-<key>. |
instructions | No | Returned from initialize as the server's instructions. |
requireAuth | No | Challenge anonymous callers with 401. Defaults to agents.mcp.requireAuth. Setting it on any server force-enables oauthProvider + bearer, without changing the default /mcp challenge. |
lane | No | 'staff' (default) or 'attendee'. An attendee server runs every request with no organization and no org roles, and confines OAuth tokens to its own audience. See Attendee servers. |
publicUrl | No | A vanity URL for the server — see below. |
events | No | Event names from the agents.mcp.events catalogue this server lists and accepts subscriptions for. Omitted: the server serves no events. An unknown name fails the compile. |
The selection is fixed at compile time. A tool name or group the generated API doesn't have fails the compile with a suggestion (unknown tool "events__selfRsvp". Did you mean "agenda_items__selfRsvp"?), and so does a selection that ends up empty or an override for an unselected tool.
What each server gets
- Curated
tools/listandtools/call. The list is the allowlist, with the access filter applied on top — scope-gated tools stay visible to any authenticated caller who could hold the scope.tools/callonly dispatches tools in the allowlist (Unknown toolotherwise) and re-enters the app exactly like/mcp: same middleware chain, same{}body for body-lessPOST/PUT/PATCHtools, no token forwarded to anything else. - An exact resource URL. The server's URL is
BETTER_AUTH_URL + path(e.g.https://api.attend.vip/guest/mcp). It is added automatically to theoauthProviderresources— so a connector can request a token withresource=<server URL>— and to the audiences the auth middleware accepts. - Its own RFC 9728 document at the path-insert URL
/.well-known/oauth-protected-resource<path>, withresourceexactly equal to the server URL. A401from the server carriesWWW-Authenticate: Bearer resource_metadata="<that document>". The root/.well-known/oauth-protected-resourcekeeps describing/mcp. The documents followagents.oauthDiscovery, like the root one. - Discovery.
/.well-known/mcp.jsongains aserversarray listing/mcpand every named server, and/llms.txtlists each one.
The default /mcp is unchanged — same tools, same challenge, same documents.
MCP Apps
A named server can serve MCP Apps. An MCP App is an interactive HTML view that the host (Claude, for example) renders in a sandboxed iframe when a tool runs. Declare each view under resources, keyed by its ui:// URI. Then point tools at it with tools.overrides.<tool>.ui:
export default defineConfig({
// …
agents: {
mcp: {
servers: {
items: {
path: "/items/mcp",
resources: {
"ui://items/board": {
file: "./mcp-ui/items-board.html", // quickback/mcp-ui/items-board.html
name: "Items board",
description: "Kanban view of your items.",
csp: { connectDomains: ["https://api.example.com"] },
prefersBorder: true,
},
},
tools: {
include: ["items__listItems", "items__moveItem"],
overrides: {
items__listItems: { ui: "ui://items/board" },
// Callable by the view, hidden from the model.
items__moveItem: { ui: { resource: "ui://items/board", visibility: ["app"] } },
},
},
},
},
},
},
});| Resource option | Required | Description |
|---|---|---|
file | Yes | An .html file under quickback/mcp-ui/, written ./mcp-ui/<name>.html. |
name | No | Name in resources/list. Defaults to the URI. |
description | No | Description in resources/list. |
csp | No | { connectDomains?, resourceDomains?, frameDomains?, baseUriDomains? }, each a list of origins the view may reach. If omitted, the host applies its most restrictive policy. |
permissions | No | Any of "camera", "microphone", "geolocation", "clipboardWrite". |
domain | No | A dedicated sandbox origin for the view (host-specific format). |
prefersBorder | No | Ask the host to draw a border around the view. |
csp, permissions, domain and prefersBorder are passed through verbatim as the resource's _meta.ui. A tool's ui is a URI, or { resource, visibility }. visibility lists who may call the tool: "model", "app", or both (the default).
The view must be one self-contained HTML file, with scripts and styles inlined (for example with vite-plugin-singlefile). The host loads it from resources/read, not from a URL, so relative asset paths do not resolve, and assets from other origins need their hosts in csp.resourceDomains. quickback build uploads every .html file under quickback/mcp-ui/. Only the files a server references are baked into the Worker.
A server with resources also gets:
resources/listandresources/read. Each view is served astext/html;profile=mcp-appwith its_meta.ui. An unknown URI returns-32002 Resource not found.resources/templates/listreturns an empty list.- Capabilities in
initialize. The response addsresourcesand theio.modelcontextprotocol/uiextension marker. _meta.uion the tools that use a view. It is set as{ resourceUri, visibility? }, next to the existingquickback.dev/*keys.structuredContenton those tools' results when the response body is a JSON object. The view reads its data fromstructuredContent. Other tools return text content only, as before.
The views sit behind the same requireAuth challenge as the server's tools. A view is static app code: every piece of data it shows still comes from a tools/call through the full security pipeline. Servers without resources, and the default /mcp, are unchanged: they still answer resources/* with Method not found.
These fail the compile:
- a URI that isn't
ui://… - a
fileoutsidequickback/mcp-ui/, or one that wasn't shipped - a view over 1 MiB, or more than 4 MiB of views in the whole project
- a tool
uinaming an undeclared resource - a resource that no tool references
On a staff server (the default), an access token minted for a named server is accepted anywhere this Worker accepts its own OAuth tokens, exactly like a /mcp token: the curated list decides what the model is offered, not what the token can reach. Every call still runs the full security pipeline. To confine a server's tokens, make it an attendee server.
Attendee servers
Set lane: 'attendee' on a server whose callers act only through a relationship to one record (an event's guests, a project's clients) and must never bring their organization role with them:
agents: {
mcp: {
servers: {
guest: {
path: '/guest/mcp',
lane: 'attendee',
tools: { include: ['agenda_items__listMyAgenda', 'agenda_items__selfRsvp'] },
},
},
},
},Two rules apply, enforced by a middleware that runs right after authentication, so after every credential lane and after the resolve-oauth-context hook. Nothing later can raise the lane again.
- No organization authority on the server. Every request on it runs with
activeOrgId,activeTeamId,roles,orgRoleandtierRolescleared anduserRole: 'user'. That covers the MCP request itself and every tool it dispatches. It applies however the caller authenticated (OAuth, session bearer, JWT or API key). The context also carriesctx.mcpLane = 'attendee'. Scoped roles (scope:<kind>:<role>) are resolved per request from the path, so they are the only authority an attendee server's tools see. A staff member who is also an event guest gets exactly a guest's access there. - OAuth tokens are confined by audience. A token minted for the attendee server's URL (its path URL or its
publicUrl) is refused with401 invalid_tokeneverywhere else:/api,/mcpand other named servers. A token minted for any other audience is refused on the attendee server. That401names the server's protected-resource metadata, so a client can re-authorize for the right resource. A token whoseaudlists both kinds keeps its staff authority on staff surfaces and is lowered on the attendee server.
Tool calls are tied to their server by the internal request object the MCP dispatcher builds, not by a header. A request from outside the Worker can't claim to be one. Instance-bound tokens (Instance-bound OAuth tokens) are already confined to their instance and are left as they are.
Projects without an attendee server compile byte-identically.
Public URLs on a vanity host
publicUrl serves the same server at a second URL on a host of your choosing, e.g. https://mcp.attend.vip/guest:
- Requests whose host and path match it reach the server's handler, and its RFC 9728 document is served on that host at
/.well-known/oauth-protected-resource<publicUrl path>withresourceequal to the public URL. Other paths on that host behave like any other host of the Worker. TheBETTER_AUTH_URL + pathURL keeps working alongside it. - The public URL is also added to the
oauthProviderresources and the accepted audiences, so a connector added with the public URL gets a token for exactly that URL. - Its hostname is bound as a custom domain on the same Worker automatically — no
providers.runtime.config.routesentry needed. A host the target already routes (its API host, say) adds no second route. See Multi-Domain Architecture. - The URL needs a path (
https://mcp.attend.vip/guest, or…/mcpon a dedicated host): the host root's/.well-known/oauth-protected-resourceis the default server's document.https://only, no port, query or fragment, and the host can't be a CMS, Account, admin, app, auth or webhook host — their hostname middleware would serve or block the MCP path. On a host the target already serves (its API orBETTER_AUTH_URLhost, aroutesentry), the path can't be/mcpor any named server'spatheither: the public URL is matched first and would shadow that server there.
With named environments, key publicUrl by environment name. Every environment runs the same bundle, so the compiler stamps QUICKBACK_ENVIRONMENT = "<name>" into each target's vars whenever a publicUrl is keyed by environment (or the apiKey plugin is on); the Worker reads it to know which public URL is its own. Only that URL is routed and accepted as an audience on that target — mcp-dev.attend.vip is never a resource of production. An environment without an entry serves the server at BETTER_AUTH_URL + path only. Keys must be plain environment names (a letter, then letters, digits, - or _), and never an Object.prototype member such as constructor. A host owned by another target, or a domains: 'none' target with an entry, fails the compile.
Login and consent pages
Every server — named or not — uses the auth-level pages (auth.config.oauth.loginPage / consentPage, else the Account SPA). Per-server pages are not supported: Better Auth's oauthProvider takes one loginPage and one consentPage and has no hook to pick one per request, so choosing by resource would need a redirect shim in front of it. Setting agents.mcp.servers.<key>.oauth is a compile error that says so. To brand the screens per server, have your login/consent page branch on the resource parameter: when the connector sends one (RFC 8707), it is part of the signed query string the page is opened with.
Connecting clients
Claude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"my-api": {
"url": "https://my-api.example.com/mcp",
"headers": {
"Authorization": "Bearer <jwt>"
}
}
}
}Cursor — use the same config shape under .cursor/mcp.json.
Quick sanity check with curl:
# List available tools
curl -X POST https://my-api.example.com/mcp \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# Call a tool
curl -X POST https://my-api.example.com/mcp \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"listCustomers","arguments":{"limit":10}}}'Transport
The server speaks the Streamable HTTP MCP transport — JSON-RPC 2.0 over POST. A plain GET /mcp returns the server info document for sanity checks.
Two protocol revisions are served on the same endpoint:
| Revision | How a client negotiates |
|---|---|
2026-07-28 | server/discover (no handshake), then io.modelcontextprotocol/protocolVersion in every request's _meta. Results carry resultType: "complete", the server identity in _meta, and ttlMs / cacheScope on catalogue results. |
2025-03-26 | initialize / notifications/initialized. Results keep their historical shape. |
A _meta version outside that list is refused with JSON-RPC error -32022 and data.supported. ChatGPT requires the 2026-07-28 revision for MCP Events.
The MCP route does not emit its own CORS headers. The Worker's existing cors() middleware applies uniformly, so browser-origin access is governed by the same allowlist as the rest of the API (auth.trustedOrigins + the deploy origin). Server-to-server clients (Claude Desktop, Cursor, MCP Inspector) connect with a Bearer token and don't need browser CORS at all. If you want a browser-based MCP client (ChatGPT, Claude.ai) to connect cross-origin, add its origin to auth.trustedOrigins like any other web client.