Observe Instrument Mcp

io.github.alanzha2由 GitHub 帳號 alanzha2 發布v0.1.2更新於 Oct 24, 2026

Add OpenTelemetry tracing to Python AI agents. Supports LangGraph, LlamaIndex, CrewAI, OpenAI SDK.

概覽

AI 產生的概覽

一個 MCP 伺服器,透過改寫 Python AI 代理程式碼來加入以 OpenTelemetry 為基礎的追蹤、指標與日誌。

可以做什麼
它提供兩個工具:instrument_agent 讀取 Python 代理檔案,套用完整的 ioa-observe-sdk 插樁,寫回檔案並回傳變更摘要;check_instrumentation 在不修改檔案的情況下稽核缺少的插樁。支援 LlamaIndex、LangGraph、CrewAI 與原生 OpenAI SDK。修改前會建立 .bak 備份。
適用情境
當你有一個以受支援框架建置的 Python AI 代理,並希望以最少的手動編輯加入以 OpenTelemetry 為基礎的追蹤、指標與日誌時使用。它也適合稽核現有代理檔案,查看缺少哪些插樁。
執行需求
以本機 stdio 程序執行,從 PyPI 安裝(pip install observe-instrument-mcp 或 uv add observe-instrument-mcp)。需要所選 LLM 供應商的 API 金鑰:ANTHROPIC_API_KEY(預設)、OPENAI_API_KEY、GEMINI_API_KEY 或 GROQ_API_KEY;Ollama 不需要金鑰。LLM_MODEL 用於選擇模型。插樁後,專案需要 ioa-observe-sdk 以及 OTel Collector 與 ClickHouse 堆疊。
安裝前請注意
instrument_agent 工具會寫入並改寫你的 Python 代理檔案,但會先建立 .bak 備份。它需要 LLM 供應商 API 金鑰,例如 ANTHROPIC_API_KEY 或 OPENAI_API_KEY,並在 MCP 伺服器設定中傳入。插樁後的代理會將遙測資料傳送到設定的 OTLP 端點,請確認追蹤資料的去向。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Observe Instrument Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

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.

Installation

bash
pip install observe-instrument-mcp# oruv 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:

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:

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

Windsurf

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

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

VariableDescription
LLM_MODELModel to use (default: claude-sonnet-4-6). See provider table below.
ANTHROPIC_API_KEYRequired for Anthropic models
OPENAI_API_KEYRequired for OpenAI models
GEMINI_API_KEYRequired for Google Gemini models
GROQ_API_KEYRequired for Groq models

Supported providers

ProviderKey variableLLM_MODEL example
AnthropicANTHROPIC_API_KEYclaude-sonnet-4-6
OpenAIOPENAI_API_KEYgpt-4o
Google GeminiGEMINI_API_KEYgemini/gemini-2.0-flash
GroqGROQ_API_KEYgroq/llama-3.3-70b
Ollama (local, free)noneollama/llama3.2

After instrumentation

Install the SDK in your project:

bash
pip install ioa-observe-sdk# oruv add ioa-observe-sdk

Start the observability stack (OTel Collector + ClickHouse):

bash
cd path/to/observe/deploydocker compose up -d

Run your agent:

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

Query traces:

bash
docker exec -it clickhouse-server clickhouse-client --user admin --password admin
sql
SELECT SpanName, ServiceName, Duration / 1000000. AS ms, TimestampFROM otel_tracesORDER BY Timestamp DESCLIMIT 20;

Development

bash
git clone https://github.com/alanzha2/observe-instrument-mcpcd observe-instrument-mcppip install -e .
# Test the server locallymcp dev observe_instrument_mcp/server.py

License

Apache-2.0

來源:README.md,提交 4c7ab11

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。