mcpspend — Claude Code MCP server: what it does, how to install
Tracks MCP tool call costs across your coding agents and lets you inspect spending directly in the chat. Useful for catching runaway token bills early.
claude mcp add --env MCPSPEND_API_KEY=<MCPSPEND_API_KEY> --env MCPSPEND_ENDPOINT=<MCPSPEND_ENDPOINT> --transport stdio mcpspend -- npx -y @mcpspend/mcp-serverWhat mcpspend does
This server connects your client to mcpspend.com, letting an assistant run queries like get_today_cost and list_top_tools. Data collection happens through the companion @mcpspend/proxy, which wraps existing tool configurations to record latency, tool names, models, and rough token counts based on payload length.
Tool arguments and raw output bodies stay on your local disk; only aggregated metadata reaches the ingestion endpoint. Running the server requires an MCPSPEND_API_KEY. The free plan covers 25,000 tool executions per month without entering payment details.
What it helps with
- check current day tool spending inside the agent conversation
- spot the most heavily invoked MCP tools across your setup
- forecast monthly budget usage before hitting billing limits
- inspect session activity without leaving the terminal
Example prompts for the agent
- How much did my MCP tool calls cost today?
- List the top tools by invocation count from recent sessions.
- What is my projected spend for this month?
How to install mcpspend
Platform CLI
claude mcp add --env MCPSPEND_API_KEY=<MCPSPEND_API_KEY> --env MCPSPEND_ENDPOINT=<MCPSPEND_ENDPOINT> --transport stdio mcpspend -- npx -y @mcpspend/mcp-serverReplace <…> with your own values
Platform CLI
codex mcp add mcpspend --env MCPSPEND_API_KEY=<MCPSPEND_API_KEY> --env MCPSPEND_ENDPOINT=<MCPSPEND_ENDPOINT> -- npx -y @mcpspend/mcp-serverReplace <…> with your own values
Config file
{
"mcpServers": {
"mcpspend": {
"command": "npx",
"args": [
"-y",
"@mcpspend/mcp-server"
],
"env": {
"MCPSPEND_API_KEY": "<MCPSPEND_API_KEY>",
"MCPSPEND_ENDPOINT": "<MCPSPEND_ENDPOINT>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"mcpspend": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@mcpspend/mcp-server"
],
"env": {
"MCPSPEND_API_KEY": "<MCPSPEND_API_KEY>",
"MCPSPEND_ENDPOINT": "<MCPSPEND_ENDPOINT>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e MCPSPEND_API_KEY=<MCPSPEND_API_KEY> -e MCPSPEND_ENDPOINT=<MCPSPEND_ENDPOINT> mcpspend npx -y @mcpspend/mcp-serverReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about mcpspend
How do I install mcpspend in Claude Code?
Run claude mcp add mcpspend -e MCPSPEND_API_KEY=<MCPSPEND_API_KEY> -- npx -y @mcpspend/mcp-server with your secret key. If using a custom endpoint, run `claude mcp add --env MCPSPEND_API_KEY=<MCPSPEND_API_KEY> --env MCPSPEND_ENDPOINT=<MCPSPEND_ENDPOINT> --transport stdio mcpspend -- npx -y @mcpspend/mcp-server`.
What does mcpspend do?
It exposes tools inside your coding agent to check daily expenditure, inspect session metrics, and view top MCP tools without opening a separate web interface.
Does mcpspend send code arguments or tool output to its cloud?
No. The proxy captures only server names, model metadata, execution time, and approximate token size. Raw inputs and tool outputs never leave the local environment.