How to monitor traffic to your MCP server
Building an MCP server? You need to know who's connecting, which tools they call, and whether usage is growing. Here's how to add analytics to your MCP server with Measure.
You’ve built an MCP server. People are using it — maybe. Cursor is connecting, Claude Desktop is connecting, Windsurf is connecting. But you have no idea:
- How many connections happen per day
- Which tools get called most often
- Whether usage is growing or dying
- Where users drop off
This is the analytics blind spot for MCP server builders in 2026. And right now, almost nobody has solved it.
Here’s how to add meaningful analytics to your MCP server using Measure.
Why standard analytics don’t work for MCP servers
MCP servers don’t serve web pages. Many communicate over stdio or a streaming HTTP transport with AI clients. You can’t drop a <script> tag into a browser because there’s no browser.
Standard web analytics (including Measure’s own JS snippet) track page views. That model doesn’t apply here.
What you need instead: server-side event tracking via the Measure REST API (https://lets.measure.events/api/v1).
What to track on an MCP server
Before writing any code, decide what matters:
Connection events
- New client connected (track: client name, timestamp)
- Client disconnected
Tool calls
- Which tool was invoked (e.g.,
search_docs,create_ticket) - Success vs. error
Usage patterns
- Daily active connections
- Most popular tools
- Peak usage hours
Growth signals
- New clients (first-time connections)
- Returning vs. one-off connections
Setting up Measure API tracking
Measure’s REST API accepts server-side events, which works for exactly this use case. No browser required.
First, create an API key in your Measure dashboard (keys start with mk_). Then create a site in your dashboard for your MCP server.
Events go to POST https://lets.measure.events/api/v1/events with your mk_ key as a Bearer token. The body is JSON: your site key, a path, and optionally referrer, user_agent, agent and utm_* fields. Model each event as a path — /events/tool_called/search_docs, /events/tool_error/search_docs — and you can read them like pages.
Node.js / TypeScript MCP server
If you’re using the TypeScript MCP SDK (@modelcontextprotocol/sdk), add tracking in your tool handlers:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const MEASURE_API_KEY = process.env.MEASURE_API_KEY; // mk_...
const MEASURE_SITE_KEY = process.env.MEASURE_SITE_KEY; // your site's tracking ID
function trackEvent(path: string, agent?: string) {
if (!MEASURE_API_KEY || !MEASURE_SITE_KEY) return;
fetch("https://lets.measure.events/api/v1/events", {
method: "POST",
headers: {
"Authorization": `Bearer ${MEASURE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ site_key: MEASURE_SITE_KEY, path, agent }),
}).catch(() => {
// Never let analytics errors affect your server
});
}
const server = new Server(
{ name: "your-mcp-server", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Track server errors
server.onerror = () => {
trackEvent("/events/server_error");
};
// Wrap your tool handlers
server.setRequestHandler(ListToolsRequestSchema, async () => {
trackEvent("/events/tools_listed");
return { tools: YOUR_TOOLS };
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const tool = request.params.name;
trackEvent(`/events/tool_called/${tool}`);
try {
return await handleTool(tool, request.params.arguments);
} catch (error) {
trackEvent(`/events/tool_error/${tool}`);
throw error;
}
});Pass the connecting client’s name (from the MCP initialize request) as agent if you want to see which clients use your server.
Python MCP server
If you’re using the Python MCP SDK:
import httpx
import os
from mcp.server import Server
from mcp.server.stdio import stdio_server
MEASURE_API_KEY = os.getenv("MEASURE_API_KEY") # mk_...
MEASURE_SITE_KEY = os.getenv("MEASURE_SITE_KEY") # your site's tracking ID
async def track_event(path: str):
if not MEASURE_API_KEY or not MEASURE_SITE_KEY:
return
try:
async with httpx.AsyncClient() as client:
await client.post(
"https://lets.measure.events/api/v1/events",
headers={"Authorization": f"Bearer {MEASURE_API_KEY}"},
json={"site_key": MEASURE_SITE_KEY, "path": path},
)
except Exception:
pass # Never block on analytics
app = Server("your-mcp-server")
@app.call_tool()
async def call_tool(name: str, arguments: dict):
await track_event(f"/events/tool_called/{name}")
# ... your tool logicHigh-volume server? Buffer events and send them together to POST /api/v1/events/batch as {"events": [...]}.
Querying your MCP analytics with AI
Here’s where it gets interesting. Once your MCP server is tracking events in Measure, you can query those analytics with an AI assistant — through Measure’s own MCP server.
Add the Measure MCP server (https://lets.measure.events/mcp, authenticated with your mk_ API key) to your Claude Desktop config and ask:
“Which tools are my users calling most often this week?”
“Did usage grow after I published on Product Hunt?”
“What’s the error rate on my search_docs tool?”
You get natural language answers backed by real data. No dashboard required.
What this looks like in practice
After a week of tracking, you’ll see things like:
/events/tools_listed→ 847 hits (how often AI clients enumerate your tools)/events/tool_called/search_docs→ 312 hits (most popular tool)/events/tool_called/create_ticket→ 89 hits/events/tool_error/search_docs→ 14 hits (an error rate worth investigating)
That’s a real product health signal. You can see if a new version introduced regressions. You can see which tools are driving adoption and which are dead weight. You can see if a mention in a newsletter drove a spike.
Environment variables
Keep your Measure credentials in .env:
MEASURE_API_KEY=mk_your_key_here
MEASURE_SITE_KEY=your_tracking_idAdd to your MCP server’s mcp.json or claude_desktop_config.json:
{
"mcpServers": {
"your-server": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"MEASURE_API_KEY": "mk_your_key_here",
"MEASURE_SITE_KEY": "your_tracking_id"
}
}
}
}Fire and forget, always
One rule: analytics should never break your server. Always wrap tracking calls in try/catch. Use fire-and-forget patterns. Your MCP server’s primary job is to respond to tool calls — analytics is secondary.
The code examples above follow this rule. If Measure is unreachable or your network is flaky, your MCP server keeps working.
Get started
- Start a 14-day trial at lets.measure.events ($29/month afterwards, covering up to 40 sites)
- Add a new site for your MCP server
- Copy the event tracking code above
- Add your
MEASURE_API_KEYandMEASURE_SITE_KEYenv vars - Deploy and watch the data come in
You built something people are using. You should know exactly how they’re using it.
Let your agent read the numbers.
$29 a month covers 40 sites, then $0.50 a site. 14-day trial.