MCP Analytics Middleware

by Phillip-Kemper

4 277 downloads Not rated yet MIT
GitHub

About

A lightweight TypeScript middleware for MCP SDK servers that delivers analytics. Captures request metrics, performance data, and usage patterns with minimal overhead. Features real-time monitoring, configurable data collection, and detailed reporting - all with full type safety.

Details

License
MIT

Explore

- 🔍 Track all tool calls and resource requests
- 📊 See performance metrics and error rates
- 🌐 Web dashboard for live analytics
- 💾 SQLite database for persistent storage

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP Analytics Middleware
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

1. Install the package:

yarn add mcp-analytics-middleware

2. Add it to your MCP server:

import { McpAnalytics } from 'mcp-analytics-middleware';

let server = new McpServer({
name: 'Sample MCP Server with Analytics',
version: '1.0.0'
});

const analytics = new McpAnalytics('analytics.db');

server = analytics.enhance(server); // override tool and resource function implementation to record usage in sqlite

If you're using the MCP Inspector, just add the analytics flag:

yarn inspector --analytics --db-path analytics.db

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp analytics middleware": {
            "mcp-analytics-middleware": {
                "command": "npx",
                "args": [
                    "-p",
                    "mcp-analytics-middleware",
                    "web-viewer",
                    "--db-path",
                    "analytics.db"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-analytics-middleware": {
        "command": "npx",
        "args": [
            "-p",
            "mcp-analytics-middleware",
            "web-viewer",
            "--db-path",
            "analytics.db"
        ]
    }
}

npm version
npm downloads

A simple way to track and visualize how your MCP server is being used. See which tools are most popular, catch errors early, and understand your server's performance.
- Supporting Blog Post

Features

- 🔍 Track all tool calls and resource requests
- 📊 See performance metrics and error rates
- 🌐 Web dashboard for live analytics
- 💾 SQLite database for persistent storage

Quick Start

1. Install the package:

yarn add mcp-analytics-middleware

2. Add it to your MCP server:

import { McpAnalytics } from 'mcp-analytics-middleware';

let server = new McpServer({
name: 'Sample MCP Server with Analytics',
version: '1.0.0'
});

const analytics = new McpAnalytics('analytics.db');

server = analytics.enhance(server); // override tool and resource function implementation to record usage in sqlite

Live Analytics

Want to see a dashboard for a Tyescript SDK MCP Server making use of this middleware? You can directly provide a live dashboard using

npx -p mcp-analytics-middleware web-viewer --db-path analytics.db


The web dashboard will open at http://localhost:8080 and show you live analytics!

You'll see:
- Total tool calls and resource requests
- Error rates and performance metrics
- Most used tools and slowest operations

Example Implementations

Example implementatinos of the analytics middleware can be found. 1. Dummy Caluclator Server Example src/server.ts 2. Ethereum RPC MCP Server with Analytics server/index.ts_ 3. Forked Verision of the Google Maps MCP Server with additional Analytics Middleware src/google-maps/index.ts

Running with Inspector

If you're using the MCP Inspector, just add the analytics flag:

yarn inspector --analytics --db-path analytics.db

License

MIT

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.