CostGate
Reduces AI token consumption by optimizing MCP tool definitions and responses, with a probe for measurement and a gate for filtered tool exposure and cost reduction.
README
CostGate
Gate your MCP. Cut your bill.
CostGate reduces AI token consumption by optimizing MCP tool definitions and responses. Cursor-first, compatible with Claude Desktop and other MCP clients.
Repository layout (monorepo)
costgate/
├── packages/
│ ├── schema/ @costgate/schema — shared log schema
│ ├── probe/ @costgate/probe — measurement MCP (npm)
│ └── gate/ costgate-gate — gateway MCP (Go binary)
├── docs/
├── examples/
└── scripts/
See docs/structure.md for why Probe and Gate share one repo.
Packages
| Package | Dist | Description |
|---|---|---|
| @costgate/probe | npm | Measurement MCP — baseline token usage, call stats, JSONL logs |
| costgate-gate | binary | Gateway MCP — filtered tool exposure, delegation, cost reduction |
| @costgate/schema | workspace | Shared JSON Schema for logs |
Quick start (Probe)
npm install
npm run build:probe
Add to Cursor ~/.cursor/mcp.json:
{
"mcpServers": {
"costgate-probe": {
"command": "node",
"args": ["/path/to/costgate/packages/probe/dist/index.js"],
"env": {
"COSTGATE_PROBE_LOG_DIR": "~/.costgate/logs"
}
}
}
}
Or after npm publish: npx @costgate/probe
See examples/cursor/ for full configuration.
Quick start (Gate)
Requires Go 1.25+.
npm run build:gate
npm run test:gate # smoke test (GitHub backend via ~/.costgate/backends.json)
Add to Cursor ~/.cursor/mcp.json (keep serena direct; see mcp-gate-github.json):
{
"mcpServers": {
"costgate-gate": {
"command": "/path/to/costgate/packages/gate/bin/costgate-gate",
"env": {
"COSTGATE_CONFIG": "~/.costgate/backends.json"
}
}
}
}
Filter mode (default): Tier A/B/C + discover_tools / invoke_tool. Set COSTGATE_GATE_MODE=transparent for pass-through baseline. See packages/gate/README.md.
Compare reduction: npm run compare (Before/After tools/list token estimate).
Session breakdown: npm run session-report (fixed + variable + overall % scenarios).
Production Cursor setup: npm run cursor:production — see examples/cursor/README.md.
Cloud metrics (opt-in): npm run cloud:upload — see costgate-cloud.
Plans (roadmap)
| Plan | Scope |
|---|---|
| Free (OSS) | Probe + Gate core |
| Pro | Automated cloud reports (costgate-cloud) |
| Team / Enterprise | Team dashboard, policies, custom proposals, support |
Documentation
- Development roadmap
- Repository structure
- Docker / Dev Container
- Architecture
- Log schema
- Contributing
License
MIT — see LICENSE
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.