MCP Server
Swarm ships an MCP (Model Context Protocol) server that plugs directly into your AI coding editor. Instead of jumping to a browser or terminal, you can drive a full UX test loop from inside Claude Code, Codex, or Cursor with one prompt.How it works
Install
One command registers the MCP with your editor and signs you in:- Registers the MCP with Claude Code (via
claude mcp add) and Codex CLI (writes~/.codex/config.toml). - Opens your browser to the device-code login page.
- Stores the API key at
~/.useswarm/config.json(mode0600).
dev_test, dev_watch, dev_status, dev_close) are ready to use.
Limit to one editor
Register without signing in
For CI, containers, or shared machines usingUSESWARM_API_KEY env:
login call).
Authentication
Swarm uses API keys scoped to your account. Auth happens at setup time, in your terminal — never mid-session inside the editor.The MCP does not trigger an interactive login when the editor spawns it. If no key is found at startup, the MCP exits with a clear message telling you to run
setup or login from a terminal. This avoids broken device-code prompts fighting your editor’s UI.Switching accounts
Manual setup
If you don’t want to usesetup, you can register the MCP yourself.
Claude Code
Codex CLI
Edit~/.codex/config.toml:
npx @useswarm/mcp login.
Cursor
Add to.cursor/mcp.json:
VS Code (Copilot)
Add to.vscode/settings.json:
Updating
@latest. It pulls the newest release from npm and rewrites the path in your editor’s config so the next launch picks up the new code. Then restart your editor — MCP processes are spawned at startup, so a running one won’t see the update.
Already signed in? setup notices, skips the login step, and finishes faster.
Power-user alternative
setup once.
Tools
The MCP exposes five tools that drive a test → fix → retest loop.dev_list_swarms
List the saved persona swarms tied to your account (personal + active org). Use this to discover swarm IDs before passing one to dev_test.
Returns: { swarms: Array<{ id, name, description, agentCount, personaCount, createdAt }>, count }.
Example prompt:
Use dev_list_swarms to show me which Useswarm persona sets are saved on my account.
dev_test
Tunnel your localhost (or hit a public URL directly) and start an AI agent swarm test.
Parameters:
Returns:
{ batchId, dashboardUrl, _devLoop: { tunnel, nextStep, ... } }.
Example prompts:
Use dev_test to test http://localhost:3000 with goal “sign up and reach the dashboard”. The audience is first-time users.
Use dev_list_swarms, then dev_test on http://localhost:3000 with goal “complete checkout” using my “B2B Buyers” swarm.
dev_watch
Wait for a test to finish, then return structured findings.
Parameters:
Returns:
dev_status
Diagnose the MCP setup. Returns auth state, tunnel state, and any active test.
recovery will name the exact command to run.
dev_close
Tear down the active tunnel manually. Usually not needed — dev_watch auto-closes on completion.
Split frontend/backend
If your app runs the frontend and backend on separate ports, passbackendUrl and the MCP spins up a reverse proxy automatically:
Use dev_test on http://localhost:3000 with backend at http://localhost:8080. Goal: “create a new project”.
Custom API paths
/ and be longer than just /.
Authenticated testing
auth supports three modes. All accept an optional startUrl to land the agent on a specific page after authentication.
If mode is omitted, the MCP infers it from which fields you pass:
cookiesarray →cookie_injectionsignupEmail→signup- otherwise →
agent_login
Mode 1: agent_login (username + password)
The agent navigates to loginUrl (or the target URL if omitted), fills the credentials, and submits.
Use dev_test on http://localhost:3000 with goal “edit profile settings”. Auth: username test@example.com, password testpass123, login URL http://localhost:3000/login.
Mode 2: signup (sub-aliased emails per persona)
For testing sign-up flows where no account exists yet. You supply one base email; each persona registers with a unique local+<hash>@domain sub-alias derived from it. All confirmation emails route to your single inbox, but each persona has its own isolated address.
How the alias works:
- The base email
you@yourdomain.combecomesyou+lwk3a8x7@yourdomain.com,you+lwk3a902@yourdomain.com, etc. — one per persona. - The timestamp half guarantees the alias can never be replicated in the future; the random half disambiguates personas spawned in the same millisecond.
- The agent is instructed to type that exact alias verbatim.
- The generated alias is persisted to the test run record (
cua_runs.generated_email) so confirmation emails can be correlated back later.
Use dev_test on http://localhost:3000 with goal “sign up for a free account”. Auth: signup mode, base email you@yourdomain.com.
Mode 3: cookie_injection (skip login entirely)
Inject session cookies and have the agent start already authenticated on a specific page.
name, value, domain at minimum; everything else is optional. The easiest way to capture cookies is the Cookie-Editor browser extension — Export → JSON.
Always set
startUrl for cookie injection. Without it the agent lands on targetUrl (often the login page) and won’t realize it’s already authenticated. The MCP warns about this on stderr, but the agent runs cleaner if you set it explicitly to the post-login destination.Cookie domains captured from a different host (e.g. .production.com) are automatically rewritten to match the tunnel host. Cookie names, values, and other attributes are preserved unchanged.The dev loop
A typical end-to-end prompt:Test my app at localhost:3000. The goal is “complete the checkout flow”. If there are issues, fix them and re-test until it passes.The editor will:
- Call
dev_testwith sensible defaults. - Call
dev_watchand read theissues[]+recommendedActions[]. - Edit code based on those findings.
- Call
dev_testagain to verify. - Loop until
issues[]is empty.
Troubleshooting
”No API key found” when starting
The MCP couldn’t find a key in~/.useswarm/config.json or USESWARM_API_KEY. Run either of these from a terminal and restart your editor:
“API 401: Unauthorized” from a tool call
Your stored key was revoked or your account was logged out elsewhere.dev_status will show auth.valid: false. Fix:
“cloudflared not found”
Install Cloudflare’s tunnel binary — used to expose localhost to Swarm’s cloud agents:Agents see only the frontend (API calls 404)
Your app has a separate backend on another port. Re-run withbackendUrl:
Use dev_test on http://localhost:3000, backend http://localhost:8080, goal ”…”

