How to connect Claude Code, Cursor, or OpenCode to your metrics
Your coding assistant can read your code, but it usually can't see what happened after you deployed it. Connect it to your metrics and you can ask about signups, latency, or failed jobs while you work. This guide shows how to connect Claude Code, Cursor, or OpenCode to Umlogger's hosted MCP server.
What you need
- An Umlogger account with at least one metric. If you're starting fresh, send a sample with curl.
- Claude Code, Cursor, or OpenCode 2.
1. Create an access token
In Umlogger, open Settings → Access tokens (MCP) and choose New access token. Start with a read-only token. It lets the assistant analyze metrics, but not create metrics, log samples, or add annotations. Copy the token right away, because it's shown only once.
2. Connect your assistant
Follow the section for the tool you use.
Claude Code
Replace the placeholder with your token, then run:
claude mcp add --transport http umlogger https://data.umlogger.com/mcp \ --header "Authorization: Bearer ump_YOUR_TOKEN"
Start Claude Code and run /mcp to check the connection. By default, the server is available only to you in the current project. Add --scope user before the server name to use it in all your projects.
To share the setup with your team, commit this .mcp.json. Each person sets UMLOGGER_TOKEN to their own token:
{
"mcpServers": {
"umlogger": {
"type": "http",
"url": "https://data.umlogger.com/mcp",
"headers": {
"Authorization": "Bearer ${UMLOGGER_TOKEN}"
}
}
}
}Cursor
Set UMLOGGER_TOKEN in the environment Cursor starts from, then add this to ~/.cursor/mcp.json:
{
"mcpServers": {
"umlogger": {
"url": "https://data.umlogger.com/mcp",
"headers": {
"Authorization": "Bearer ${env:UMLOGGER_TOKEN}"
}
}
}
}OpenCode
These steps are for OpenCode 2. Set your token in the shell you use to start OpenCode. To keep it for new terminals, add this line to your shell profile:
export UMLOGGER_TOKEN="ump_YOUR_TOKEN"
Then merge this into ~/.config/opencode/opencode.json, keeping any settings you already have. To connect just one project, use its opencode.json instead:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"umlogger": {
"type": "remote",
"url": "https://data.umlogger.com/mcp",
"oauth": false,
"headers": {
"Authorization": "Bearer {env:UMLOGGER_TOKEN}"
}
}
}
}
}Two details are easy to miss. OpenCode writes variables as {env:NAME}, without a $. And because Umlogger uses a token instead of OAuth, you should keep "oauth": false. Without it, OpenCode may ask you to sign in when the token is simply missing.
Finish any active OpenCode work, then run these commands in the same shell to restart its background server and check the connection:
opencode service restart opencode mcp list
Don't skip the restart if OpenCode was already running. Its background server won't pick up a token you set after it started, so you'd get a 401 error even with the right config. You should see umlogger connected. If no servers are listed, wait a moment and run opencode mcp list again.
3. Ask your first question
Check what the assistant can see, then try a comparison:
List my Umlogger metrics and when each last received data. How do signups for the last 7 days compare with the 7 days before?
For the second prompt, the assistant can call query_metric with comparePrevious turned on. Umlogger calculates both totals and the percentage change, so the assistant doesn't have to add up raw samples.
4. Add deploys to your charts
If you want the assistant to make changes, create a read & write token and update your config. Then you can ask it to mark a deploy:
Add the annotation "Deployed the new checkout" to checkout-errors.
Later, ask it to compare annotations with changes in the metric. If errors rise after a deploy, that's a useful lead, but the timing alone doesn't prove the deploy caused them.
Keep your token safe
- Give each person and device its own token, so you can revoke one without affecting the others.
- Set an expiry, and never commit a token to your repository.
- Review changes before approving them.
- Your AI client receives the metric data it requests and may send it to its model provider.
See the MCP server guide for all the tools, limits, and troubleshooting, or try these prompts for SaaS metrics.