mcpstat
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]"
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
- 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
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.
Metadata
Release files for mcpstat 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcpstat-0.2.2.tar.gz | 45.5 kB | Without provenance | Details for mcpstat-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcpstat-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for mcpstat-0.2.2-py3-none-any.whl |
Total release size: 68.5 kB
Release files / mcpstat-0.2.2.tar.gz
| Download URL | mcpstat-0.2.2.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8346e4c8a35359a8000366521e0a673e2b1ffdbfeed18e406e0d067185dc292b
|
|
BLAKE2b-256 checksum How to use checksums |
eb0dbed573866b34c94b68acb579c7adf5dd58b310d74c0837260ebc937b761a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / mcpstat-0.2.2-py3-none-any.whl
| Download URL | mcpstat-0.2.2-py3-none-any.whl |
|---|---|
| Size | 23.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f96ad0ccbe77ea0fea096e11c5c4571058abdc741ccb867d2aa9be20a8be666
|
|
BLAKE2b-256 checksum How to use checksums |
f83b89f05c177136f5d56df44182deb9aa24162ec689ccfa1f6bf014f7241abf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for mcpstat 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.