Spend Guard

v0.2.0
io.github.vulinh1704/spend-guard Checked 2 days ago Published 1 month ago

Budgets, payee allowlists, price-spike checks and human approval for agents paying x402 paywalls

Values you need

VariableWhat it is
SPEND_GUARD_POLICYoptional Policy JSON file: networks, budgets, approval amount, spike ratio, known services and their payees. Without one, every payment waits for your approval.
SPEND_GUARD_RAILSoptional How to pay: mock (pays nothing), near, arc, gateway, or a comma list. arc and gateway need ARC_PRIVATE_KEY, near needs NEAR_ACCOUNT_ID and NEAR_PRIVATE_KEY. Default: mock
SPEND_GUARD_LEDGERoptional Decisions file, read back on start so a restart keeps today's spend; servers on one file share one budget. Default ~/.spend-guard/ledger.jsonl; off keeps it in memory.
SPEND_GUARD_DASHBOARD_PORToptional Port of the approval dashboard on 127.0.0.1. 0 picks a free one; off means no dashboard, and payments that need approval are declined. Default: 4400
SPEND_GUARD_APPROVAL_TIMEOUToptional Seconds a payment waits for your answer before it is declined. Raise it together with your client's tool timeout. Default: 55
SPEND_GUARD_MOCK_NETWORKoptional Network the mock rail pretends to pay on. Default: near-testnet
ARC_PRIVATE_KEYoptional secret Agent key for the arc and gateway rails. Testnet keys only.
NEAR_ACCOUNT_IDoptional Agent account for the near rail (testnet).
NEAR_PRIVATE_KEYoptional secret Agent key for the near rail. Testnet keys only.

npm (npx) discovery passed

Requires Node.js 18+

Run in a terminal
claude mcp add spend-guard -- npx -y @vulinh1704/spend-guard@0.2.0 mcp
Add to claude_desktop_config.json
{
  "mcpServers": {
    "spend-guard": {
      "args": [
        "-y",
        "@vulinh1704/spend-guard@0.2.0",
        "mcp"
      ],
      "command": "npx"
    }
  }
}
Add to ~/.cursor/mcp.json
{
  "mcpServers": {
    "spend-guard": {
      "args": [
        "-y",
        "@vulinh1704/spend-guard@0.2.0",
        "mcp"
      ],
      "command": "npx"
    }
  }
}
Add to .vscode/mcp.json
{
  "servers": {
    "spend-guard": {
      "args": [
        "-y",
        "@vulinh1704/spend-guard@0.2.0",
        "mcp"
      ],
      "command": "npx",
      "type": "stdio"
    }
  }
}
Add to ~/.codex/config.toml
[mcp_servers.spend-guard]
command = "npx"
args = ["-y", "@vulinh1704/spend-guard@0.2.0", "mcp"]

For AI agents

  1. Pick the user's MCP client and apply the matching config from the first install method (it is the one verified by the smoke test when available).
  2. Restart or reload the client so it starts the server.
  3. Verify: the server should expose these tools: pay_and_fetch, spending_status, spending_policy.
  4. If it fails, check that the required runtime is installed (Node.js 18+) and that the values above are set.

Machine-readable: install.md · manifest.json