MainworthyDocs Open Mainworthy

Let an agent in

Give an AI agent its own token and connect it over Model Context Protocol (MCP). The agent can then read cases, review changes, and report results. The project's policy sets who answers each kind of question and which answers count.

An agent's session, from token to a person's decision. Zoom, search and follow a path in the frame, or open it full screen.

Make a token for the agent #

Create a token for the agent so every record it creates names the agent as its actor.

$ mainworthy token new --agent reviewer --can read,produce --project scratch
token for agent "reviewer" (read, record, produce)
<token>
Shown once. It will not be shown again.

An agent gets read and produce by default. These are capabilities on the project.

  • read lets the agent see cases, results, questions, and the gate.
  • produce lets the agent write and edit cases, report results, review, and send answers. It includes record, which lets the agent report results and attachments. Mainworthy still refuses an agent's report that a change ended or that a deployment happened.
  • answer lets an answer count where the policy asks a project member. Without it, the policy records the agent's answer as advice or refuses it. Add answer only where you want the agent's answer to count.

For a new agent, --project scratch gives it its first grant, a list of capabilities, on scratch. A token for an existing agent uses the agent's current grants across all projects. Before you reuse an agent's name, check mainworthy actor list. Adding or removing a grant changes access for every token of that agent. See People, agents and pipelines for grants and revocation.

Warning

In local mode with no proxy named, a client on the same machine that sends no token acts as the owner. An agent without its own token makes edits as a person, and the policy treats them that way. Always give the agent a token.

Connect over MCP #

Mainworthy supports MCP protocol 2026-07-28 with the v2 TypeScript SDK, and retains support for 2025-11-25 clients. Choose either standard input and output or HTTP to connect the agent.

For standard input and output, configure the MCP client as follows. The server must be running because mainworthy mcp forwards each call to the server.

  1. Set the client's command to mainworthy.
  2. Set its argument to mcp.
  3. Set the server address, agent token, and project in the client's environment:
MAINWORTHY_URL=http://127.0.0.1:7357
MAINWORTHY_TOKEN=<token>
MAINWORTHY_PROJECT=scratch

The configuration file depends on the MCP client.

For HTTP, send MCP requests to the server's /mcp address, such as http://127.0.0.1:7357/mcp. Include the header Authorization: Bearer <token>. The endpoint accepts only POST. Each request stands alone, with no session to open or close. A request body can be up to 4 MiB. For a bigger report, use the command line.

A 2026-07-28 client uses server/discover to learn what the server supports and skips the initialization handshake. It sends the protocol and client metadata in _meta. Over HTTP, send Mcp-Method with the request's JSON-RPC method. Without that header, the server returns HTTP 400 with error code -32020. For tool calls, the SDK sends Mcp-Method, MCP-Protocol-Version, and Mcp-Name.

A 2025-11-25 client keeps its initialize handshake and gets the same tools and replies. Clients on 2025-06-18 or later receive output schemas and structured replies. A 2025-03-26 client receives text replies and tool definitions without output schemas.

To find your server's /mcp address, open Connect in Settings.

If the agent can access more than one project, name one. Every tool takes a project field. The standard input and output connection also reads MAINWORTHY_PROJECT and --project. With exactly one accessible project, the agent can leave it out.

The tools and where to start #

Five of the ten tools read data.

  • impact takes a change such as pr:482 or a list of changed files. It returns affected cases, the reasons they are affected, prior reviews, open questions, and uncovered files.
  • inbox lists the open questions with their evidence.
  • get reads cases, questions, runs and tests by ref. It also returns the full gate for commit:<hash>, change:<key>, or a run ref such as R-2. It includes passed, failed, blocked, or pending, the reason, counts, and open questions. repo disambiguates a commit reported in several repositories.
  • find searches.
  • since returns what changed after a cursor.

The other five tools write data.

  • work takes, renews, or gives back a lease on a planned run slot. The lease marks a slot as assigned to you for a limited time.
  • propose creates or changes cases.
  • claim records a review and its findings, or the cause of a failed result.
  • report records results.
  • decide answers a question.

