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 分

    请在仓库或注册中心条目中声明许可证。