opentelemetry trace querying via natural language
Exposes distributed traces and spans stored in Pydantic Logfire through an MCP tool interface that accepts natural language queries. The AsyncLogfireQueryClient handles HTTP communication with Logfire's REST API, translating user intent into structured queries against OpenTelemetry-formatted telemetry data. Integrates with FastMCP's tool registration system to expose query capabilities to LLM clients via JSON-RPC over stdio transport.
Unique: Bridges MCP protocol directly to Logfire's REST API via AsyncLogfireQueryClient, enabling LLMs to query production telemetry without custom integrations. Uses FastMCP's tool registration pattern to expose Logfire queries as first-class MCP tools with schema validation.
vs alternatives: Tighter integration with Logfire than generic observability tools because it's built by Pydantic and uses native Logfire API semantics, avoiding translation layers that other MCP servers might require.
exception detection and localization in source files
The find_exceptions_in_file tool queries Logfire for exceptions that occurred in a specific source file, returning stack traces with line numbers and context. Implements file-scoped exception filtering by querying OpenTelemetry exception spans and matching them against the provided file path. Results include full exception details, timestamps, and surrounding code context for rapid debugging.
Unique: Implements file-scoped exception filtering directly against Logfire's OpenTelemetry exception spans, with automatic stack trace extraction and line number mapping. Uses AsyncLogfireQueryClient to construct targeted queries that avoid full-table scans.
vs alternatives: More precise than generic error tracking tools because it filters by source file location, reducing noise and enabling developers to focus on exceptions in specific modules they're working on.
arbitrary sql querying against logfire datafusion database
The arbitrary_query tool exposes direct SQL access to Logfire's DataFusion-backed database, allowing users to execute custom queries against OpenTelemetry metrics, traces, and spans. Queries are executed via AsyncLogfireQueryClient's HTTP interface, with results returned as structured JSON. Enables power users and data analysts to perform complex aggregations, joins, and filtering beyond the scope of predefined tools.
Unique: Exposes Logfire's DataFusion backend directly through MCP, allowing arbitrary SQL execution without intermediate query builders or DSLs. AsyncLogfireQueryClient passes queries directly to Logfire's REST API, preserving full SQL expressiveness and DataFusion-specific functions.
vs alternatives: More flexible than predefined query tools because it allows arbitrary SQL, but requires more expertise; positioned for advanced users who need custom aggregations that generic observability tools cannot provide.
logfire ui trace link generation
The logfire_link tool generates direct URLs to specific traces in the Logfire web UI, enabling seamless navigation from LLM-assisted debugging back to the interactive Logfire dashboard. Takes a trace ID and constructs a properly formatted URL that opens the trace in Logfire's UI with full span visualization, metrics, and context. Implements URL construction logic that handles Logfire's project-scoped URL structure.
Unique: Implements project-aware URL construction that respects Logfire's multi-tenant architecture, generating links that automatically route to the correct project and trace. Tightly coupled to Logfire's URL scheme, avoiding generic link generation patterns.
vs alternatives: Simpler and more reliable than manual URL construction because it encodes Logfire's project scoping and URL structure, ensuring links always resolve correctly regardless of user's current Logfire context.
datafusion schema introspection and reference
The schema_reference tool queries Logfire's DataFusion database to retrieve table definitions, column names, types, and metadata, enabling users to understand the structure of available telemetry data. Executes schema queries via AsyncLogfireQueryClient and returns structured metadata that helps users construct valid SQL queries. Supports both full schema dumps and targeted table/column lookups.
Unique: Provides direct DataFusion schema introspection through MCP, allowing dynamic discovery of available telemetry tables and columns without external documentation. Queries Logfire's information_schema tables to return authoritative, up-to-date schema metadata.
vs alternatives: More accurate than static documentation because it reflects the actual current schema in Logfire, including custom attributes and project-specific tables that may not be documented elsewhere.
mcp server lifecycle management with fastmcp
Implements the MCP server runtime using FastMCP framework, handling stdio transport, JSON-RPC message routing, and tool registration. The app_factory function creates a FastMCP instance with a lifespan context that initializes AsyncLogfireQueryClient on startup and manages its lifecycle. Implements proper async context management to ensure Logfire client is available for all tool invocations and cleaned up on shutdown.
Unique: Uses FastMCP's lifespan context pattern to manage AsyncLogfireQueryClient initialization and cleanup, ensuring proper resource management across tool invocations. Implements stdio-based JSON-RPC transport that integrates with MCP client discovery and tool schema negotiation.
vs alternatives: More robust than manual MCP server implementations because FastMCP handles JSON-RPC protocol details, tool schema generation, and error handling, reducing boilerplate and potential bugs.
logfire api authentication and token resolution
Implements multi-source token resolution that checks command-line arguments, environment variables, and .env files to obtain Logfire read tokens. The main() CLI entry point uses this resolution logic to initialize AsyncLogfireQueryClient with proper credentials. Supports both explicit token passing and environment-based discovery, enabling flexible deployment across local development and production environments.
Unique: Implements cascading token resolution that checks multiple sources in priority order, allowing both explicit passing and environment-based discovery. Integrates with Python's dotenv library to support .env files without requiring external configuration tools.
vs alternatives: More flexible than single-source token passing because it supports multiple resolution strategies, enabling both local development workflows (.env files) and production deployments (env vars) without code changes.