Connect an AI client (MCP)
Connect Claude, Cursor, Codex, or another MCP client to Serena over the hosted server with OAuth, or run the local server for headless machines.
Recommended: the hosted server
Serena runs a hosted MCP server over Streamable HTTP. Your client opens your browser, you sign in to Serena and approve the access it asks for, and the client keeps its own token. There is nothing to install and no API key to create or protect.
https://withserena.ai/api/mcpThe client can use only the access you approve, and each tool still checks your workspace permissions. Pass a workspace_id to tools that work inside one workspace. The hosted server does not use the workspace open in your browser as a default.
Set up your client
| Client | How you connect |
|---|---|
| Claude Code | One command |
| Cursor | One command |
| Codex | Two commands |
| Claude Desktop and Claude on the web | Add a custom connector in Settings |
serena mcp install --client <client> comes with the Serena CLI and adds the hosted server to the client’s config file. Remove the entry with serena mcp uninstall --client <client>.
Set up Claude Code
claude mcp add --transport http serena https://withserena.ai/api/mcp
# or, with the Serena CLI (writes .mcp.json in this folder)
serena mcp install --client claude-codeThen run /mcp in Claude Code to sign in.
Set up Cursor
serena mcp install --client cursorThis writes .cursor/mcp.json in the current folder. Cursor prompts you to sign in the first time it uses the server.
Set up Codex
serena mcp install --client codex
codex mcp login serenaCodex does not prompt for sign-in on its own, so the second command is required. The first writes ~/.codex/config.toml.
Set up Claude Desktop and Claude on the web
- In Claude, open Settings, then Connectors.
- Choose Add custom connector.
- Enter https://withserena.ai/api/mcp as the URL.
- Sign in to Serena and approve the access the consent screen lists.
Claude Desktop keeps remote servers in this screen, not in its config file. serena mcp install --client claude prints the same steps.
Choose a toolset
By default a client sees every tool. A profile shortens the list for an agent that needs fewer tools. Profiles are core, planning, knowledge, routines, admin, and all. Every profile includes the core tools, such as tasks, labels, search, and the dashboard. Each tool still needs its own permission.
https://withserena.ai/api/mcp?profile=coreYou can send the header X-Serena-MCP-Profile: core instead. When both are present, the URL parameter wins. The local server reads SERENA_MCP_PROFILE. An unknown profile name is rejected.
Headless machines: the local server
For CI, scripts, and hosts with no browser, run the local stdio server with an API key. Provide the key as the SERENA_API_KEY environment variable from your CI secret store or a secret manager. Do not type it into a command, a script, or a shell profile. API keys are a limited rollout: create one in Settings, then API Keys, if that page appears in your account. Without it, use the hosted server above.
npx -y @serena-ai/mcp-server
# or write the client config with the Serena CLI
serena mcp install --client claude-code --transport stdio| Variable | Required | Purpose |
|---|---|---|
| SERENA_API_KEY | Yes | Authenticates requests from the local server. |
| SERENA_WORKSPACE_ID | No | Pins workspace-only tools to one workspace. |
| SERENA_MCP_PROFILE | No | Selects a toolset profile. Defaults to all. |
| SERENA_ACTIVE_PLAN_PROPOSALS | No | Off by default. 1 or true registers propose_plan_seed and propose_plan_revision in the all and planning profiles, and needs SERENA_WORKSPACE_ID set to a workspace UUID. Registering them grants no access: every call still needs a workspace-pinned key with Plan proposal consent and a reviewed binding. |
The API key must start with srn_, serena_live_, or serena_test_. The server exits at startup if the key is missing or has a different prefix.
How agents discover the endpoint
The hosted endpoint uses the OAuth authorization code flow with PKCE. A request with no token receives an HTTP 401 challenge that names the OAuth protected-resource metadata, and the client discovers the authorization server from there. Agents can start from the API catalog at /.well-known/api-catalog, which links to the endpoint and its metadata at /.well-known/oauth-protected-resource/api/mcp.