Skip to main content
MCPAgent can attach LangChain callbacks to each run. Use observability to inspect prompts, model calls, tool calls, errors, latency, metadata, and tags. Observability is enabled by default. If no supported callback integration is configured, the agent runs normally without traces.

Enable Langfuse

Set Langfuse credentials before the agent initializes. mcp-use auto-detects them and installs the Langfuse callback handler.
Call flush() before a serverless function exits so buffered traces have time to send.

Add metadata and tags

Use metadata for trace attributes and tags for filtering. Metadata keys are sanitized, object values must be serializable, and large serialized values are truncated.

Use custom callbacks

Pass custom LangChain callbacks when you want to use your own Langfuse handler or another tracing platform. Custom callbacks replace auto-detected callbacks for the agent.

Disable observability

Set observe: false when you do not want the agent to look for observability integrations.
You can also disable Langfuse auto-detection with MCP_USE_LANGFUSE=false.

What traces include

Configured callbacks receive the LangChain run tree for agent execution. Depending on the callback platform, traces can include model calls, streamed chunks, tool calls, tool inputs and outputs, errors, timing, metadata, tags, and conversation flow.

Next steps