costpilot-mcp
v0.1.2
Published
CostPilot MCP server for per-request AI cost tracking and prompt optimization for Claude Code, Cursor, Windsurf, and more
Maintainers
Readme
CostPilot MCP
Track AI spend, catch prompt waste, and audit AI coding setups from any MCP-compatible client.
CostPilot MCP connects Claude Desktop, Claude Code, Cursor, Windsurf, and other AI tools to your CostPilot dashboard. It exposes tools for request-level cost tracking, prompt optimization, spend insights, and local setup audits.
Install
Run the MCP server with npx:
npx -y costpilot-mcpNode.js 18 or newer is required.
Claude Desktop
Add CostPilot to your Claude Desktop MCP config:
{
"mcpServers": {
"costpilot": {
"command": "npx",
"args": ["-y", "costpilot-mcp"],
"env": {
"COSTPILOT_KEY": "pilot_live_your_key_here"
}
}
}
}On Windows, use npx.cmd as the command because many MCP hosts spawn commands directly without going through a shell:
{
"mcpServers": {
"costpilot": {
"command": "npx.cmd",
"args": ["-y", "costpilot-mcp"],
"env": {
"COSTPILOT_KEY": "pilot_live_your_key_here"
}
}
}
}On Windows, the config file is usually:
%APPDATA%\Claude\claude_desktop_config.jsonOn macOS, the config file is usually:
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop after saving the config.
Environment
COSTPILOT_KEY=pilot_live_your_key_hereOptional:
COSTPILOT_API_URL=https://api.aicostpilot.online
COSTPILOT_SKIP_TRACKING=trueUse COSTPILOT_SKIP_TRACKING=true when another integration, such as a Claude Code hook or gateway, already records requests. In that mode the MCP server exposes optimization, insights, and audit tools without double-counting usage.
Tools
costpilot_start
: Starts a tracked request and estimates input cost before the model answers.
costpilot_track
: Completes a tracked request and records final output cost.
costpilot_optimize
: Reviews long prompts for token waste and practical savings.
costpilot_insights
: Returns recent AI spend, request volume, token usage, and tool breakdown.
costpilot_audit
: Audits local AI tool configs for bloated rules files, unused MCP servers, uncapped shell output, and other token-wasting setup issues.
Example Prompts
After connecting the MCP server, try:
How much have I spent on AI this month?Audit my Claude and Cursor setup for wasted tokens.Can you optimize this long prompt before answering?Troubleshooting
If the server prints COSTPILOT_KEY is required, add a valid CostPilot API key to the MCP config env block.
If Claude Desktop does not show the tools, restart Claude Desktop and confirm the package command is exactly:
"args": ["-y", "costpilot-mcp"]On Windows, also confirm:
"command": "npx.cmd"If you already track Claude Code with a CostPilot hook, set:
"COSTPILOT_SKIP_TRACKING": "true"Links
- Dashboard: https://aicostpilot.online
- Package: https://www.npmjs.com/package/costpilot-mcp
