opencode-balance-mcp
opencode-balance-mcp
Un servidor MCP (stdio) que expone los datos de tu suscripción de OpenCode como herramientas — tu cuota de Go y tu saldo prepago de Zen — a cualquier cliente compatible con MCP (pi, Claude Desktop, opencode, Cursor y más).
query_go_usage— Cuota de OpenCode Go en ventanas móviles (5h), semanales y mensuales. Obtiene la página/workspace/{id}/goy analiza el payload RSC incrustado.query_zen_balance— Saldo prepago de OpenCode Zen. Obtiene la página del panel del workspace y analiza los escalares SSR de SolidJS incrustados.
Las solicitudes se reintentan con backoff en fallos transitorios (5xx, 429 — respetando Retry-After) y expiran después de 15s.
Cero dependencias. Node.js ≥ 18.
Instalación y ejecución
npx -y opencode-balance-mcp \
--workspace-id wrk_xxx \
--auth-cookie "Fe26.2**..."Related MCP server: kitepass-mcp
Credenciales
El servidor necesita tu ID de workspace de OpenCode y tu cookie de autenticación. Orden de prioridad:
Argumentos CLI:
--workspace-id/--auth-cookieVariables de entorno:
OPENCODE_GO_WORKSPACE_ID/OPENCODE_GO_AUTH_COOKIE
⚠️
authCookiees tu cookie de sesión de OpenCode (empieza conFe26.2**). Caduca — actualízala iniciando sesión en https://opencode.ai → DevTools → Application → Cookies →auth.
Herramientas
query_go_usage
Sin argumentos. Devuelve la cuota de la suscripción Go para las tres ventanas:
{
"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, "...": "..." }
}usagePercentes un entero —0%simplemente significa que se usó menos del 1% del límite de la ventana (5h $12 / semanal $30 / mensual $60). Consulta opencode.ai/docs/go.estSpentUsdLow/Highacotan el gasto estimado para el porcentaje de uso actual.resetsInes una cuenta regresiva legible derivada deresetsInSeconds.
query_zen_balance
Sin argumentos. Lee la página del panel del workspace y analiza el saldo de Zen (datos de hidratación SSR de SolidJS):
{
"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
}balanceRawes un entero en unidades de 1e-8 USD (la misma unidad que usa el cliente del panel:formatBalance = amount / 1e8). Negativo = crédito prepago, positivo = cantidad adeudada.balanceUsd/balanceFormattedse derivan de él; el signo aparece como(crédito)/(adeudado)en la etiqueta.autoReloadrefleja la recarga automática de Zen: cuando el saldo baja detriggerUsd, añadereloadUsd.
No existe una API oficial de saldo de Zen, por lo que el servidor extrae el panel de la misma manera que sondea la cuota de Go. El analizador vive en
src/parse.mjsy puede necesitar actualizaciones si la estructura de la página cambia.
Configurar en clientes MCP
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**..."
}
}
}
}MCP estándar (stdio) — cualquier cliente
{
"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 en la raíz del proyecto)
{
"mcpServers": {
"opencode-balance": {
"command": "npx",
"args": ["-y", "opencode-balance-mcp"],
"env": {
"OPENCODE_GO_WORKSPACE_ID": "wrk_xxx",
"OPENCODE_GO_AUTH_COOKIE": "Fe26.2**..."
}
}
}
}O mediante 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**..."
}
}
}
}Desarrollo
npm start # run the server directly
npm test # unit tests (parser, zen formatting, HTTP retry policy) + a protocol smoke testLa prueba de humo del protocolo (test/test.mjs) lanza el servidor sobre stdio y verifica initialize, tools/list, tools/call y el manejo de errores de tools/call. Sin credenciales, falla esperadamente las dos llamadas a herramientas con un resultado isError.
Arquitectura
src/index.mjs— protocolo MCP stdio, credenciales (CLI/env), pegamento de obtención de páginassrc/http.mjs— política de red: timeout, reintento con backoff, manejo de 429/Retry-Aftersrc/parse.mjs— ayudantes puros de análisis/formateo (sin I/O, probados unitariamente)
Publicación
npm publishLicencia
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It adds value by disclosing that credentials are pre-configured via CLI args or env vars, which prevents unnecessary auth handling. However, it does not mention potential error conditions, whether the action is read-only (though implied by 'query'), or any rate limits. It neither contradicts nor fully discloses behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with no wasted words. The first sentence states purpose and outputs; the second clarifies argument and credential requirements. Information is front-loaded and every word serves a purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter query tool with no output schema, the description covers the essential details: what it returns and that no arguments are needed. It does not specify the exact format of the reset countdown (e.g., seconds, minutes), which could cause minor ambiguity, but overall the tool is simple enough that the description is nearly complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so baseline is 4. The description reinforces this by explicitly stating 'No arguments needed,' which adds clarity beyond the empty schema. Since there are no parameters to document, this is fully adequate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool queries OpenCode Go subscription quota and enumerates specific outputs (usage percent, estimated USD spent, reset countdown). It uses a specific verb 'query' and resource 'Go subscription quota,' making it distinguishable from the sibling tool query_zen_balance.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly states 'No arguments needed' and explains how credentials are provided, which tells the agent it doesn't need to pass authentication. It does not explicitly name the sibling or contrast usage, but the purpose is clear enough that the agent can infer when to use it. Lacks an explicit 'when not to use' but provides sufficient context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden and discloses useful behavioral details: balance units in 1e-8 USD, negative values meaning credit, formatted USD output, and auto-reload settings. It also clarifies credential sourcing, which is important operational behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two efficiently written sentences convey the purpose, output, required arguments, and credential mechanism with no filler. Every clause earns its place and the core subject is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter read-only query tool with no output schema, the description is complete: it names the resource, details the returned data, explains the unit semantics, states no arguments are needed, and tells where credentials come from. Nothing necessary for correct invocation is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are zero parameters and schema coverage is 100%, so the baseline is 4. The description reinforces that no arguments are needed and goes further by explaining how authentication is already handled, which adds meaning beyond the empty schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb (Query), a specific resource (OpenCode Zen prepaid balance), and the scope (pay-as-you-go balance). It lists the exact data returned, which distinguishes it from the sibling query_go_usage without needing to compare schemas.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly states that no arguments are needed and explains how credentials are supplied, which is essential contextual guidance for invoking the tool. It does not explicitly name the sibling as an alternative, but the resource and data scope make the intended use clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
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.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Query OneLens cloud-cost data in natural language: breakdowns, trends, cost centers. Read-only.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Related MCP Servers
- AlicenseAqualityFmaintenanceAn MCP server that retrieves current GitHub Copilot usage data, including quotas, limits, and usage statistics. It allows AI agents to monitor premium interaction status and detailed account usage via raw or formatted summaries.316MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to query Kite Passport user info, sessions, wallet balance, and backend health via read-only MCP tools.MIT
- AlicenseNot gradedqualityDmaintenanceExposes GitHub Copilot premium request usage as an MCP tool, providing a breakdown by model and cost.MIT
- AlicenseAqualityAmaintenanceQueries real-time AI subscription quota for Claude Code Max, Kimi, and Z.ai. Tokens are read from environment variables and never stored.3MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/gralliry/opencode-balance-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server