mcpstat
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcpstat
Python observability and usage analytics for MCP (Model Context Protocol) servers.
Track tool, prompt, and resource calls, successful and failed invocations, and execution latency in local SQLite storage. Add tracking to your existing Python MCP server and expose its statistics as MCP tools that an assistant can query. Optional file logging provides an audit trail.
Installation
pip install mcpstat
pip install "mcpstat[server]" # Includes the SDK for the example belowRelated MCP server: MCP Pulse
Quick Start
from mcp.server import MCPServer
from mcpstat import MCPStat, disable_sdk_tracing
app = MCPServer("my-server")
disable_sdk_tracing(app)
stat = MCPStat("my-server")
@app.tool()
@stat.track(name="echo")
async def echo(message: str) -> str:
"""Return a message, tracking usage and latency automatically."""
return message
@app.tool()
async def get_tool_usage_stats() -> dict:
"""Return cumulative MCP usage statistics."""
return await stat.get_stats()
if __name__ == "__main__":
try:
app.run()
finally:
stat.close()Connect your assistant to this server, then ask: "Give me MCP usage stats"
For a complete request-to-statistics example, follow the weather server walkthrough. It demonstrates successful calls, an intentional failure, unused tools, and statistics that persist after restarting the server.
Choose Your Integration
Use case | Installation | What it tracks |
Add tracking to an existing Python server |
| The handlers you instrument with the SDK-independent library; keep your server's MCP SDK installed separately. |
Run the bundled documentation and demonstration server |
| Its own temperature conversion tools and other registered handlers. |
The decorator records usage; register a statistics tool such as get_tool_usage_stats
to query that data from Claude Code, VS Code, or another MCP client. The standalone
server does not automatically observe other MCP servers.
Features
SQLite-backed - Stats persist across restarts
Built-in MCP tools -
get_tool_usage_stats,get_tool_catalogTag 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 - Database operations run in worker threads with serialized transactions
Install mcpstat for the SDK-independent tracking library. The [server] extra includes
the SDK and the runnable mcpstat documentation and demonstration server. The standalone
server tracks its own calls; integrate the library into each server you want to monitor.
Documentation
Full Documentation - Quick start, API reference, examples
Quick Start - Get running in 5 minutes
Configuration - Customize paths, logging, presets
API Reference - Complete method reference
Token Tracking - Cost analysis features
Latency Tracking - Performance monitoring
Agent Documentation Index - Links to plain Markdown guides and examples
Full Agent Reference - Detailed integration and API summaries
Examples
# Clone and run example server
git clone https://github.com/tekkidev/mcpstat.git
cd mcpstat
pip install -e ".[dev]"
python examples/example_server.pySee 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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Analytics for MCP servers. Query your tool calls, first-call success, retries and schema cost.
Analytics for MCP servers. Find out which of your tools agents get wrong. MCPulse shows you which tools AI agents retry, which come back empty, and which they never call at all. Two lines inside your own server. It never sees your arguments or your results. getmcpulse.com
Analytics and debugging for your MCP server — explore usage and sessions, then root-cause errors.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
Related MCP Servers
- AlicenseAqualityDmaintenanceA MCP server for tracking AI usage metrics and structured logs across applications. Monitor model calls, analyze usage patterns, track costs, and debug AI interactions.57 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables sharing MCP servers with clients, storing tool calls in PostgreSQL, and providing usage analytics via an admin dashboard and API.-
- AlicenseAqualityBmaintenanceAn 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.83MIT
- FlicenseNot gradedqualityDmaintenanceRead-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.-