Claude Agent SDK는 Claude를 사용하여 에이전트 애플리케이션을 구축하기 위한 SDK입니다. LangSmith는 Claude Agent SDK와의 네이티브 통합을 제공하여 에이전트 실행, tool 호출 및 Claude 모델과의 상호작용을 자동으로 추적합니다.

설치

Claude Agent SDK용 LangSmith 통합을 설치합니다
pip install "langsmith[claude-agent-sdk]"

빠른 시작

Claude Agent SDK 애플리케이션에서 LangSmith 추적을 활성화하려면 애플리케이션 시작 시 configure_claude_agent_sdk()를 호출하세요:
import asyncio
from claude_agent_sdk import (
    ClaudeAgentOptions,
    ClaudeSDKClient,
    tool,
    create_sdk_mcp_server,
)
from typing import Any

from langsmith.integrations.claude_agent_sdk import configure_claude_agent_sdk

# Setup claude_agent_sdk with langsmith tracing
configure_claude_agent_sdk()

@tool(
    "get_weather",
    "Gets the current weather for a given city",
    {
        "city": str,
    },
)
async def get_weather(args: dict[str, Any]) -> dict[str, Any]:
    """Simulated weather lookup tool"""
    city = args["city"]

    # Simulated weather data
    weather_data = {
        "San Francisco": "Foggy, 62°F",
        "New York": "Sunny, 75°F",
        "London": "Rainy, 55°F",
        "Tokyo": "Clear, 68°F",
    }

    weather = weather_data.get(city, "Weather data not available")
    return {"content": [{"type": "text", "text": f"Weather in {city}: {weather}"}]}


async def main():
    # Create SDK MCP server with the weather tool
    weather_server = create_sdk_mcp_server(
        name="weather",
        version="1.0.0",
        tools=[get_weather],
    )

    options = ClaudeAgentOptions(
        model="claude-sonnet-4-5",
        system_prompt="You are a friendly travel assistant who helps with weather information.",
        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 San Francisco and Tokyo?")

        async for message in client.receive_response():
            print(message)


if __name__ == "__main__":
    asyncio.run(main())
설정이 완료되면 다음을 포함한 모든 Claude Agent SDK 작업이 자동으로 LangSmith에 추적됩니다:
  • Agent 쿼리 및 응답
  • Tool 호출 및 결과
  • Claude 모델 상호작용
  • MCP server 작업

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I