OPEN SOURCE · APACHE 2.0

MCP Python Hooks

A lightweight Python sensor for MCP servers. Wrap any Python-based MCP server at startup and capture tool invocations, session activity, module imports, and subprocess activity as structured runtime events. No code changes. No proxy. No SDK to integrate.

Install

pip install bluerock[oss]

Run

mkdir -p ~/.bluerock

cat > ~/.bluerock/bluerock-oss.json << 'EOF'

{"enable": true, "imports": {"enable": true}, "mcp": true}

EOF

python -m bluepython --oss --cfg-dir ~/.bluerock your_script.py

Wraps your script at startup. The original script runs unchanged.

View events

cat ~/.bluerock/event-spool/python-*.ndjson | jq .event

What It Captures

MCP protocol events

Server initialization, tool/resource registration, protocol messages, session lifecycle, client connections - Module imports

Every module loaded across the full execution environment, with SHA-256 hash, version, and filesystem path

Subprocess activity and security-sensitive system operations

Startup-level instrumentation — captures behavior from interpreter start, including dependencies you didn’t write

Event Format

Events are written as NDJSON — one JSON object per line. Route into OpenTelemetry, Grafana, or any log pipeline.

{

"ts": "2026-04-02T10:00:00.123456Z",

"event": {

"meta": {"name": "python_mcp_server_init", "type": "event", "origin": "bluepython"},

"context": {"process": {"pid": 12345}},

"server": {"name": "test-server", "version": "0.0.1"}

}

}

Resources

Item Link
Repo github.com/bluerock-io/bluerock
Event schema EVENTS.md
Configuration CONFIG.md
Examples examples/
License Apache 2.0
Platform support Linux + macOS • Python 3.10–3.13
Announcement Read the launch post →