# set_budget

URL: https://codepanel.ai/docs/mcp-server/set_budget

The CodePanel MCP tool that sets your account's monthly budget or a repository's cap, on own-key spend, and returns the limits before and after.

`set_budget` changes the account's monthly budget, a repository's own monthly cap, or both, and returns the limits before and after. It is how an agent raises or lowers what reviews may spend on your own provider keys. It needs the `budget:write` scope, which no other scope includes, so a token that only reviews cannot raise its own limit.

## When to call it

- **After a refusal that a person approved raising:** a budget or cap stopped a round and you were told to raise it. Raise a limit only when your user asked for it.
- **To keep one busy repository from using the whole budget:** give it a `capUsd`.
- **To undo your own change:** pass the old value from `before`.

A repository cap is checked as well as the account budget, not instead of it. Neither changes plans, credits or the per-pull-request limit.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `monthlyUsd` | number or `"default"` or null | no |  |
| `repo` | string | no | Repository as owner/name |
| `capUsd` | number or null | no | The repository's own cap; needs repo |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

Give `monthlyUsd`, or `repo` with `capUsd`, or both. `monthlyUsd` is a positive amount in USD, `"default"` for the $25 default, or `null` for no budget. `capUsd` is a positive amount, or `null` to remove the cap so only the account budget applies. `capUsd` without `repo` is refused:

```text
CodePanel: capUsd needs repo: the repository whose cap to set.
```

With neither limit, the answer is `CodePanel: Nothing to change: pass monthlyUsd, or repo and capUsd.` A zero, negative or non-numeric amount is a `400`.

## What it returns

`before` and `after`, each in the shape of [`get_budget`](/docs/mcp-server/get_budget), and `changed`: `["account"]`, `["repo"]` or both. Both are counted from the same spend, so they differ only in the limits.

## Examples

These responses come from a test account on a local backend.

### Raise the account budget

```json title="Call"
{ "monthlyUsd": 40 }
```

```json title="Result"
{
  "after": {
    "account": {
      "heldUsd": 0,
      "limitUsd": 40,
      "remainingUsd": 38.250275,
      "source": "custom",
      "spentUsd": 1.7497250000000002,
      "status": "open"
    },
    "enforced": true,
    "month": "2026-11"
  },
  "before": {
    "account": {
      "heldUsd": 0,
      "limitUsd": 25,
      "remainingUsd": 23.250275,
      "source": "default",
      "spentUsd": 1.7497250000000002,
      "status": "open"
    },
    "enforced": true,
    "month": "2026-11"
  },
  "changed": [
    "account"
  ]
}
```

`source` moved from `default` to `custom`. Without `repo` the answer has no `repo` block.

### Cap one repository

```json title="Call"
{ "repo": "codepanel-dev/web-app", "capUsd": 15 }
```

```json title="Result (the account blocks are left out)"
{
  "after": {
    "repo": {
      "capUsd": 15,
      "heldUsd": 0,
      "remainingUsd": 14.0606625,
      "repo": "codepanel-dev/web-app",
      "review": {
        "limitedBy": "repo",
        "refusal": null,
        "remainingUsd": 14.0606625,
        "status": "open"
      },
      "spentUsd": 0.9393375000000003,
      "status": "open"
    }
  },
  "before": {
    "repo": {
      "capUsd": null,
      "heldUsd": 0,
      "remainingUsd": null,
      "repo": "codepanel-dev/web-app",
      "review": {
        "limitedBy": "account",
        "refusal": null,
        "remainingUsd": 38.250275,
        "status": "open"
      },
      "spentUsd": 0.9393375000000003,
      "status": "unlimited"
    }
  },
  "changed": [
    "repo"
  ]
}
```

`account`, `enforced` and `month` inside `before` and `after` are left out; they did not change. `review.limitedBy` moved from `account` to `repo`, because the cap now leaves less room than the budget.

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel budget set --monthly 50` and `codepanel budget set --repo owner/name --cap 20` (`--monthly default\|none`, `--cap none`) ([CLI](/docs/cli)) |
| HTTP API | [`POST /budget`](/docs/api#post-budget) with `monthlyUsd`, `repo` and `capUsd` |

A person can also set both in the dashboard, under **Settings → Budget** and a repository's **Spend & budget** tab.

## What the server tells your agent

The description your agent reads when it lists the tools:

> Set the account's monthly budget (monthlyUsd: an amount in USD, "default" for the $25 default, or null for no budget) and/or a repository's own monthly cap (repo with capUsd: an amount, or null to remove it so only the account budget applies). A repo cap is checked as well as the account budget, not instead of it. Counts only spend on your own provider keys; plans and credits are not changed. Returns the state before and after, as get_budget.

## Related

- [`get_budget`](/docs/mcp-server/get_budget): read the limits first.
- [`get_auto_reload`](/docs/mcp-server/get_auto_reload) and [`set_credits_first`](/docs/mcp-server/set_credits_first): the credits side of spending.
- [Budgets and spending limits](/docs/budgets-and-limits#set-the-limits): where each limit is set.
- [Scopes](/docs/mcp-server#scopes): what `budget:write` allows.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
