Skip to main content
Glama

mcpstat

PyPI - Version GitHub License PyPI - Python Version GitHub Actions Workflow Status PyPI - Downloads Checked with mypy Security: bandit Codecov

Usage tracking and analytics for MCP servers. Pure Python, zero required dependencies.

Track which tools get called, how often, and keep an audit trail - all in 3 lines of code.

Installation

pip install mcpstat

With MCP SDK:

pip install "mcpstat[mcp]"

Related MCP server: MCP Pulse

Quick Start

from mcp.server import Server
from mcpstat import MCPStat

app = Server("my-server")
stat = MCPStat("my-server")

@app.call_tool()
@stat.track  # ← One decorator does everything!
async def handle_tool(name: str, arguments: dict):
    # Your logic here - latency tracked automatically
    return await my_logic(arguments)

Then ask your AI assistant: "Give me MCP usage stats"

Features

  • SQLite-backed - Stats persist across restarts

  • Built-in MCP tools - get_tool_usage_stats, get_tool_catalog

  • Tag system - Categorize and filter tools

  • Token tracking - Estimate or record actual token usage

  • Latency tracking - Measure execution duration, identify slow tools

  • File logging - Optional timestamped audit trail

  • Async-first - Thread-safe via asyncio.Lock

Documentation

Full Documentation - Quick start, API reference, examples

Examples

# Clone and run example server
git clone https://github.com/tekkidev/mcpstat.git
cd mcpstat
pip install -e ".[mcp]"
python examples/example_server.py

See examples/ for minimal and full integration patterns.

Contributing

See CONTRIBUTING.md. Run tests with:

pip install "mcpstat[dev]"
pytest tests/

License

MIT - see LICENSE for details.


MCP is a trademark of its respective owners. This project is not affiliated with or endorsed by any trademark holders.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables sharing MCP servers with clients, storing tool calls in PostgreSQL, and providing usage analytics via an admin dashboard and API.
    -
  • A
    license
    A
    quality
    A
    maintenance
    An MCP server that records agent execution metrics and exposes a Context Window Explorer to visualize exactly what entered the model's context window across sessions, tokens, and tool calls.
    8
    3
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Read-only MCP server for querying AI usage metrics (exact tokens, cost, latency, errors, productivity) from a local SQLite database, enabling charts and analysis in Claude Code and Cursor.
    -