---
title: "Operate your app with a coding agent"
description: "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."
section: "guides"
status: "Building for 0.4"
spec: "ops-mcp"
canonical: "https://mainsdk.dev/docs/guides/operate-your-app-with-an-agent"
updated: "2026-10-28"
---

# 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.

Status: Building for 0.4 · Canonical: https://mainsdk.dev/docs/guides/operate-your-app-with-an-agent · 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](https://mainsdk.dev/docs/guides/respond-to-attacks-and-pressure)).
- 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
```

```json title=".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

```yaml title="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](https://mainsdk.dev/docs/interfaces/ops), [playbooks](https://mainsdk.dev/docs/interfaces/playbooks), [govern an app agent](https://mainsdk.dev/docs/guides/govern-an-app-agent).
