Reference

The Duscode API and MCP server

Hand Dus a job from another tool: the versioned Duscode API (start, follow, prove, cancel), scoped API tokens, Prometheus metrics, and Duscode as an MCP server for Claude Code, Codex and Cursor.

Other tools can hand Dus work. A CI script, your own dashboard or another AI agent can start an engineering job. Dus builds it, commits, pushes, opens the pull request, checks it with its own CI and merges it under your project's merge rule, within the budget. The tool can then follow the job and fetch the evidence.

There are two ways in:

  • The Duscode API. This is versioned HTTP on the Duscode server, under /api/v1. The OpenAPI document describes it, and your server also serves it at /api/v1/openapi.json.
  • duscode mcp. This makes Duscode an MCP server, so Claude Code, Codex, Cursor or any MCP client can call start_job, job_status and get_proof.

Both use an API token.

API tokens

To create one, go to Settings → Apps & connectors → API & MCP → New token. A token carries exactly what you give it, nothing more:

You choose What it means
Projects The projects it may work on. You always name them: no token covers every project.
What it may do jobs:start, jobs:read, jobs:cancel, insights:read, metrics:read
Its jobs run under The job profiles its jobs may use. A job started with a token always runs under one of them, in its own copy of the project. It never runs in a task you have open.
How long it lasts 90 days by default, up to 365.

The token appears once, when you create it. Duscode stores only a fingerprint of it (a SHA-256 hash). If you lose a token, revoke it and create a new one.

Revoke stops a token at once. Every use of a token is written to an audit log, kept in the Duscode data folder (api/audit.jsonl), and so is every refused use. Each line records which token, what it did, on which project and job, and whether it worked. The log never holds the token itself or what was sent.

Send the token in a header:

Authorization: Bearer dsk_…

Tokens never go in the URL, because URLs end up in logs.

Endpoints

Method and path Needs What it does
GET /api/v1 nothing The version, and where the OpenAPI document is
GET /api/v1/openapi.json nothing The OpenAPI 3.1 document
GET /api/v1/projects a token The projects this token may work on
GET /api/v1/jobs?project= jobs:read Jobs, newest first
POST /api/v1/jobs jobs:start Start a job: { "objective", "project"?, "profile"?, "budgetUsd"?, "title"? }
GET /api/v1/jobs/{id} jobs:read One job: its status, step, the reason in one line, money spent, and whether it waits on you
GET /api/v1/jobs/{id}/events jobs:read Follow the job as Server-Sent Events (below)
GET /api/v1/jobs/{id}/proof jobs:read Its Proof of Work: each side effect with its receipt, and the Proof of Work of the tasks that did the work
POST /api/v1/jobs/{id}/cancel jobs:cancel Stop it
GET /api/v1/insights?days=&project= insights:read Outcome insights: cost per verified merged change and per healthy deploy, merge, rollback and revert rates, time to merge, and how much of your attention the work needed

project and profile can be left out when the token allows exactly one of each.

Errors come back as { "error": "…", "code": "unauthorized" | "forbidden" | "not_found" | "bad_request" | "conflict" }.

Start a job:

bash
curl -s http://127.0.0.1:4317/api/v1/jobs \
  -H "Authorization: Bearer $DUSCODE_API_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"objective":"Add a CSV export to the orders page","budgetUsd":3}'

Following a job

GET /api/v1/jobs/{id}/events sends Server-Sent Events:

  1. job.snapshot comes first.
  2. Then come job.updated (status, step or reason changed) and job.effect (a side effect recorded, with its evidence and cost).
  3. job.finished arrives when the job merges or is cancelled. Then the stream ends.

Each event's id is its sequence number. To skip what you already have after a reconnect, add ?after=<id>.

Duscode as an MCP server

duscode mcp speaks MCP over stdio. It holds only the token you give it, and the token bounds what the other agent can do. A start under a profile the token doesn't allow comes back to that agent as a tool error it can read.

Claude Code:

bash
claude mcp add duscode --env DUSCODE_API_TOKEN=dsk_… -- duscode mcp

Any MCP client (Codex, Cursor and others) takes the same command and environment:

json
{ "mcpServers": { "duscode": { "command": "duscode", "args": ["mcp"], "env": { "DUSCODE_API_TOKEN": "dsk_…" } } } }
Tool Arguments Returns
start_job objective, project?, profile?, budget_usd? The job, queued or running
job_status job_id, project?, wait_seconds? (up to 120) Where the job is. It can wait for the job to change.
get_proof job_id, project? Its receipts and Proof of Work

Duscode on another port: set DUSCODE_PORT. A team server over HTTPS: set DUSCODE_API_URL=https://…. Plain http:// is accepted only for this computer.

Prometheus metrics

You can turn on Settings → Apps & connectors → Prometheus metrics. This works on your own computer, a team server and an always-on runner. Scrape /metrics with a token that has metrics:read:

yaml
scrape_configs:
  - job_name: duscode
    authorization: { credentials: dsk_… }
    static_configs: [{ targets: ['127.0.0.1:4317'] }]

It exports counts only:

  • jobs by state, and jobs waiting on you;
  • money spent on jobs;
  • open Watch incidents;
  • spend today;
  • whether the server is a runner;
  • the version and start time.

No label carries a project, a person, an objective or code.

Signed webhooks

To have Duscode post events to your own URL, see Webhooks.

Something missing or wrong? Email support@duscode.com.