Docs
Production facts for your agents
Lessons tell agents about past mistakes. Production facts tell them how the code they're about to change behaves right now, so they don't make a new one.
What agents get
Codela runs an MCP server with one read-only tool, production_facts. An agent passes the files it's about to change (and the routes, if it knows them). Codela answers from the repo's monitoring tool, for the last 24 hours:
- requests per day, p50 and p95 latency and error rate for the endpoints those files serve, and how they rank;
- slow functions defined in those files, and other services they call many times per request;
- Codela lessons about those files;
- the service's overall numbers, for context.
Production facts for acme/shop (service `shop-api` in Datadog, last 24h):
Whole service: p50 40ms, p95 300ms, error rate 0.4%, 136,000 requests/day.
Endpoints these files serve or handle:
- `POST /api/checkout`: 41,200 requests/day, p50 180ms, p95 620ms, errors 0.3% <- the slowest of 12 endpoints
Downstream services these files call, per request:
- `inventory-service`: about 4.2 calls per request. One more call in a loop multiplies.
Codela lessons about these files (details in .codela/lessons/):
- [high] Batch price lookups per cart; one query per item made checkout 3x slower.Your lessons file asks agents to call it before changing a request handler, a database query or calls to another service. In our tests, a Claude Code agent asked to add a GitHub call to a busy webhook checked production first, saw it was the slowest endpoint, and moved the new call to a background thread.
Set it up
Claude Code and Cursor: sign in once
Codela's lessons pull request adds Codela to your repo's .mcp.json (Claude Code) and.cursor/mcp.json (Cursor), so everyone on your team gets it with the repo. There's no key in those files: each person signs in to Codela once.
- Claude Code (on your computer): open it in the repo and approve the
codelaserver if it asks. Then type/mcp, pick codela (it shows “needs authentication”) and chooseAuthenticate. Your browser opens; click Allow. From the terminal,claude mcp login codeladoes the same. - Cursor: in Cursor's MCP settings, click the login button next to codela, then Allow in the browser.
That's it, for good: the tool keeps its access and refreshes it by itself.
Codela only adds itself to these files. Anything else in them is kept, and if they already have acodela entry, they're left alone.
Claude Code on the web (cloud sessions)
Cloud sessions read the same .mcp.json, but they run in a sandbox: they can't open a browser to sign in, and they only reach websites your environment allows. Set it up once per cloud environment, in its settings (the cloud environment menu in the session's title bar, then Edit):
- Network access: allow
api.usecodela.com. - Network secrets: add one for host
api.usecodela.com, headerX-Codela-Key, with your Codela key as the value. Create the key in Settings, under Production facts for your agents(Create a key for your agents). The environment adds it to every request to Codela, so the key never sits in your repo or your chat. - That's it. No new session needed: the tool is there from the start of every session, and it works from the next time your agent calls it after you save the secret. Every later session has it too.
Put the key in Network secrets, not in an environment variable: commands in the session can read environment variables, but not network secrets.
Codex, or connecting by hand
In Settings, under Production facts for your agents, click Create a key for your agents. The key is yours and stops working if you leave the workspace. Then:
Cursor, in ~/.cursor/mcp.json (your home folder, so the key isn't committed):
{
"mcpServers": {
"codela": {
"url": "https://api.usecodela.com/mcp",
"headers": { "X-Codela-Key": "<your Codela key>" }
}
}
}Codex, in ~/.codex/config.toml, with CODELA_API_KEY set to your key in your shell:
[mcp_servers.codela]
url = "https://api.usecodela.com/mcp"
bearer_token_env_var = "CODELA_API_KEY"Claude Code without the plugin:
claude mcp add --transport http codela https://api.usecodela.com/mcp --header "X-Codela-Key: <your Codela key>"If your workspace watches more than one repo, the agent passes repo (owner/name). The plugin does it for you.
How it works, and what it never returns
- It matches files to production by the route paths, function names and service hosts in them (read from your default branch), or by file name for files that aren't pushed yet. When nothing matches, it says so instead of guessing.
- Each repo is read from its own monitoring tool, at most once every 15 minutes, so agents don't load your monitoring API. Calls are rate-limited per workspace.
- It returns numbers and route or function names only. Error messages are never returned, only counted: anyone using your app can choose an error's text, and this goes straight into your agent's context.
- It only answers about repos your workspace watches. Signing in from an AI tool gives that tool its own read-only access for you: it works only for these tools (not the rest of Codela), and stops if you leave the workspace.