A Helix project can serve chosen defineTool tools over the Model Context Protocol (MCP) at POST /mcp on the app’s own URL, or at another path you choose. You turn the endpoint on with mcp.enabled in helix.config.ts and list the tool modules it serves under mcp.tools. An MCP client such as Claude Code, Cursor, or VS Code then connects with the URL and a bearer token, lists those tools, and calls them. Each call runs the tool’s handler with a full ctx and the caller’s identity, and is recorded as an execution like any request. Nothing is served unless you enable the endpoint and list the tool.
A deployed app serves the endpoint once it is deployed with SDK 1.30.0 or later. A deployment built with an earlier SDK answers the MCP path with the app itself until you redeploy.
Enable the endpoint
Set mcp.enabled and list each tool module you want served, by its path under functions/:
// helix.config.ts
import { defineConfig } from '@trayai/helix-sdk';
export default defineConfig({
name: 'customer-health',
workspaceId: 'f8e7d6c5-4b3a-2190-8765-abcdef012345',
mcp: {
enabled: true,
tools: [
'_tools/lookup-customer', // functions/_tools/lookup-customer.ts
'_tools/orders/search', // functions/_tools/orders/search.ts
],
},
});
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | boolean | false | Off, there is no MCP endpoint at all, locally or deployed |
path | string | '/mcp' | Where the endpoint is served. A fixed path such as /api/mcp: no trailing slash, no [param] segments, and not under /_helix/ or /.well-known/ |
tools | string[] | [] | The tool modules to serve, as paths under functions/ starting with _tools/. The .ts extension is optional, and .. is not allowed |
listTtlMs | non-negative integer | 300000 | How long, in milliseconds, clients are told they may cache the tool list |
Every entry has to name a module that exists. A missing one fails helix deploy before anything is uploaded, with INVALID_MCP_CONFIG and a message such as mcp.tools lists tool modules that do not exist: _tools/x → functions/_tools/x.ts. helix dev still starts, and prints ⚠ mcp.tools lists _tools/x, but there is no functions/_tools/x.ts instead.
A listed module is served when it default-exports a defineTool definition. Two kinds of entry are skipped with a warning rather than served: a module whose default export is not a tool, and a tool with needsApproval set (see choosing which tools are served). A tool defined inline inside an agent file has no path of its own and cannot be listed; move it to functions/_tools/ and import it from the agent.
What the endpoint serves
Each listed tool is an ordinary defineTool module:
// functions/_tools/lookup-customer.ts
import { z } from 'zod';
import { defineTool } from '@trayai/helix-sdk';
export default defineTool({
name: 'lookup_customer',
description: 'Look up a customer by email address. Returns the CRM contact, or found: false if there is no match.',
input: z.object({
email: z.string().email().describe('The customer login email, lowercase'),
}),
annotations: { readOnlyHint: true },
handler: async (ctx) => {
const res = await ctx.http
.authed('hubspot')
.get(`https://api.hubapi.com/crm/v3/objects/contacts/${encodeURIComponent(ctx.input.email)}`, {
query: { idProperty: 'email' },
});
if (res.status === 404) return { found: false };
const contact = res.body as { id: string; properties: Record<string, string> };
return { found: true, id: contact.id, properties: contact.properties };
},
});
A client that lists tools sees, for each one:
| Field | Comes from |
|---|---|
name | name |
description | description. The model picks tools by this text, so say what the tool does, when to use it, and what it returns |
inputSchema | JSON Schema generated from the Zod input, including .describe() text on each field |
annotations | annotations, when set |
The server identifies itself to clients with the project name from helix.config.ts and the version of the Helix SDK the project runs.
Annotations
annotations passes MCP tool annotations through to the client. They are hints a client may show or act on, for example to ask before running a destructive tool, and the platform does not enforce them.
| Hint | Meaning |
|---|---|
title | A display name for the tool |
readOnlyHint | The tool does not change anything |
destructiveHint | The tool may delete or overwrite data |
idempotentHint | Calling it again with the same input has no further effect |
openWorldHint | The tool reaches external systems |
Choosing which tools are served
mcp.tools is the whole list. A tool that is not on it is never listed or callable over MCP, however it is used elsewhere, so a tool written for an agent stays private until you add its module path. The same module can be on the list and imported by an agent; the handler is the same, and ctx.trigger.type tells the two callers apart.
Tools with needsApproval set, whether true or a predicate, are skipped even when listed: an MCP call has no person in the loop to approve it.
How long clients cache the list
Clients are told they may cache the tool list for five minutes. Change it with listTtlMs:
mcp: {
enabled: true,
tools: ['_tools/lookup-customer'],
listTtlMs: 60_000,
},
The list is the same for every caller, so clients may share a cached copy.
The endpoint
| URL | |
|---|---|
| Deployed | https://{project-id}.helix-app.ai/mcp, or /mcp on the project’s readable project URL |
Local (helix dev) | http://localhost:3000/mcp, or the port you passed to --port |
If you set mcp.path, use that path in place of /mcp everywhere on this page.
The endpoint accepts POST only and answers every request with a single JSON reply. Streamable HTTP is the name of MCP’s HTTP transport, which lets a server answer with either JSON or a stream of Server-Sent Events. This endpoint always answers with JSON, so a client sends one request and gets the whole reply at once, and nothing is remembered between requests. Clients that open with the older initialize handshake are served too. Clients must still send Accept: application/json, text/event-stream on every request, whichever protocol version they speak, as the transport requires; a request without both gets 406. The reply is always application/json.
The endpoint and a function cannot share a path. While mcp.enabled is set, a function routed to exactly the MCP path (for the default, functions/mcp.ts, functions/mcp.post.ts, functions/mcp/index.ts, or a method variant of either) fails helix dev, helix deploy, and the deploy build with an MCP_PATH_CONFLICT error naming the file. To keep a /mcp function of your own, serve MCP somewhere else:
mcp: {
enabled: true,
path: '/api/mcp',
tools: ['_tools/lookup-customer'],
},
Paths below the MCP path, such as /mcp/docs, are yours to use. A project that does not enable MCP keeps every path for its own functions.
Authentication
A deployed app is behind login, and so is its MCP endpoint: every request carries a bearer token.
Authorization: Bearer hxk_...
Use an API token. You create one from the project’s Access Control tab, under API tokens, choosing the API user it acts as and when it expires (30 days, 90 days, one year, or never). It is long-lived and revocable, which is what a connector configured once and used for weeks needs. The platform checks the token before the request reaches your code, and the tool runs as the token’s API user: ctx.identity.user.id is that API user, not the person driving the client, and the execution is attributed to it. Pick a dedicated API user per connector if you want calls told apart in the logs; API users covers creating them and rotating their tokens.
Whoever can reach the app can list and call every served tool. Access is granted per project on its Access Control tab, the same as for the app itself; see identity and roles. There is no per-tool access rule yet.
Browser-based clients send an Origin header, and the endpoint accepts it only when it matches the app’s own host. Native clients send none and are unaffected. Under helix dev, which needs no token, the endpoint answers only requests addressed to localhost (or 127.0.0.1) and, from a browser, only pages served from localhost.
Connect a client
Use the app’s URL with /mcp (or your mcp.path) appended and an API token. For the local server use http://localhost:3000/mcp and leave the header out.
Claude Code
claude mcp add --transport http my-helix-app https://{project-id}.helix-app.ai/mcp \
--header "Authorization: Bearer hxk_..."
Cursor, in .cursor/mcp.json for one project or ~/.cursor/mcp.json for all of them:
{
"mcpServers": {
"my-helix-app": {
"url": "https://{project-id}.helix-app.ai/mcp",
"headers": { "Authorization": "Bearer hxk_..." }
}
}
}
VS Code, in .vscode/mcp.json:
{
"servers": {
"my-helix-app": {
"type": "http",
"url": "https://{project-id}.helix-app.ai/mcp",
"headers": { "Authorization": "Bearer hxk_..." }
}
}
}
MCP Inspector, for trying tools by hand:
npx @modelcontextprotocol/inspector
Choose the Streamable HTTP transport, enter the URL, and add an Authorization header with the bearer token under the authentication settings. Against helix dev, enter http://localhost:3000/mcp with no header.
Claude Desktop, Claude.ai, and ChatGPT add remote servers as custom connectors, and their connector settings expect the server to sign the user in with OAuth rather than take a pasted header. Helix does not offer an OAuth flow for the endpoint yet, so these clients are supported once the sign-in flow ships. Until then, use a client that accepts a static header, such as the ones above.
curl, to check the endpoint answers:
curl -s http://localhost:3000/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
The reply names the server after your project. Against a deployed app, add -H 'authorization: Bearer hxk_...'.
A 2026-07-28 client sends no initialize; each request stands alone and names its method in a header that must match the body:
curl -s http://localhost:3000/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-H 'mcp-protocol-version: 2026-07-28' \
-H 'mcp-method: tools/list' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
A tools/call also sends mcp-name: <tool>. The reply is one JSON document, never an event stream.
What a tool call gets
A call over MCP runs handler the same way an agent call does: the input is validated against the Zod schema first, and the handler receives a full ctx.
On ctx | Value |
|---|---|
input | The validated input |
trigger | { type: 'mcp', tool: '<name>', client?: { name, version? } }. client is present when the MCP client reports its name and version with the call. Clients on older protocol versions (2025-11-25 and earlier) report it only during the initialize handshake, which the endpoint does not store, so it is absent on their tool calls |
identity, userId | The caller, from the bearer token: the API user the token acts as. Every call made with the same token looks like the same user. null under helix dev, where no token is sent. See ctx.identity |
http, kv(), ai(), agent(), log, callFunctionAsync() | As in any function |
executionId, deploymentId, traceId | The execution this call created, the deployment it ran in, and its trace |
request, status() | Not available: there is no HTTP request of yours to read or status to set |
ctx.trigger.type is how a tool shared between an agent and the endpoint tells the two apart.
What the handler returns is sent to the client as text content:
| Handler returns | Client receives |
|---|---|
| A string | That string |
undefined or null | Empty content |
| Anything else | The value as pretty-printed JSON |
Keep results small. The client passes the whole result to its model on every later turn, so return the fields the caller needs rather than a whole API response.
Errors
A failing call returns a tool error the client’s model can read, not a protocol failure, so the model can recover or tell the user:
| What happened | What the client sees |
|---|---|
| Input fails the schema | Invalid input: <field paths>. The handler never runs |
Handler throws ctx.error(status, message) | The message |
| Handler runs past the 170 s budget | Tool "<name>" did not finish within 170s, with structuredContent: { code: 'timeout' }. The handler is not stopped; see below |
| Handler throws anything else | Tool "<name>" failed. Execution ID: <id>. The real error is in the execution’s logs. Under helix dev the message is included |
| A tool that is not listed, or was skipped | A protocol error from the server: tool not found |
A timeout only decides the reply. The handler keeps running until it finishes or the platform stops it, so a write it was making can still land after the client has been told it failed, and a client that retries can make it twice. Make a tool that writes safe to repeat, for example by keying the write on something in its input, and say so with annotations: { idempotentHint: true } so clients know a retry is safe.
Find a failed call in the dashboard or with helix logs: the execution is listed with trigger type mcp and the route MCP tools/call <name>, and the Type filter narrows the list to MCP calls. The execution’s details show the MCP method, the tool, and the name and version of the client that called it. See observability.
Local development
With mcp.enabled set, helix dev serves the endpoint on the same port as your functions and needs no token. It reads enabled and path once at startup, so turning the endpoint on or off, or moving it, needs a dev-server restart. It also scans functions/_tools/ once at startup, so a tool file you add or remove needs a restart too; edits to existing tool files and to mcp.tools hot-reload like any other change. When the endpoint is on, the startup output shows the URL and what it serves:
➜ MCP: http://127.0.0.1:3000/mcp
serves 2 tools listed in mcp.tools
With an empty list it says no tools yet — list tool modules in mcp.tools, e.g. '_tools/lookup-customer', and each entry that names a missing module gets its own ⚠ line. When the endpoint is off, nothing about MCP is printed and no MCP path is served.
Point any client at http://localhost:3000/mcp to exercise tools before you deploy. Calls run with ctx.identity set to null, since the dev server has no sign-in flow, so a tool that reads it should handle the null case locally. A tool that throws reports the real error message locally, so you see what went wrong without opening logs.
Limits
| Item | Value |
|---|---|
| Tool budget per call | 170 s, then a timeout tool error. The handler is not stopped |
| Reply size | About 4.5 MB. For more, return a link the client can fetch rather than the data itself |
| Progress updates | None. The client waits for the reply, so keep tools short |
| Transport | One JSON reply per request; nothing is streamed, and there are no sessions |
Tools with needsApproval | Skipped, even when listed |
Troubleshooting
The endpoint answers 404, or the client cannot find the server. mcp.enabled is not set, the URL’s path is not your mcp.path, or you changed either while helix dev was running. Add enabled: true under mcp in helix.config.ts and restart the dev server. A reply saying MCP is not enabled for this project means the same thing.
The client reports 405. The endpoint accepts POST only. A client that probes with GET or DELETE first, as some do for session setup, gets 405 with Allow: POST and should continue with POST. If it does not, set the client to the Streamable HTTP transport: the older HTTP+SSE transport (often labelled just “SSE” in client settings) is not supported.
The client gets 400 with error code -32020. A 2026-07-28 request’s headers disagree with its body: mcp-method names a different method, or mcp-name a different tool, than the JSON-RPC call. Clients built on the official SDKs send matching headers; a hand-written request must set both to the body’s values.
A browser-based client gets 403. The request carried an Origin header for a host other than the app’s. The endpoint only accepts browser requests from the app itself. Under helix dev, use http://localhost:3000/mcp or http://127.0.0.1:3000/mcp: requests addressed to any other hostname, or from pages not served from localhost, get 403.
helix deploy fails with INVALID_MCP_CONFIG. An entry in mcp.tools names a module that does not exist. The message lists each one as _tools/x → functions/_tools/x.ts; fix the path or create the file. The deploy build fails with the same code if the check is skipped, and helix dev warns about the same entries at startup rather than stopping.
helix dev or helix deploy fails with MCP_PATH_CONFLICT. MCP is enabled and the project also defines a function that routes to the MCP path. The error lists the offending files as functions/<file> → /mcp and says to set mcp.path to a path no function uses, or to rename or move the files. Setting mcp.path: '/api/mcp' keeps your /mcp function. Paths below the MCP path are still available to you.
The config fails to load with an mcp.path error. The path must start with /, have no trailing slash, use only letters, digits, ., _ and -, and have no segment starting with _ or .. /mcp/, /orders/[id], /_helix/mcp and /.well-known/mcp are all rejected.
The deploy build fails asking you to upgrade the SDK. mcp.enabled is set but the project’s @trayai/helix-sdk predates the endpoint. The message says to upgrade @trayai/helix-sdk to 1.30.0 or later; do that and redeploy.
The client gets 401 Unauthorized from a deployed app. No bearer token was sent, or it has expired or been deleted. Add the Authorization header to the client’s configuration with an API token, or replace the token: an API token stops at the expiry you chose when you created it, and a deleted one stops at once.
A tool is missing from the list. It is one of: not in mcp.tools; listed with a path that does not match a file (the ⚠ line at helix dev startup names it); a file created after helix dev started, which is not picked up until you restart the dev server, even once mcp.tools lists it; a module that does not default-export a defineTool definition, or a tool with needsApproval, both skipped with a warning; defined inline in an agent file, which cannot be listed; or not yet picked up because the client cached the list, in which case reconnect or wait for listTtlMs to pass.
Every call fails with Invalid input. The client sent arguments that do not satisfy the Zod schema. The message names the failing fields; .describe() text on those fields is what the model reads to correct itself.
The deployed app answers the MCP path with the app itself. The deployment was built with an SDK older than 1.30.0, or before mcp.enabled was set. Redeploy on 1.30.0 or later.
Full option list for defineTool and the mcp config key: agent definition reference. Tools themselves are covered in defining tools.