Skip to main content

Setup

from langsight.sdk import LangSightClient
from langsight.integrations.crewai import LangSightCrewAICallback
from crewai import Agent

client = LangSightClient(url="http://localhost:8000")

callback = LangSightCrewAICallback(
    client=client,
    server_name="my-mcp-server",
    agent_name="support-agent",   # optional
)

agent = Agent(
    role="Support Agent",
    tools=[my_mcp_tool],
    callbacks=[callback],          # ← one line added
)
Every tool call made by this agent is automatically traced in LangSight.

Callback methods

The LangSightCrewAICallback hooks into three CrewAI events:
EventFires whenRecords
on_tool_startTool call beginsStart timestamp
on_tool_endTool call succeedsLatency + SUCCESS status
on_tool_errorTool call failsLatency + ERROR status + error message