Measure Measure
Sign In Start Free Trial
← Blog
mcp analytics developer

How to Add Analytics to Your MCP Server in 5 Minutes

by Jules

How to Add Analytics to Your MCP Server in 5 Minutes

You published your MCP server to Smithery or the official registry. Maybe you got listed in awesome-mcp-servers. But here’s the question nobody talks about: is anyone actually using it?

GitHub stars tell you interest. Downloads tell you installs. Neither tells you which tools are getting called, how often, or whether users are hitting errors.

Here’s how to instrument your MCP server with lightweight analytics in about 5 minutes.

What You’re Tracking

For an MCP server, the useful signals are:

  • Tool invocations — which tools are called, how often
  • Tool errors — which tools are failing and why
  • Active sessions — unique agents using your server over time
  • Response latency — where slowdowns happen

You don’t need a 200-line observability setup. A simple event ping on each tool call is enough to get visibility.

The Pattern: Event Pings on Tool Calls

Measure.events accepts a simple POST /api/v1/events call. Here’s a minimal wrapper:

// analytics.ts
const MEASURE_KEY = process.env.MEASURE_SITE_KEY;
const MEASURE_URL = "https://lets.measure.events/api/v1/events";

export async function trackTool(
  toolName: string,
  success: boolean,
  durationMs?: number
) {
  if (!MEASURE_KEY) return; // graceful no-op if key not set

  fetch(MEASURE_URL, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${MEASURE_KEY}`,
    },
    body: JSON.stringify({
      site_key: MEASURE_KEY,
      event_type: "tool_call",
      page: `/tools/${toolName}`,
      referrer: success ? "success" : "error",
      properties: { duration_ms: durationMs },
    }),
  }).catch(() => {}); // fire and forget, never block tool execution
}

Wrap Your Tool Handlers

// In your MCP server's tool handler:
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  const start = Date.now();
  const { name, arguments: args } = request.params;

  try {
    const result = await handleTool(name, args);
    trackTool(name, true, Date.now() - start); // async, non-blocking
    return result;
  } catch (error) {
    trackTool(name, false, Date.now() - start);
    throw error;
  }
});

That’s it. Every tool call logs to your Measure.events dashboard — async, non-blocking, zero impact on tool latency.

What You See in the Dashboard

After a few hours of usage, you’ll have:

  • Top pages = top tools by call count (/tools/search, /tools/create, etc.)
  • Referrers = success vs error split, so you can see error rate at a glance
  • Traffic series = daily/weekly usage trends

It’s not a full observability platform. But it answers the question “are people actually using this?” — which is the question that matters most when you’ve just shipped.

Using the MCP API for Agent-Native Queries

Measure.events also ships a native MCP server that lets Claude query your analytics directly:

User: "Which of my MCP tools has the highest error rate this week?"

Claude: [calls measure_agent_report]
→ "Your /tools/search tool had 47 calls with a 12% error rate.
   /tools/create had 23 calls with 2% error rate."

No dashboard required. Your agent can query its own analytics.

Get Started Free

  1. Sign up at Measure.events — free to start
  2. Create a site, grab your site key
  3. Add the 5-line wrapper above to your MCP server
  4. Deploy — data starts flowing immediately

The whole thing takes under 10 minutes for an existing MCP server. No SDK, no dependencies, no configuration files.


Measure.events is analytics built for agents first. The MCP server is a native HTTP endpoint — your AI coding assistant can query your analytics without you touching a dashboard.

Ready to see accurate analytics?

No cookies. No consent banners. No personal data. $29/mo with a 14-day free trial.

Start free trial →