mcpstat
Usage tracking and analytics for MCP servers
claude mcp add --transport stdio tekkidev-mcpstat python -m mcp.server \ --env MCPSTAT_DATABASE_URL="SQLite path or URL for persistent stats (optional, defaults to local sqlite file)"
How to use
mcpstat is a Python-based analytics and usage-tracking tool designed to work with MCP servers. It provides an audit trail of tool usage, tracks how often tools are invoked, and offers built-in capabilities such as get_tool_usage_stats and get_tool_catalog, along with token and latency tracking. Integrating mcpstat into your MCP workflow lets you monitor tool usage patterns, categorize tools with a tag system, and optionally log all actions to a file for auditing. The package is Reactivated by decorating your tool handlers to automatically collect metrics, so you can keep your business logic clean while gaining visibility into performance and usage.
To use it, install mcpstat and run your MCP server with the provided Python entry point. The library exposes a Server from the MCP ecosystem and a MCPStat tracker, which you attach to your tool handlers via decorators. After setup, you can query usage statistics, catalog information, and latency data to identify slow tools or high-usage patterns. This enables cost analysis, optimization, and better capacity planning for your MCP-based services.
How to install
Prerequisites:
- Python 3.10 or newer
- pip (comes with Python)
Installation steps:
-
Install the core package pip install mcpstat
-
(Optional) Install with MCP extra for integration helpers pip install "mcpstat[mcp]"
-
Verify installation python -m pip show mcpstat
-
Run a sample server (adjust as needed for your environment)
Example using the recommended entry point from the README example
pip install -e ".".*[mcp] # if you are developing locally python -m mcp.server # or your actual server startup command
-
If needed, install development/testing tools pip install "mcpstat[dev]" && pytest tests/
Additional notes
Notes and tips:
- mcpstat stores usage data in SQLite by default (persistent across restarts); configure alternative storage if required via environment variables or config files.
- The built-in tools like get_tool_usage_stats and get_tool_catalog help you explore which tools are most used and how they are categorized with tags.
- Enable token tracking and latency measurements to understand cost implications and performance characteristics of tools.
- You can enable file-based audit logging for a timestamped trail of actions.
- If you encounter environment-specific issues, ensure your Python environment matches the supported version (Python 3.10+), and verify that the MCP base library your server uses is compatible with mcpstat.
- Review the official documentation linked in the README for configuration options and advanced usage patterns.
Related MCP Servers
AstrBot
Agentic IM Chatbot infrastructure that integrates lots of IM platforms, LLMs, plugins and AI feature, and can be your openclaw alternative. ✨
dexto
A coding agent and general agent harness for building and orchestrating agentic applications.
aser
Aser is a lightweight, self-assembling AI Agent frame.
moling
MoLing is a computer-use and browser-use based MCP server. It is a locally deployed, dependency-free office AI assistant.
mcp
🤖 Taskade MCP · Official MCP server and OpenAPI to MCP codegen. Build AI agent tools from any OpenAPI API and connect to Claude, Cursor, and more.
mcp -js
MCP server that exposes YepCode processes as callable tools for AI platforms. Securely connect AI assistants to your YepCode workflows, APIs, and automations.