MainSDK
Search⌘K
How-to

Operate your app with a coding agent

Let Claude Code or another MCP client ask your running app how it is and what a playbook would do, with every change waiting for you.

Building for 0.4

Status Status is where the work is: Planned (in a milestone, not started), Building (tickets in progress), Preview (usable, may change), then the stability it ships at.

Stability The promise an interface ships with.

  • Stable Follows semantic versioning; breaking changes need a new major, 12 months of overlap and a codemod.
  • Beta Usable in production; may change before it becomes stable.
  • Experimental May change or go away; needs an explicit opt-in in main.yaml.
Stability levels
Updated 2026-10-28

You will start your app in dev, connect a coding agent to its ops tools, ask what a playbook would do, and approve a run yourself. It takes about 15 minutes.

You need

  • A MainSDK app with playbooks declared (see respond to an attack).
  • A coding agent that speaks MCP: Claude Code, Cursor or Gemini CLI.

1. Start the app

bash
npx mainsdk dev

The ops socket is on by default in dev and off elsewhere. mainsdk init already wrote a mainsdk-ops entry in your agent's project MCP file; in an older project add it by hand:

To run the server by hand, for example to test it from a terminal:

bash
npx mainsdk ops mcp
.mcp.json
{ "mcpServers": { "mainsdk-ops": { "command": "npx", "args": ["mainsdk", "ops", "mcp"] } } }

2. Ask

Tell the agent: "How is the app? What would the pressure.slim playbook do right now?" It calls ops.status and ops.plan. Nothing changes: the plan is a dry run.

3. Let it ask for a run

The agent can call ops.run with a rule and a reason. The run waits. Your client may show the plan and ask you to confirm; that answer is only recorded. To let the run happen:

bash
npx mainsdk playbooks approve <run>

An agent that tries to approve gets MAIN-AGENT-0003. With ops.mcp.write: off the two write tools are unavailable and answer MAIN-OPS-0004.

4. Keep it in budget

main.yaml
agents:
  ops: { budget: { calls: 500/day } }

Every call acts as the app agent ops, so its budget, kill switch and audit apply. When the budget is spent, tools answer MAIN-OPS-0006 until the period resets.

Related: ops server, playbooks, govern an app agent.

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet