MCP Analytics Middleware

MCP Analytics Middleware

By Phillip-Kemper GitHub

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.

Overview

what is mcp-analytics-middleware?

mcp-analytics-middleware is a lightweight TypeScript middleware designed for MCP SDK servers that provides analytics capabilities. It captures request metrics, performance data, and usage patterns with minimal overhead.

how to use mcp-analytics-middleware?

To use mcp-analytics-middleware, integrate it into your MCP SDK server setup. Configure the middleware to collect the desired metrics and enable real-time monitoring and reporting.

key features of mcp-analytics-middleware?

  • Real-time monitoring of request metrics and performance data.
  • Configurable data collection to suit specific needs.
  • Detailed reporting with full type safety to ensure reliability.

use cases of mcp-analytics-middleware?

  1. Monitoring the performance of web applications built on MCP SDK.
  2. Analyzing usage patterns to optimize server performance.
  3. Generating reports for performance audits and improvements.

FAQ from mcp-analytics-middleware?

  • What programming language is mcp-analytics-middleware written in?

It is written in TypeScript, ensuring type safety and better development experience.

  • Is there any overhead when using this middleware?

The middleware is designed to have minimal overhead, allowing for efficient performance monitoring without significant impact on server operations.

  • Can I customize the data collection?

Yes! The middleware allows for configurable data collection based on your specific requirements.

Content

MCP Analytics Middleware

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.

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
  1. 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 tools information available.
No content found.