Start with impact to find the relevant cases without reading the whole suite. Each reply holds at most 200 cases. When next is not null, pass it as cursor with the same change, files, since, and ledger inputs. Read every page before saving the final reply's cursor for the next review's since. Until you reach the last page, the reply keeps your original since value as its cursor, or uses s:0 if you supplied none. If you stop early, the next review still includes the unread cases.

Counts cover all matching cases. Unreviewed cases come first, then cases sort by number within each group. Mainworthy checks every accepted path, up to 5,000. The counts.uncovered field counts all paths without a case, and uncovered lists the first 50. To read the next page, use the same caller, project, and inputs. If a project write occurs between pages, the server returns a conflict. Restart without cursor and keep the original since. Finish reading pages before recording reviews.

The CLI prints next and cursor in its JSON output. Use mainworthy impact --change pr:482 --cursor '<next>' for the following page, repeating any other input flags. API and agent tools lists every tool's inputs.

To record a change review, follow these steps.

  1. Before reading the patch, copy the commit from impact's change.head.
  2. Set claim's about to the change key.
  3. Set patch to the copied commit.
  4. Set reviewed to the case refs and hashes you read.
  5. Send the claim request.

For example, send about: "pr:482", patch: "cccc0001", and reviewed: ["C-1@<hash>"]. Keep the original patch value if another commit arrives while you are reviewing.

impact marks a case reviewed only when this caller reviewed the same case version, change key, and commit. A different change starts unreviewed, even at the same commit. A new commit needs another review, even if the case text is unchanged. Passing since still returns those affected cases when the change moves. With an unchanged change, it returns only cases that moved or are failing. Reviews without about and patch remain recorded but cannot cover a change. A files-only impact request has no known head and cannot reuse reviews. The review stays current while its change key, commit, and case version stay the same. To request a review without prior review filtering, use ledger: false.

Say why a failure happened #

When you fix a failing test, record why it failed with claim. Send failures, one entry for each failed result you fixed. Use find --in results to look up each ID in the result field. For the assessment's result, prefix the ID with result:, as in result:812. Set cause to defect for a product issue, test for a test issue, flaky for an intermittent failure, or infra for a runner or service failure. Use note to describe what failed and what fixed it. If a commit made the test pass, name it in fix.

{"failures": [{"result": "result:812", "cause": "test", "note": "The assertion read last week's price.", "fix": "4f1c2ab"}]}

Mainworthy records an assessment alongside any answer to the failure question. An assessment opens and answers no questions. A flaky or infra assessment leaves the failure and the gate unchanged. If the policy answered the failure question automatically, that answer stays in effect.

In get result:812, assessments lists the latest ten assessments, oldest first. Each entry names who recorded it, whether that was a person or an agent, and the server's time. The assessmentCount field counts them all. Assessments stay on the result after a later commit passes.

Mainworthy accepts only failed results from the same project. If it refuses any result in the request, it records no assessments from that request. If the same caller sends an identical assessment again, the reply says recorded: false. A different assessment stays alongside the first.

Install the skill #

A skill is a short guide that an agent loads when it needs it. Mainworthy ships one in a directory named mainworthy. It has a SKILL.md and a references folder with pages on writing cases, reviewing a change, reporting results, and tool inputs. The skill describes the case model and the order of work. The agent starts with impact, reads the cases it needs, records findings in one claim, and reports outcomes in one report. It answers a question using the evidence hash it read.

The instance serves an archive of the mainworthy skill directory at /docs/skill/mainworthy.tar.gz. The archive needs no token.

To install the skill for Claude Code, follow these steps.

  1. Choose ~/.claude/skills for every project, or .claude/skills inside one project.
  2. Create the skills directory.
  3. Download the archive.
  4. Unpack the archive into that directory.

For example, these commands install the skill for every project:

