Logfire MCP Server
Query OpenTelemetry traces, metrics, and logs from Pydantic Logfire using SQL, then surface exceptions and link back to the Logfire UI.
The Logfire MCP server gives LLMs read access to the OpenTelemetry traces, metrics, and logs you have sent to Pydantic Logfire. Agents can search for recent exceptions, run arbitrary SQL queries against the underlying DataFusion database, inspect the database schema, and generate deep links back to the Logfire web UI for a human to inspect a trace. It is intended for debugging, incident response, and exploratory analysis of production telemetry from inside a coding agent or chat client.
Pydantic now operates a hosted remote MCP server at https://logfire-us.pydantic.dev/mcp (and an EU equivalent), which is the recommended way to connect. Authentication is handled in the browser on first connection via OAuth, or with a Bearer API token in sandboxed environments. The original STDIO server published on PyPI as logfire-mcp and its source at github.com/pydantic/logfire-mcp is now archived in favor of the remote server, which Pydantic iterates on more quickly.
Because the server speaks to Logfire's OpenTelemetry-native query API, any data shape Logfire supports (Python, Node, Rust, Go, Pydantic AI traces, FastAPI instrumentation, custom OTel exporters, etc.) is queryable through the same arbitrary_query tool, making this a general-purpose observability backend for agents.
Tools
| Tool | Description |
|---|---|
find_exceptions_in_file |
Get details about the 10 most recent exceptions recorded for a given source file. |
arbitrary_query |
Run a custom SQL query against the Logfire DataFusion database holding your traces, logs, and metrics. |
schema_reference |
Return the schema of the Logfire database so the LLM can write valid SQL against it. |
logfire_link |
Generate a Logfire UI link for a specific trace so a human can open it in the browser. |
Recommended: remote MCP server
The remote server is hosted by Pydantic. There is nothing to install. Pick the region matching your Logfire project:
- US:
https://logfire-us.pydantic.dev/mcp - EU:
https://logfire-eu.pydantic.dev/mcp
On first connect the server opens a browser window to authenticate against your Logfire account. For headless/sandboxed clients, generate an API key with project:read scope and send it as a Bearer token.
Cursor (.cursor/mcp.json)
{
"mcpServers": {
"logfire": {
"type": "http",
"url": "https://logfire-us.pydantic.dev/mcp"
}
}
}
Claude Desktop
{
"mcpServers": {
"logfire": {
"type": "http",
"url": "https://logfire-us.pydantic.dev/mcp"
}
}
}
VS Code (.vscode/mcp.json)
{
"servers": {
"logfire": {
"type": "http",
"url": "https://logfire-us.pydantic.dev/mcp"
}
}
}
Claude Code
claude mcp add logfire --transport http https://logfire-us.pydantic.dev/mcp
Legacy: local STDIO server (archived)
The original logfire-mcp PyPI package is still installable but no longer maintained. It requires uv and a project-scoped read token from https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens.
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "pylf_v1_us_..."
}
}
}
}
For self-hosted Logfire, set LOGFIRE_BASE_URL to your deployment URL.
- Debug a production incident by asking the agent to pull the last hour of exceptions for a specific file or service and summarize the stack traces.
- Run ad hoc SQL over traces and spans to compute p95 latency, error rate, or token usage per endpoint without leaving your editor.
- Triage a noisy alert: have the agent fetch the offending trace, summarize it, then hand back a
logfire_linkfor a human to open. - Audit Pydantic AI / LLM agent runs that have been instrumented with Logfire to find the prompts, tool calls, and costs of slow or failing requests.
- Generate weekly reliability reports by running
arbitrary_queryacross the OTel data and asking the model to write up the findings.
- "Find the 10 most recent exceptions in
services/checkout/payments.pyfrom the last 24 hours and group them by error type." - "Write a SQL query against Logfire to get p95 latency per HTTP route for the last hour, then run it."
- "Show me the schema of the Logfire database so I can ask better questions about my traces."
- "Look up trace
0x7a9c...and give me a Logfire link plus a one paragraph summary of what went wrong." - "Across the last 7 days, which Pydantic AI agent runs had the highest token cost? Return the top 20 with their trace IDs."
- Official server maintained by Pydantic, the team that builds Logfire.
- Remote hosted option needs zero local setup and handles auth in the browser.
arbitrary_query+schema_referencegives the agent full SQL access to the OTel store, not just a fixed set of canned queries.- Works with both Logfire cloud (US/EU) and self-hosted deployments.
- Read-only: you cannot create alerts, dashboards, or modify project settings from the MCP server.
- The original local STDIO package on PyPI/GitHub is archived; new features land only in the remote server.
- Queries are capped at a 30 day window via the
ageparameter, which limits longer historical analyses.
- Grafana MCP server for querying Prometheus, Loki, and Tempo from an agent.
- Sentry MCP server if your error tracking lives in Sentry rather than Logfire.
- Honeycomb MCP server for OpenTelemetry traces hosted in Honeycomb.