Integrations
Claude Agent SDK (Python)
Trace Anthropic's Claude Agent SDK in Muster via LangSmith's OTel bridge.
The Claude Agent SDK is Anthropic's open-source framework for building AI agents with native MCP support. Muster captures Claude Agent SDK runs through the LangSmith OTel bridge, which forwards every agent step, tool call, and model response.
Setup
1. Install dependencies
%pip install langfuse claude-agent-sdk "langsmith[claude-agent-sdk]" "langsmith[otel]" -q2. Configure environment
import os
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..."
os.environ["LANGSMITH_OTEL_ENABLED"] = "true"
os.environ["LANGSMITH_OTEL_ONLY"] = "true"
os.environ["LANGSMITH_TRACING"] = "true"from langfuse import get_client
langfuse = get_client()
if langfuse.auth_check():
print("Muster client is authenticated and ready!")3. Wire up the OTel bridge
from langsmith.integrations.claude_agent_sdk import configure_claude_agent_sdk
configure_claude_agent_sdk()4. Build an agent with tools
import asyncio
from claude_agent_sdk import (
ClaudeAgentOptions,
ClaudeSDKClient,
tool,
create_sdk_mcp_server,
)
from typing import Any
@tool(
"get_weather",
"Gets the current weather for a given city",
{"city": str},
)
async def get_weather(args: dict[str, Any]) -> dict[str, Any]:
weather_data = {
"Berlin": "Cloudy, 59°F",
"New York": "Sunny, 75°F",
}
weather = weather_data.get(args["city"], "Weather data not available")
return {"content": [{"type": "text", "text": f"Weather in {args['city']}: {weather}"}]}
async def main():
weather_server = create_sdk_mcp_server(
name="weather",
version="1.0.0",
tools=[get_weather],
)
options = ClaudeAgentOptions(
model="claude-sonnet-4-5-20250929",
system_prompt="You are a friendly travel assistant.",
mcp_servers={"weather": weather_server},
allowed_tools=["mcp__weather__get_weather"],
)
async with ClaudeSDKClient(options=options) as client:
await client.query("What's the weather like in Berlin and New York?")
async for message in client.receive_response():
print(message)
await main()5. View the trace