$ mkdir -p ~/.claude/skills
$ curl -fsS "$MAINWORTHY_URL/docs/skill/mainworthy.tar.gz" | tar -xz -C ~/.claude/skills

The skill matches the instance version. After an upgrade, unpack the skill again. For other agents, use the skills directory that the agent reads as the tar destination. The same files are in the Mainworthy source tree at skill/mainworthy.

A proposal accepts up to 200 input edits. An edit that updates a fragment can change more cases than the number of edits you sent. The review lists those case changes across pages. Each proposal also has a limit of 5,000 case targets. Every case reference in a placement, state, or fragment edit counts toward the limit, including repeats. If one edit names more than 5,000 cases, split it into smaller edits first.

The MCP propose tool and CLI propose command split larger edit lists automatically. In a split reply, result.proposals in MCP or proposals in CLI JSON lists the replies in input order. Each reply has ok: true with a proposal result or ok: false with an error. Check every reply. Each proposal applies in full or changes nothing. A refusal or a wait for review leaves later proposals free to apply. If a change depends on another proposal, wait for that proposal to take effect first.

HTTP propose accepts one proposal. For larger HTTP requests, send separate proposals of up to 200 edits each. When you accept a pending proposal from before the limit changed or from a restored archive, Mainworthy applies the same limit of 200 input edits. If the proposal is too large, reject it and resubmit the original list through the CLI or MCP so it can split the edits. You can still see the old proposal in history. Mainworthy also refuses stored proposals with invalid input or more resolved edits than their input allows.

One MCP call accepts up to 5,000 input edits and 5,000 case targets. Split larger sets across calls. The CLI also splits at the case-target limit. To retry a CLI or MCP submission safely, supply cmd. Mainworthy derives a stable command ID for each part from the root cmd. The split reply includes that root ID, whether you supplied it or Mainworthy generated it.

If a connection error loses a receipt, the reply includes all earlier receipts and an error for the part whose outcome is unknown. It stops before sending later parts and gives their count in remaining. To recover the recorded receipts and resume, send the complete edit list again with the same root command ID.

For case-file imports, use import --format csv --cmd <id>. The command also supports TestRail and Qase. A large import without --cmd prints a generated command ID before writing. Keep it for retries with the same file and options. Large bulk-move Undo actions also split the edits that reverse the move and keep a stable command ID for each part. If parts wait for review, the reply names each pending question. Parts that already took effect stay in place.

What agent work is worth #

See policy for what each preset allows.

An ordinary case edit that an agent proposes takes effect at once under loose. Under standard and strict, the reply is open and a person decides. Policy edits and quarantine proposals need a person's decision under every preset. If you edit an older case version, Mainworthy returns conflict with the case, the edited version (base), and the current version (head). Read the current case and send the edit again on head.

Mainworthy records and shows findings from a review. A person accepts, rejects, defers, or marks each finding as a duplicate. In the web queue, accepting a finding with a suggestion turns the suggestion into a proposed edit. The agent is the edit's author, and the policy applies to the edit. A finding never changes a gate by itself.

A finding can suggest a step edit with suggest: { step, action, expected }, or a new case with suggest: { case: { title, folder, steps } }. For a new case, folder is optional and each step is an outline line, such as Remove the coupon > Total shows $100.00. The claim keeps this content for acceptance. Through the API, use decide with answer: { is: "accept", apply: true } to turn the suggestion into a proposal.

Mainworthy records and shows an agent's result. Include the model in the report to distinguish sessions from the same agent. An agent's failure can raise a question. See which results count toward a commit gate.

The reply to decide gives the status of the agent's answer. decided means the answer counts. advised means Mainworthy records the answer as advice and a person decides. forbidden means the policy refuses the answer. With the default grant of read and produce, an agent's failure answer is advised under loose and standard and forbidden under strict:

[{"q":"Q-19","status":"advised","needs":"one member who is not an agent","decision":null}]

