Connect MCP servers (with OAuth)
Add an MCP server under integrations and call its tools from Func with ctx.mcp. Servers that need OAuth sign-in work too, with either your account or each visitor's own. The platform keeps the tokens; Func never sees them.
Add an MCP server under integrations and Func can call its tools with ctx.mcp('name', tool, args), including servers that require sign-in (OAuth) such as Linear, Notion or Sentry. The platform runs the authorization and holds the tokens; your code never sees them.
Add an MCP server
Open Backend → Integrations in the editor, click MCP and fill in the table below. Saving connects to the server once, so a wrong URL or auth setting fails right away.
| Field | What to enter | Required |
|---|---|---|
| Name | The server name in code, e.g. linear. Letters, digits, - and _ only; creght is reserved | Yes |
| Server URL | The MCP Streamable HTTP endpoint, usually ending in /mcp, e.g. https://mcp.linear.app/mcp. https only | Yes |
| Authentication | OAuth: servers that need sign-in (default). Token: the server gave you a fixed token. None: public servers | Yes |
| Whose account | With OAuth: Mine or Each visitor connects their own | With OAuth |
| Scopes | Leave blank to request what the server asks for | No |
| OAuth client ID / secret | Only for servers without dynamic client registration. Most servers (Linear, Notion, Sentry, Atlassian) support it, so leave these blank | No |
With "Mine", click Authorize on the card after saving, then sign in and approve in the popup. The card shows the authorization state and every tool the server offers.
Call it from Func
export async function createTask(input, ctx) {
const tools = await ctx.mcp.tools('linear') // [{ name, description, input_schema }]
const issue = await ctx.mcp('linear', 'create_issue', {
title: input.title,
team: 'ENG',
})
return issue
}
| Method | Description |
|---|---|
ctx.mcp(name, tool, args?) | Calls a tool. Resolves to its structured result; text-only results are parsed when they are JSON and returned as-is otherwise. A tool error rejects |
ctx.mcp.tools(name) | Lists the tools: name, description, input_schema. Check it before writing code; tool names and arguments come from here |
ctx.mcp.status(name) | Whether it can be called now: connected, connect_as, signed_in, authorize_url |
ctx.mcp.disconnect(name) | Removes the current visitor's own authorization. Only for "each visitor" servers |
Each visitor connects their own account
The platform has no visitor-facing UI: your pages render the button and the messages. What the platform gives you is an authorization entry point:
/auth/mcp/start?server=linear&redirect=/dashboard
The visitor must be signed in to the site. The platform takes them to the server to sign in and approve, then sends them back to the redirect path with ?mcp_connected=linear, or ?mcp_error=reason on failure. From then on that visitor's calls use their own account.
Return "needs connecting" as a normal value instead of making the page handle exceptions:
import type { TalizenFuncContext } from 'talizen/func-runtime'
export async function myIssues(input: unknown, ctx: TalizenFuncContext) {
ctx.auth.requireUser()
const st = await ctx.mcp.status('linear')
if (!st.connected) return { needConnect: true, url: st.authorize_url }
try {
const issues = await ctx.mcp('linear', 'list_issues', { assignee: 'me' })
return { needConnect: false, issues }
} catch (e: any) {
if (e.code === 'mcp_authorization_required') {
return { needConnect: true, url: st.authorize_url }
}
throw e
}
}
export async function disconnect(input: unknown, ctx: TalizenFuncContext) {
ctx.auth.requireUser()
return ctx.mcp.disconnect('linear')
}
In the page:
import { invoke } from 'talizen/func'
const res = await invoke('linear.myIssues', {})
if (res.needConnect) {
const href = res.url + '&redirect=' + encodeURIComponent(location.pathname)
// render <a href={href}>Connect Linear</a>
}
The visitor is the site's signed-in user (ctx.auth) first, then the project member (ctx.member). So when you try a Func in the editor, it uses the authorization you made with "Connect my account" on the integration card.
Security and limits
- Tokens stay on the platform, encrypted, and never enter Func. They are refreshed before they expire; when refreshing fails, calls return
mcp_authorization_required. - Do not implement MCP authorization in Func or call the server with
fetch. Only with Token auth can you turn on "expose to Func" and call it yourself with the environment variable. - Only Streamable HTTP is supported, not the older HTTP + SSE transport or local stdio servers.
- Each call opens a new connection, one extra round trip compared with a plain API call, so avoid dozens of calls in one request.
- Changing the server URL, authentication, account mode or client ID invalidates every existing authorization.
