opencode-balance-mcp
This server is an MCP tool server that exposes your OpenCode subscription data (Go quota and Zen prepaid balance) to any MCP-capable client.
query_go_usage: Fetches OpenCode Go subscription usage across rolling (5h), weekly, and monthly windows, including usage percent, estimated USD spent (low/high), limit, and reset countdown.query_zen_balance: Reads the OpenCode Zen prepaid balance, including raw balance (1e-8 USD units), formatted USD, sign as credit/owed, and auto-reload settings.Credentials: Workspace ID and auth cookie can be supplied via CLI args or environment variables.
Integration: Runs as a stdio MCP server and can be used with opencode, Claude Desktop, Cursor, Claude Code, Codex, pi, and other MCP clients.
Robustness: Requests have timeout, retry with backoff, and handling for transient failures and redirect/auth errors.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@opencode-balance-mcp Check my Go quota and Zen balance."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
opencode-balance-mcp
An MCP server (stdio) that exposes your OpenCode subscription data as tools — your Go quota and your Zen prepaid balance — to any MCP-capable client (pi, Claude Desktop, opencode, Cursor, and more).
query_go_usage— OpenCode Go quota across rolling (5h), weekly, and monthly windows. Fetches the/workspace/{id}/gopage and parses the embedded RSC payload.query_zen_balance— OpenCode Zen prepaid balance. Fetches the workspace dashboard page and parses the embedded SolidJS SSR scalars.
Requests are retried with backoff on transient failures (5xx, 429 — honouring
Retry-After) and time out after 15s.
Zero dependencies. Node.js ≥ 18.
Install & Run
npx -y opencode-balance-mcp \
--workspace-id wrk_xxx \
--auth-cookie "Fe26.2**..."Related MCP server: chatgpt-quota-mcp
Credentials
The server needs your OpenCode workspace ID and auth cookie. Priority order:
CLI args:
--workspace-id/--auth-cookieEnvironment:
OPENCODE_GO_WORKSPACE_ID/OPENCODE_GO_AUTH_COOKIE
⚠️
authCookieis your OpenCode session cookie (starts withFe26.2**). It expires — refresh it by logging into https://opencode.ai → DevTools → Application → Cookies →auth.
Tools
query_go_usage
No arguments. Returns the Go subscription quota for all three windows:
{
"timestamp": "...",
"workspaceId": "wrk_...",
"rolling": { "status": "ok", "usagePercent": 1, "limitUsd": 12, "estSpentUsdLow": 0.12, "estSpentUsdHigh": 0.24, "resetsInSeconds": 8660, "resetsIn": "2h 24m" },
"weekly": { "status": "ok", "usagePercent": 1, "limitUsd": 30, "...": "..." },
"monthly": { "status": "ok", "usagePercent": 0, "limitUsd": 60, "...": "..." }
}usagePercentis an integer —0%simply means less than 1% of the window limit was used (5h $12 / weekly $30 / monthly $60). See opencode.ai/docs/go.estSpentUsdLow/Highbracket the estimated spend for the current usage percent.resetsInis a human-friendly countdown fromresetsInSeconds.
query_zen_balance
No arguments. Reads the workspace dashboard page and parses the Zen balance (SolidJS SSR hydration data):
{
"timestamp": "...",
"workspaceId": "wrk_...",
"plan": "pay-as-you-go",
"balanceRaw": 0,
"balanceUsd": 0,
"balanceFormatted": "$0.00",
"autoReload": { "triggerUsd": 5, "triggerMinUsd": 5, "reloadUsd": 20, "reloadMinUsd": 10 },
"reloadAmount": 20,
"reloadTrigger": 5
}balanceRawis an integer in 1e-8 USD units (the same unit the dashboard client uses:formatBalance = amount / 1e8). Negative = prepaid credit, positive = amount owed.balanceUsd/balanceFormattedare derived from it; the sign shows up as(credit)/(owed)in the label.autoReloadmirrors Zen's auto top-up: when the balance drops belowtriggerUsd, addreloadUsd.
There is no official Zen balance API, so the server scrapes the dashboard the same way it probes Go quota. The parser lives in
src/parse.mjsand may need updating if the page structure changes.
Configure in MCP clients
opencode (~/.config/opencode/opencode.json)
{
"mcp": {
"opencode-balance": {
"type": "local",
"command": ["npx", "-y", "opencode-balance-mcp"],
"environment": {
"OPENCODE_GO_WORKSPACE_ID": "wrk_xxx",
"OPENCODE_GO_AUTH_COOKIE": "Fe26.2**..."
}
}
}
}Standard MCP (stdio) — any client
{
"mcpServers": {
"opencode-balance": {
"command": "npx",
"args": ["-y", "opencode-balance-mcp"],
"env": {
"OPENCODE_GO_WORKSPACE_ID": "wrk_xxx",
"OPENCODE_GO_AUTH_COOKIE": "Fe26.2**..."
}
}
}
}Claude Code (.mcp.json at project root)
{
"mcpServers": {
"opencode-balance": {
"command": "npx",
"args": ["-y", "opencode-balance-mcp"],
"env": {
"OPENCODE_GO_WORKSPACE_ID": "wrk_xxx",
"OPENCODE_GO_AUTH_COOKIE": "Fe26.2**..."
}
}
}
}Or via CLI: claude mcp add opencode-balance -e OPENCODE_GO_WORKSPACE_ID=wrk_xxx -e OPENCODE_GO_AUTH_COOKIE="Fe26.2**..." -- npx -y opencode-balance-mcp
Codex (~/.codex/config.toml)
[mcp_servers.opencode-balance]
command = "npx"
args = ["-y", "opencode-balance-mcp"]
enabled = true
[mcp_servers.opencode-balance.env]
OPENCODE_GO_WORKSPACE_ID = "wrk_xxx"
OPENCODE_GO_AUTH_COOKIE = "Fe26.2**..."pi (~/.pi/agent/mcp.json)
{
"mcpServers": {
"opencode-balance": {
"command": "npx",
"args": ["-y", "opencode-balance-mcp"],
"env": {
"OPENCODE_GO_WORKSPACE_ID": "wrk_xxx",
"OPENCODE_GO_AUTH_COOKIE": "Fe26.2**..."
}
}
}
}Development
npm start # run the server directly
npm test # unit tests (parser, zen formatting, HTTP retry policy) + a protocol smoke testThe protocol smoke test (test/test.mjs) launches the server over stdio and verifies
initialize, tools/list, tools/call, and
tools/call error handling. Without credentials it expectedly fails the two tool calls with
an isError result.
Architecture
src/index.mjs— entry point: CLI/env credentials, wiring, startupsrc/mcp.mjs— MCP stdio protocol layer + tool implementationssrc/http.mjs— HTTP layer: timeout, retry-with-backoff, redirect/auth error handlingsrc/parse.mjs— pure parsing/formatting helpers (no I/O, unit-tested directly)
Publish
npm publishLicense
MIT
Available Tools
2 toolsquery_go_usageA
Query OpenCode Go subscription quota: rolling (5h) / weekly / monthly usage percent, estimated USD spent and reset countdown. No arguments needed; credentials are provided at startup via CLI args (--workspace-id / --auth-cookie) or env vars.
Inputs: no named parameters.
query_zen_balanceA
Query OpenCode Zen prepaid balance (pay-as-you-go): balance in 1e-8 USD units (negative = credit), formatted USD, and auto-reload settings. No arguments needed; credentials are provided at startup via CLI args (--workspace-id / --auth-cookie) or env vars.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools query distinct resources: one for Go subscription quota and one for Zen prepaid balance. Their descriptions clearly differentiate the data returned (usage percentages vs. balance in USD units), making confusion unlikely.
Both tool names follow the exact same pattern: 'query_' prefix followed by the resource type ('go_usage' and 'zen_balance'). This is fully consistent and predictable.
With only two tools, the surface is minimal, but the server's scope is narrowly defined as querying two distinct balance types. The count feels appropriate given the focused purpose, though slightly thin if broadenability was expected.
The server covers the two core balance query operations for its domain. Missing a combined query or historical data are minor gaps that agents can work around, but the essential read operations are present.
Related MCP Connectors
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
Read-only AI/LLM cost tools with current MCP discovery and attributable Registry transport.
Paid MCP tools behind one endpoint. Agents pay per call in USDC on Base via x402.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceExposes rate-limit and usage data for AI coding agent CLIs as MCP tools, enabling querying of usage snapshots and reset times.MIT
- FlicenseAqualityDmaintenanceMCP server that exposes a single tool to retrieve ChatGPT/Codex quota via the signed-in Codex CLI, reporting rate-limit windows and usage percentages.1-
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code sessions to check account rate-limit headroom, local token spend, and live session status, with read-only MCP tools for limits, summaries, token usage, and session listing.2MIT

Apitaco MCP Serverofficial
AlicenseAqualityCmaintenanceExposes three MCP tools that let Claude Desktop, Cursor, Claude Code, and Cline query an account's current balance in USD, retrieve token and cost usage statistics for the last N days, and list supported models with per-million-token pricing. Answers questions like "How much have I spent in the last 30 days?" by calling those tools directly from any MCP-compatible client.3MIT