An answer counts only if the agent holds answer and the policy clause lets agents answer. The presets allow agents to settle duplicate findings under loose. Under loose and standard, agents can settle unlinked-test questions. That permission applies only when the project asks about tests with no case.

Share a run without repeating work #

Before working, call the MCP work tool with {"do":"take","run":"R-2"}. The server chooses the next free, unfinished slot whose run and pinned case accept your method. Several agents asking together get different slots. A null slot means none is available. Before you start, use find to look up the slot and read the case version named there. To take or renew a named slot, include its numeric slot id. If someone else holds the lease, Mainworthy refuses your request and names the holder and deadline. The default lease is 900 seconds. You can request seconds from 30 to 86400. The server supplies both timestamps.

Report results with report. Any qualifying result ends the slot's lease, even from another producer. A lease does not reserve the right to report evidence. If you stop without reporting, send {"do":"give-back","run":"R-2","slot":123}. After a lease expires, the slot stops showing as in progress and another agent can take it. You can take slots only in open planned runs. Closing a run ends its leases.

The MCP tool list has ten tools. gate remains an HTTP operation and CLI command. If your MCP client used the former gate tool, update it to use get.

Name the model behind results #

Send model once on the report, alongside run or target and results:

{
    "run": "R-4",
    "model": "claude-opus-5-5",
    "results": [{ "test": { "case": "C-1" }, "outcome": "pass" }]
}

The HTTP API, CLI JSON input and MCP report tool accept the same field. The name is optional, trimmed, and must contain 1 to 120 characters after trimming. Only an agent token can name a model. A person's or pipeline's report with model is refused with "Only an agent's report can name a model."

Each result keeps the report's model beside its producer. Later reports from the same token can name a different model. An omitted model reads as null, meaning the agent did not say which model it used. The server records the model name the agent supplies without verifying it. The name leaves the gate's count unchanged.

Which results count toward a commit gate #

A commit gate counts results from people and pipelines. If only an agent has reported a commit, its gate reads pending with nothing counted:

$ mainworthy get commit:3333333333333333333333333333333333333333 --json

If an agent reports a failure, a person can read the evidence and answer the question. An agent's report cannot name a branch or a pull request for a commit or move a change's head. If only an agent reported the failure, the question stays open for a person to answer, even if a pipeline later reports a pass.

Runs that ask for agents #

To count an agent's result, allow the agent method on both the case and the planned run.

  1. Open the case.
  2. Under "Can be exercised by", tick Agent. The Markdown equivalent is methods: [human, agent].
  3. On the CLI or through the API, plan the run with a requirement that names the agent method.
$ mainworthy plan --json '{"name":"Agent smoke","select":{"cases":["C-2"]},"require":[{"id":"exercise","kind":"exercise","methods":["human","agent"],"minActors":1,"basis":"exact-or-assumed"}]}'
{
  "run": "R-2",
  "slots": 1,
  "already": 0
}

The web planner does not offer this requirement yet, so use the command line or the API. After planning the run, have the agent report to it with run set to R-2. Its pass fills the slot, and get with refs: ["R-2"] returns gate.verdict: "passed". A run that does not name the agent method ignores agent results, even on a case that admits agents.

Skip unchanged case documents #

Each case from get includes an etag for the returned document. Pass it back in unless, keyed by case ref, with the same as and fields to skip a document you already have. Any change to a returned field changes the etag, including metadata and requested proof in a data reply. For a Markdown reply, the etag covers the Markdown document. The separate hash still identifies the version's body for claim.reviewed. Old clients that send body hashes in unless receive full documents.

See also #

When you report a pass, use results[].steps to record what you observed at each step. Give each step its stable case step ID and outcome. You can also record its duration in milliseconds and the actions you took. Each action has text and can include an outcome and duration. For a step from a fragment, use its occurrence ID, such as a1.b2. The get reply and the result details show the same trail. See step trails and their limits.

Mainworthy 0.1.0 · Licence · this page is docs/guide/agents.md in the repository