how do i log the mcp tools call made by the agent?
# ask-ai
b
how do i log the mcp tools call made by the agent?
t
Thanks for reaching out, Antonio. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to log MCP tool calls made by an agent — you can capture those calls by enabling OpenTelemetry tracing and exporting traces to an observability backend (example: LangFuse). Steps: 1. Set exporter environment variables (example for LangFuse): ◦ Set
OTEL_EXPORTER_OTLP_ENDPOINT
to your LangFuse OTLP endpoint (e.g.,
{host}/api/public/otel
). ◦ Set
OTEL_EXPORTER_OTLP_HEADERS
to include Basic auth:
Authorization=Basic {base64(public_key:secret_key)}
. 1. Initialize OpenTelemetry tracing in your app: ◦ Create a
TracerProvider
. ◦ Add a
BatchSpanProcessor
with an
OTLPSpanExporter
. ◦ Call
set_tracer_provider(trace_provider)
. 1. Activate tracing in the agent entrypoint: ◦ Call your tracing setup function (e.g.,
setup_langfuse()
) in the agent’s entrypoint before starting the agent loop so MCP tool calls are captured. When enabled, tool calls (including MCP server tool spans) are automatically recorded and sent to the trace backend where you can inspect them alongside LLM/STT/TTS spans. If you want, tell me: • which language or agent SDK you’re using, and • which backend (LangFuse or another OTLP-compatible) — I’ll give paste-ready code for that environment. Sources: Observability data hooks | LiveKit docs