Query spend with MCP
Point the Opik MCP server at your Cost Intelligence workspace and you can ask your coding agent about your organization’s spend in plain language: who spends the most, which skills and MCP servers earn their keep, and what drove the cost of a single session. The agent reads the same figures as the Cost Intelligence dashboard, and links each answer to the matching page so you can check it.
Only admins can use it. The Cost Intelligence workspace holds company-wide data, so access to it is limited to admins, and the MCP server can only read what your own API key can.
Before you begin
You need three things:
uv, which runs the MCP server.- Your Opik API key, from your Opik account settings.
- The name of your Cost Intelligence workspace. It is
__ai_spend_followed by your organization ID and two underscores, for example__ai_spend_XJtf7HIqB9i2K59BxoHmUUGTD__. To find yours, open Cost Intelligence from the user menu in Opik and copy the name from the browser address bar, which readshttps://www.comet.com/opik/<workspace>/ai-spend/....
Set it up
Install uv, if you don't have it
Open a new terminal afterwards so uvx is on your PATH.
Add the server to your coding agent
Add it under its own name, opik-cost-intelligence, so it sits alongside any Opik MCP server you already use for your regular workspace.
Claude Code
Cursor
Codex
For other clients, Advanced setup shows where each one keeps this configuration.
On a self-hosted Comet deployment, also set COMET_URL_OVERRIDE to your
instance URL. The server expects Opik’s API at that URL plus /opik/api.
If your deployment serves it at a different host or path, also set
OPIK_URL to the full API URL.
Questions to ask
Answers cover the last 30 days unless you name another time window.
Total spend for the period, and what each of the ten heaviest users spends their tokens on.
Which skills earn their place, and which ones only add to every request.
MCP servers that are installed but never called, and what removing them would save.
Duplicates like claude_ai_Notion and Notion, where users pay for the same tool definitions twice.
What one session did, step by step, and which cost category dominated it.
Troubleshooting
- The agent says it has no access to spend data. The server is pointed at the wrong workspace. Set
OPIK_WORKSPACEto your Cost Intelligence workspace, the one starting with__ai_spend_. Anopik-mcpversion older than 0.2.38 shows the same symptom; ifuvxis still running an older copy from its cache, runuv cache clean opik-mcp. Restart the coding agent after any change. - The agent reports an authentication or permission error. The API key belongs to an account without access to the Cost Intelligence workspace. Use an admin’s key.