Skip to main content

🔍 AIMonitor

A lightweight, modular observability toolkit for MCP (Multi-Channel Processing) workflows

Python 3.10+ License Tests

AIMonitor tracks tool execution, exports monitoring events, and supports OpenTelemetry integration alongside file, SQLite, and Prometheus backends.

✨ Features

  • 🎯 Tool Monitoring — Automatic event capture with @monitor_tool decorator
  • 📤 Multiple Exporters — File, SQLite, Prometheus, Redis, Kafka, Webhook, OpenTelemetry
  • 🔐 Sensitive Data Redaction — Automatically masks API keys and secrets
  • 🧠 Internal Telemetry — Optional SDK observability via OpenTelemetry
  • ⚡ Async-first — Built for async workflows
  • 🛠️ Extensible — Simple interface for custom exporters

🚀 Quick start

Install

pip install ai-monitor-sdk

This will install the most basic implementation of AIMonitor, but most exporters will not work with it, as it depends on their own sdk to use them. Run the following command to install their optional dependencies depending on which exporters you want to make use of.

pip install "ai-monitor-sdk[opentelemetry,sqlite,prometheus,kafka]"

Exporters

In AIMonitor, an Exporter refers to a class that inherits from BaseExporter class. Their purpose is to serve as a client to your custom storage for tool traces, tokens, etc. As such, AIMonitor comes with a set of programmed exporters:

🔌 Available Exporters

Exporter Purpose Status
FileExporter JSONL file output with rotation ✅ Stable
SQLiteExporter Local database storage ✅ Stable
PrometheusExporter Prometheus metrics endpoint ⚠️ On development
OpenTelemetryExporter OTel span export ✅ Stable
WebhookExporter HTTP endpoint POST ✅ Stable
KafkaExporter Kafka topic producer ✅ Stable
PostgreSQLExporter Postgres implementation ❌ Coming on future releases
MongoDBExporter MongoDb implementation ❌ Coming on future releases

However, AIMonitor is designed as a flexible sdk, meaning you can create your own custom exporters as long as you follow the contract explained later on the documentation of this repo.

🔧 Configuration

AIMonitor is thought from the beginning with one core idea: simple configuration. As such, setting up exporters requires only two simple steps

  • Create a YAML/JSON config file following the example below. This will be used as the source of truth for your exporters' configuration
app:
  env: ENV
tracking:
  enabled: true
  track_metrics: true
  track_events: true
  track_logs: true
telemetry:
  inner_telemetry: false
  healthcheck_enabled: true
  healthcheck_interval: 60
exporters:
  kafka:
    enabled: true
    bootstrap_servers: "localhost:9092"
    producer:
      acks: "all"
      retries: 3
      linger_ms: 5
      compression: "none"
      batch_size: 2048
      max_workers: 12
  prometheus:
    enabled: true
    url: "http://localhost:9000"
  file:
    enabled: true
    path: "./logs"
  • Inside the lifespan of your desired server, execute the initialize_monitor function
from aimonitor.bootstrap import initialize_monitor, shutdown_monitor
from contextlib import asynccontextmanager
from fastapi import FastAPI

@asynccontextmanager
async def lifespan(app: FastAPI):
    await initialize_monitor(config_path="aimonitor_config.yaml")
	yield
	await shutdown_monitor()

app = FastAPI(lifespan=lifespan)


@app.get("/")
async def hello_world():
    return {"msg": "Hellow World!", "status": 200}

AIMonitor is fully async with options for syncronicity if necessary. The SDK also allows to use JSON files for the config file as well as using env variables, starting with AIMONITOR_. Refer to the documentation for extra examples and description.

Monitor a tool

AIMonitor allows you to monitor tools that are executed by an LLM or even tools executed through the MCP protocol, on an MCP server. The most basic example is this one

from aimonitor.core.decorators import monitor_tool

@monitor_tool
async def fetch_data(user_id: str):
    return {"data": "example"}

Assuming we are using FastMCP to create an mcp server, we can set up

from aimonitor.core.decorators import monitor_tool
from fastmcp import FastMCP
from aimonitor.bootstrap import initialize_monitor, shutdown_monitor
from contextlib import asynccontextmanager
from fastapi import FastAPI

@asynccontextmanager
async def lifespan(app: FastAPI):
    await initialize_monitor(config_path="aimonitor_config.yaml")
	yield
	await shutdown_monitor()

mcp = FastMCP(name="CalculatorServer", lifespan=lifespan)

@mcp.tool
@monitor_tool(track_duration=False, track_tool_count=True)
def add(a: int, b: int) -> int:
    """Adds two integer numbers together."""
    return a + b

Refer to the documentation on usage for further explanation on how to set up

Export events

from aimonitor.exporters.file import FileExporter
from aimonitor.core.registry import registry

exporter = FileExporter(base_uri="./logs")
await exporter.connect()
registry.register(exporter)

# Now all monitored tool calls are exported to ./logs

📚 Documentation

🧪 Testing

Run the test suite:

# Unit tests
python -m pytest tests/unit -q

# Integration tests
# Run furst the setup scripts foumd om /scripts

# kafka
sh scripts/prometheus/sh/run_prometheus.sh
# prometheus
sh scripts/kafka/sh/run_kafka.sh

python -m pytest tests/integration

# All tests
python -m pytest tests/ -v

Tests run automatically on every PR to main. Scripts for batch/Powershell are also found under the /batch subfolder for test running

📦 Deployment

Publish to PyPI

# Update version in pyproject.toml
python -m build
python -m twine upload dist/*

Docker

AIMonitor works in containerized environments. Set environment variables and mount config files as needed.

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

  1. Fork the repo
  2. Create a feature branch
  3. Add tests for new features
  4. Open a PR to main

📄 License

MIT License — see LICENSE for details.

🎯 Roadmap

  • Enhanced A2A (Agent-to-Agent) support
  • Skills framework integration
  • Web dashboard for event visualization
  • Advanced filtering and querying
  • Multi-backend batch export

Questions? Open an issue or check the docs.

Metadata

Release files for ai-monitor-sdk 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-monitor-sdk 0.0.2
File Size Uploaded Provenance Actions
ai_monitor_sdk-0.0.2.tar.gz 38.0 kB With provenance Details for ai_monitor_sdk-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-monitor-sdk 0.0.2
File Interpreter ABI Platform Actions
ai_monitor_sdk-0.0.2-py3-none-any.whl Python 3 none any Details for ai_monitor_sdk-0.0.2-py3-none-any.whl

Total release size: 85.7 kB

Release files / ai_monitor_sdk-0.0.2.tar.gz

Download URL ai_monitor_sdk-0.0.2.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cbad4a493dae4ae435ebd3163ec15bdb0873dca80c8e4eebe3adbf16b8f123db
BLAKE2b-256 checksum
How to use checksums
0cb399bc0297d9ac8a65734aa51f2aa80d6489f96a38bc6de7c26ce1dc8debd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / ai_monitor_sdk-0.0.2-py3-none-any.whl

Download URL ai_monitor_sdk-0.0.2-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b85f28af80f7280139df393b938eeaba7415a88b3a90c3132e3338fc4bd50dc2
BLAKE2b-256 checksum
How to use checksums
f5386720c698cbd4a0842a1055f4f466a2936d2faf08813b31cc149155d66fe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Security for ai-monitor-sdk 0.0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ai_monitor_sdk-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page