Skip to main content
Glama
observe-instrument-mcp

observe-instrument-mcp

by alanzha2

observe-instrument-mcp

An MCP server that automatically instruments Python AI agents with the ioa-observe-sdk — adding OpenTelemetry-based tracing, metrics, and logs with zero manual effort.

Works with any MCP-compatible AI coding assistant: Claude Desktop, Cursor, Windsurf, and others.

What it does

Two tools:

instrument_agent — reads a Python agent file, applies full observe SDK instrumentation, writes it back, and returns a summary of changes. Creates a .bak backup before modifying.

check_instrumentation — audits a file for missing instrumentation without modifying it.

Supported frameworks: LlamaIndex, LangGraph, CrewAI, raw OpenAI SDK.

Related MCP server: cursor-otel

Installation

pip install observe-instrument-mcp
# or
uv add observe-instrument-mcp

Requires an API key for your chosen LLM provider. Defaults to Claude (ANTHROPIC_API_KEY). See supported providers below.

Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "observe-instrument": {
      "command": "uvx",
      "args": ["observe-instrument-mcp"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "observe-instrument": {
      "command": "uvx",
      "args": ["observe-instrument-mcp"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "observe-instrument": {
      "command": "uvx",
      "args": ["observe-instrument-mcp"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Examples

Ready-to-use uninstrumented agent files are included in the examples/ folder:

examples/
  single-agent/
    openai-sdk-example.py      # OpenAI SDK customer support agent
    langgraph-example.py       # LangGraph currency converter
    llama-index-example.py     # LlamaIndex math agent
    crewai-example.py          # CrewAI research crew
  multi-agent/
    openai-sdk-multi-agent-example.py   # OpenAI SDK orchestrator pipeline
    langgraph-multi-agent-example.py    # LangGraph supervisor pattern
    llama-index-multi-agent-example.py  # LlamaIndex research + writing pipeline
    crewai-multi-agent-example.py       # CrewAI research + publishing crews

Usage

Once configured, ask your AI assistant:

Instrument my agent with the observe SDK: path/to/my_agent.py
Check what observe SDK instrumentation is missing from path/to/my_agent.py

Environment variables

Variable

Description

LLM_MODEL

Model to use (default: claude-sonnet-4-6). See provider table below.

ANTHROPIC_API_KEY

Required for Anthropic models

OPENAI_API_KEY

Required for OpenAI models

GEMINI_API_KEY

Required for Google Gemini models

GROQ_API_KEY

Required for Groq models

Supported providers

Provider

Key variable

LLM_MODEL example

Anthropic

ANTHROPIC_API_KEY

claude-sonnet-4-6

OpenAI

OPENAI_API_KEY

gpt-4o

Google Gemini

GEMINI_API_KEY

gemini/gemini-2.0-flash

Groq

GROQ_API_KEY

groq/llama-3.3-70b

Ollama (local, free)

none

ollama/llama3.2

After instrumentation

Install the SDK in your project:

pip install ioa-observe-sdk
# or
uv add ioa-observe-sdk

Start the observability stack (OTel Collector + ClickHouse):

cd path/to/observe/deploy
docker compose up -d

Run your agent:

OPENAI_API_KEY=sk-... OTLP_HTTP_ENDPOINT=http://localhost:4318 python my_agent.py

Query traces:

docker exec -it clickhouse-server clickhouse-client --user admin --password admin
SELECT SpanName, ServiceName, Duration / 1000000. AS ms, Timestamp
FROM otel_traces
ORDER BY Timestamp DESC
LIMIT 20;

Development

git clone https://github.com/alanzha2/observe-instrument-mcp
cd observe-instrument-mcp
pip install -e .

# Test the server locally
mcp dev observe_instrument_mcp/server.py

License

Apache-2.0

Available Tools

2 tools
check_instrumentationA
Read-onlyIdempotent

Audit a Python AI agent file for missing ioa-observe-sdk instrumentation.

Read-only — does not modify the file. Use instrument_agent to apply changes.

Args: file_path: Path to the Python file to audit.

Returns: Audit report: what is present, what is missing, and specific recommendations.

Inputs: file_path (required). Returns: result

instrument_agentA

Read a Python AI agent file, add ioa-observe-sdk instrumentation, and write it back.

Adds Observe.init(), SDK imports, @tool/@agent/@graph/@workflow decorators, and session_start() — covering LlamaIndex, LangGraph, CrewAI, and raw OpenAI SDK agents. Creates a .bak backup before modifying the file.

Args: file_path: Path to the Python file to instrument. app_name: Optional app name for Observe.init(). Inferred from file if omitted.

Returns: Summary of all changes made, the diff, and next steps.

Inputs: file_path (required), app_name. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one audits for missing instrumentation (read-only), the other applies the instrumentation (modifies the file). There is no overlap or ambiguity.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun snake_case pattern: check_instrumentation and instrument_agent. The naming is clear and predictable.

    Tool Count4/5

    With only 2 tools, the server is minimal but appropriately scoped for its specific workflow of auditing and instrumenting Python AI agent files. It is slightly below the typical 3-15 range but still well-focused.

    Completeness5/5

    The tool set covers the full lifecycle for the stated purpose: check for missing instrumentation and apply it. There is no obvious gap—the backup creation in instrument_agent provides a safety net.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Provides comprehensive monitoring and observability for MCP server ecosystems with real-time health checks, performance metrics, distributed tracing, anomaly detection, and automated performance reports using OpenTelemetry and Prometheus.
      22
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that instruments Cursor AI agent interactions with OpenTelemetry traces and logs to monitor agent turns and performance. It enables tracking of user queries, assistant responses, and tool usage through GenAI-compliant telemetry spans.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server that gives AI agents access to your application's OpenTelemetry traces for querying, analysis, and debugging.
      5
      17 npm
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that demonstrates comprehensive observability with Sentry, OpenTelemetry, and Braintrust, providing tools for file, data, and HTTP operations along with real-time status and configuration resources.
      MIT