Coding agents
How to connect Autonex to agents that work in your terminal or editor —Claude Code, OpenAI Codex, Cursor and VS Code with GitHub Copilot— and how to write your own agent with the official MCP SDKs. Read Essentials first.
Before you start (every client)
Create one key per agent in Settings → API & MCP, with just the scopes it needs (how). For analysis,
…:read. Add…:writeonly if the agent will propose changes.Put the key in an environment variable of your session, for example in
~/.zshrcor~/.bashrc, or load it from your secrets manager:export AUTONEX_MCP_KEY="mk_xxxxxxxx_…"The client must start in an environment where that variable exists. If you open the editor from the Dock or the start menu, it may not inherit your terminal's variables: start it from the terminal or define the variable system-wide.
Project configuration files (
.mcp.json,.cursor/mcp.json,.codex/config.toml,.vscode/mcp.json) go into git: write the reference to the variable in them, never the key.Set up tool approval: reads without asking, if you like;
confirm_action,create_incidentandadd_incident_notealways with approval. Don't use modes that skip every permission with a key that has write scopes.
Claude Code
Verified against the Claude Code MCP documentation and the permissions page.
Add the server
claude mcp add --transport http autonex https://mcp.autonexhub.es/mcp \
--header "Authorization: Bearer $AUTONEX_MCP_KEY"Options (--transport, --scope) go before the name. --scope chooses where it is stored:
| Scope | For whom | Stored in |
|---|---|---|
local (default) | Only you, in this project | ~/.claude.json |
user | Only you, in all your projects | ~/.claude.json |
project | The whole team of the repository | .mcp.json at the project root (goes into git) |
With local and user, your shell substitutes $AUTONEX_MCP_KEY when adding it, and the key is stored in ~/.claude.json, on your machine and outside the repository.
Project configuration (.mcp.json)
To share the connection with the team, without the key, create .mcp.json at the project root. Claude Code substitutes ${AUTONEX_MCP_KEY} at startup with each person's variable:
{
"mcpServers": {
"autonex": {
"type": "http",
"url": "https://mcp.autonexhub.es/mcp",
"headers": { "Authorization": "Bearer ${AUTONEX_MCP_KEY}" }
}
}
}The first time a .mcp.json is used, Claude Code asks you to approve the server. If the variable doesn't exist, claude mcp list and /mcp show a warning and the server will answer 401.
Check the connection
claude mcp list: theautonexserver and its status.claude mcp get autonex: the configuration details.- Inside a session,
/mcp: the server's status and its tools. - First message: "Call whoami on the Autonex MCP and tell me which organization and permissions I'm connected with".
In Claude Code the tools are named mcp__autonex__<tool>, for example mcp__autonex__ops_overview.
Approvals
Claude Code asks before using MCP tools. To skip the question for reads but keep it for writes, add rules to .claude/settings.json (project) or ~/.claude/settings.json (you). ask rules win over allow rules, so this lets every Autonex tool through except the writes:
{
"permissions": {
"allow": ["mcp__autonex__*"],
"ask": [
"mcp__autonex__confirm_action",
"mcp__autonex__create_incident",
"mcp__autonex__add_incident_note"
]
}
}When Claude asks you to approve confirm_action, first read the preview's summary it showed you.
OpenAI Codex (CLI)
Verified against the Codex MCP documentation.
Configuration
Codex reads ~/.codex/config.toml (you, in every project) and, in trusted projects, the project's .codex/config.toml. Add:
[mcp_servers.autonex]
url = "https://mcp.autonexhub.es/mcp"
bearer_token_env_var = "AUTONEX_MCP_KEY"
default_tools_approval_mode = "prompt"
# Optional: reads you use often, without asking
[mcp_servers.autonex.tools.whoami]
approval_mode = "approve"
[mcp_servers.autonex.tools.usage]
approval_mode = "approve"bearer_token_env_var makes Codex send Authorization: Bearer <value of AUTONEX_MCP_KEY>: the key is not written in the file. To limit the tools Codex sees, use enabled_tools = ["whoami", "usage", "ops_overview", …].
You can also start with codex mcp add autonex --url https://mcp.autonexhub.es/mcp and then add bearer_token_env_var by hand in the [mcp_servers.autonex] section of config.toml.
Check the connection
codex mcp list: the configured servers.- Inside
codex,/mcp: the active servers and their tools. - First message: "Use the autonex whoami tool and tell me which tools I have".
Cursor
Verified against the Cursor MCP documentation.
Create .cursor/mcp.json in the project, or ~/.cursor/mcp.json for all your projects:
{
"mcpServers": {
"autonex": {
"url": "https://mcp.autonexhub.es/mcp",
"headers": { "Authorization": "Bearer ${env:AUTONEX_MCP_KEY}" }
}
}
}Cursor replaces ${env:AUTONEX_MCP_KEY} with the environment variable; the key does not stay in the file.
- Check: enable the server under Customize (sidebar) and look at its tools under Available Tools. If it doesn't connect, open the Output panel (Cmd/Ctrl+Shift+U) and choose MCP Logs.
- Approvals: Cursor asks for approval before using MCP tools. If you use tool allowlists or auto-run, leave out
confirm_action,create_incidentandadd_incident_note. - First message (in chat, agent mode): "Call whoami on the autonex MCP".
VS Code (GitHub Copilot, agent mode)
Verified against the VS Code MCP configuration reference and the Add MCP servers guide.
Recommended configuration (.mcp.json)
VS Code and Copilot read .mcp.json at the workspace root and, for you, ~/.copilot/mcp-config.json. It is the same format as Claude Code, so one .mcp.json works for both:
{
"mcpServers": {
"autonex": {
"type": "http",
"url": "https://mcp.autonexhub.es/mcp",
"headers": { "Authorization": "Bearer ${AUTONEX_MCP_KEY}" }
}
}
}Write ${AUTONEX_MCP_KEY} with braces: without them ($AUTONEX_MCP_KEY) VS Code sends it as literal text.
Alternative: .vscode/mcp.json with the key asked at startup
The editor format (.vscode/mcp.json) can ask you for the key instead of reading it from a variable. VS Code keeps supporting it, but recommends the format above for new configurations:
{
"inputs": [
{ "type": "promptString", "id": "autonex-key", "description": "Autonex API key (mk_…)", "password": true }
],
"servers": {
"autonex": {
"type": "http",
"url": "https://mcp.autonexhub.es/mcp",
"headers": { "Authorization": "Bearer ${input:autonex-key}" }
}
}
}VS Code asks you for the value the first time the server starts.
Check and approve
- The MCP: List Servers command, or Chat: Open Customizations → MCP Servers: the server's status.
- In chat, in agent mode: "Call whoami on the autonex MCP".
- Copilot asks for approval for tools. Approve
confirm_actionone call at a time, after reading the preview; don't approve it permanently.
Other clients
Any client that speaks Streamable HTTP and can send an Authorization header works: URL https://mcp.autonexhub.es/mcp and header Authorization: Bearer <key>. If your client only offers OAuth or the legacy SSE transport, it can't connect yet (OAuth access is planned). Windsurf (now Devin Desktop) is not listed here because we could not verify its current format.
Example tasks
Write the request as you would to a person. The agent picks the tools; for every change it shows you the preview and waits for your "yes".
Operations (ops pack)
"Analyse the absences and uncovered classes at CEM Joan Miró this week and propose covers."
ops_overviewwithlocation: "Joan Miró": absences, uncovered classes with the best candidates for each, and conflicts, in a single call.- If you ask for alternatives for a class,
ops_cover_candidates. - When you choose ("Have Marta Ruiz cover Tuesday's Pilates"),
ops_cover_assign_previewreturns thesummary("Assign Tuesday 10:00 Pilates to Marta Ruiz"), the warnings and aconfirm_token. Nothing has changed. - You answer "yes" and the agent calls
confirm_action. The panel shows the cover as if a person had assigned it.
It needs ops:read to analyse and ops:write to assign. Other requests:
- "Which instructors are closest to their hours cap this month? Put a table in
hours.csv." (ops_worker_hours; the coding agent writes the file in your project). - "Undo the cover we assigned yesterday at Joan Miró." (
ops_cover_history→ops_cover_undo_preview→ confirmation).
Incidents (incidents pack)
"Which high-priority incidents are still pending? Leave a note on HEM-142 saying the customer will call back tomorrow, and mark it as resolved."
list_incidentsfor the list.add_incident_noteadds the note in a single call (it only adds information): that is why your client should ask for approval here too.update_incident_previewwithstatus: "resolved"shows the change ("Status: pending → resolved") and the conversations that will be closed.- After your "yes",
confirm_action.
It needs incidents:read to look and incidents:write for notes and changes.
Conversations (conversations and contacts packs)
"Find yesterday's conversations where the customer asked to talk to a person, and summarise the most common reasons."
search_conversations (for example with needs_human) and get_conversation for each one. Read only: no confirmations. It needs conversations:read.
Build your own agent
The server keeps no session: every request carries the Authorization header. With the official SDKs you just pass the header to the transport.
TypeScript (@modelcontextprotocol/sdk 1.x)
npm install @modelcontextprotocol/sdkimport { createInterface } from 'node:readline/promises';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
const client = new Client({ name: 'my-agent', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('https://mcp.autonexhub.es/mcp'), {
requestInit: { headers: { Authorization: `Bearer ${process.env.AUTONEX_MCP_KEY}`, 'Accept-Language': 'en' } },
}));
// What can I do
const { tools } = await client.listTools();
console.log(tools.map((t) => t.name));
// Two-phase write: preview → a person confirms → confirm_action
const preview = await client.callTool({ name: 'ops_cover_assign_preview', arguments: { request_id: 812, worker_id: 15 } });
if (preview.isError) throw new Error(JSON.stringify(preview._meta?.error));
const p = preview.structuredContent as { summary: string; confirm_token: string };
const rl = createInterface({ input: process.stdin, output: process.stdout });
const ok = (await rl.question(`${p.summary}\nConfirm? (y/n) `)).trim().toLowerCase() === 'y';
rl.close();
if (ok) {
const done = await client.callTool({ name: 'confirm_action', arguments: { confirm_token: p.confirm_token } });
console.log(done.structuredContent);
}
await client.close();Python (mcp 2.x)
pip install "mcp>=2"import asyncio, os
import httpx2
from mcp import Client
from mcp.client.streamable_http import streamable_http_client
async def main() -> None:
headers = {"Authorization": f"Bearer {os.environ['AUTONEX_MCP_KEY']}", "Accept-Language": "en"}
async with httpx2.AsyncClient(headers=headers, timeout=httpx2.Timeout(30.0, read=300.0)) as http_client:
transport = streamable_http_client("https://mcp.autonexhub.es/mcp", http_client=http_client)
async with Client(transport) as client:
me = await client.call_tool("whoami", {})
print(me.structured_content)
preview = await client.call_tool("ops_cover_assign_preview", {"request_id": 812, "worker_id": 15})
p = preview.structured_content
if p is None: # error: the text carries the code, e.g. "FORBIDDEN: …"
raise SystemExit(preview.content[0].text)
if input(f"{p['summary']}\nConfirm? (y/n) ").strip().lower() == "y":
done = await client.call_tool("confirm_action", {"confirm_token": p["confirm_token"]})
print(done.structured_content)
asyncio.run(main())In version 2 of the Python SDK the headers go on the HTTP client (httpx2.AsyncClient), not on streamable_http_client. On 1.x, the equivalent is streamablehttp_client(url, headers=headers) with ClientSession (see LiveKit or your own agent).
Rules for your agent
- Call
whoamifirst and use itstoolslist. - For every
*_preview, showsummary(and the key points ofeffects) to a person and wait for their approval beforeconfirm_action. If more than 15 minutes go by, ask for a new preview. - Branch on
_meta.error.code(or the code at the start of the text), never on the message. - On
RATE_LIMITED, waitretry_afterseconds. OnQUOTA_EXCEEDED, stop. - The ids in the examples (
request_id: 812…) are illustrative: get them with the read tools.