MCP Budget
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP SpendShield
Node.js/TypeScript cost tracking and daily budget enforcement for MCP tool handlers. Tracks explicit USD costs and token usage, estimates missing usage, and applies global, per-tool, and per-client daily limits.
Install
npm install mcp-spendshieldRelated MCP server: Expense-Tracker-MCP-Server
Quick start
import { createMCPSpendShield } from "mcp-spendshield";
const spend = createMCPSpendShield({
maxDailyUsd: 25,
maxPerToolUsd: { deep_research: 5, image_generation: 8 },
maxPerClientUsd: 10,
mode: "block",
estimatedUsdPerToken: 0.000002,
});
const budgetedSearch = spend.wrapToolHandler(
async (args: { query: string }) => providerSearch(args.query),
"deep_research",
);
// Register budgetedSearch as the MCP tool handler.
const snapshot = spend.status();
console.log(snapshot);The wrapper reads cost_usd, total_cost_usd, or cost from the result, then token usage from a usage object. When usage is missing it calls costEstimator, or estimates from serialized result length. Client identity is derived from the Bearer token or context.clientId, then SHA-256 hashed. Supply clientIdResolver when your transport has a trusted client identity.
Configuration
Option | Default | Description |
| unset | Global daily USD ceiling. |
|
| Daily ceiling by tool name. |
| unset | Daily ceiling per client. |
|
|
|
|
| Fallback token price. |
| unset | Custom function returning estimated USD cost. |
| automatic | Resolve a trusted client identifier from handler context. |
| console | Structured budget event callback. |
Operational note: costs are measured after a tool returns. Block mode withholds the result after execution; it cannot undo side effects or guarantee a pre-execution spend cap. Counters are in-memory and process-local, reset at UTC midnight, and do not coordinate across replicas. Use provider-side quotas for hard spending limits.
API
createMCPSpendShield(options)/new MCPSpendShield(options)spend.wrapToolHandler(handler, toolName)spend.status()/spend.reset()CostTracker,BudgetExceededError
Development
npm install
npm test
npm pack --dry-runNode.js 20+ · TypeScript · MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Paid remote MCP for context-budget routing, schema cost estimates, usage audits, and readiness.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceBudget management and cost tracking MCP server for autonomous agents, enabling budget creation, cost recording, spending projections, and alert rules.MIT
- FlicenseBqualityCmaintenanceEnables tracking and managing expenses through a FastMCP server.3-
- AlicenseNot gradedqualityCmaintenanceLocal-first cost tracking and model routing for MCP agents with offline token counting, budget alerts, and spend reports.63 npmMIT
- AlicenseNot gradedqualityCmaintenanceUsage tracking and credit/quota access-gating for enlace MCP connectors, providing policy-based metering with ledger recording and fail-closed FastMCP middleware to enforce per-principal credit and call caps.Apache 2.0