{"id":26570924,"url":"https://github.com/pydantic/logfire-mcp","last_synced_at":"2025-06-22T06:08:26.889Z","repository":{"id":282059954,"uuid":"943883428","full_name":"pydantic/logfire-mcp","owner":"pydantic","description":"The Logfire MCP Server is here! :tada:","archived":false,"fork":false,"pushed_at":"2025-05-07T09:41:39.000Z","size":76,"stargazers_count":77,"open_issues_count":5,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-16T00:19:10.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pydantic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-06T12:26:11.000Z","updated_at":"2025-06-12T16:57:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f555b83-0a32-4075-80b8-2f74b8570fd3","html_url":"https://github.com/pydantic/logfire-mcp","commit_stats":null,"previous_names":["pydantic/logfire-mcp"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pydantic/logfire-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Flogfire-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Flogfire-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Flogfire-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Flogfire-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pydantic","download_url":"https://codeload.github.com/pydantic/logfire-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Flogfire-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261244049,"owners_count":23129643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-22T22:19:22.381Z","updated_at":"2025-06-22T06:08:21.865Z","avatar_url":"https://github.com/pydantic.png","language":"Python","readme":"# Logfire MCP Server\n\nThis repository contains a Model Context Protocol (MCP) server with tools that can access the OpenTelemetry traces and\nmetrics you've sent to Logfire.\n\nThis MCP server enables LLMs to retrieve your application's telemetry data, analyze distributed\ntraces, and make use of the results of arbitrary SQL queries executed using the Logfire APIs.\n\n## Available Tools\n\n* `find_exceptions` - Get exception counts from traces grouped by file\n  * Required arguments:\n    * `age` (int): Number of minutes to look back (e.g., 30 for last 30 minutes, max 7 days)\n\n* `find_exceptions_in_file` - Get detailed trace information about exceptions in a specific file\n  * Required arguments:\n    * `filepath` (string): Path to the file to analyze\n    * `age` (int): Number of minutes to look back (max 7 days)\n\n* `arbitrary_query` - Run custom SQL queries on your OpenTelemetry traces and metrics\n  * Required arguments:\n    * `query` (string): SQL query to execute\n    * `age` (int): Number of minutes to look back (max 7 days)\n\n* `get_logfire_records_schema` - Get the OpenTelemetry schema to help with custom queries\n  * No required arguments\n\n## Setup\n### Install `uv`\n\nThe first thing to do is make sure `uv` is installed, as `uv` is used to run the MCP server.\n\nFor installation instructions, see the [`uv` installation docs](https://docs.astral.sh/uv/getting-started/installation/).\n\nIf you already have an older version of `uv` installed, you might need to update it with `uv self update`.\n\n### Obtain a Logfire read token\nIn order to make requests to the Logfire APIs, the Logfire MCP server requires a \"read token\".\n\nYou can create one under the \"Read Tokens\" section of your project settings in Logfire:\nhttps://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens\n\n\u003e [!IMPORTANT]\n\u003e Logfire read tokens are project-specific, so you need to create one for the specific project you want to expose to the Logfire MCP server.\n\n### Manually run the server\nOnce you have `uv` installed and have a Logfire read token, you can manually run the MCP server using `uvx` (which is provided by `uv`).\n\nYou can specify your read token using the `LOGFIRE_READ_TOKEN` environment variable:\n\n```bash\nLOGFIRE_READ_TOKEN=YOUR_READ_TOKEN uvx logfire-mcp\n```\n\nor using the `--read-token` flag:\n\n```bash\nuvx logfire-mcp --read-token=YOUR_READ_TOKEN\n```\n\u003e [!NOTE]  \n\u003e If you are using Cursor, Claude Desktop, Cline, or other MCP clients that manage your MCP servers for you, you **_do\n    NOT_** need to manually run the server yourself. The next section will show you how to configure these clients to make \n    use of the Logfire MCP server.\n\n## Configuration with well-known MCP clients\n\n### Configure for Cursor\n\nCreate a `.cursor/mcp.json` file in your project root:\n\n```json\n{\n  \"mcpServers\": {\n    \"logfire\": {\n      \"command\": \"uvx\",\n      \"args\": [\"logfire-mcp\", \"--read-token=YOUR-TOKEN\"]\n    }\n  }\n}\n```\n\nThe Cursor doesn't accept the `env` field, so you need to use the `--read-token` flag instead.\n\n### Configure for Claude Desktop\n\nAdd to your Claude settings:\n\n```json\n{\n  \"command\": [\"uvx\"],\n  \"args\": [\"logfire-mcp\"],\n  \"type\": \"stdio\",\n  \"env\": {\n    \"LOGFIRE_READ_TOKEN\": \"YOUR_TOKEN\"\n  }\n}\n```\n\n### Configure for Cline\n\nAdd to your Cline settings in `cline_mcp_settings.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"logfire\": {\n      \"command\": \"uvx\",\n      \"args\": [\"logfire-mcp\"],\n      \"env\": {\n        \"LOGFIRE_READ_TOKEN\": \"YOUR_TOKEN\"\n      },\n      \"disabled\": false,\n      \"autoApprove\": []\n    }\n  }\n}\n```\n\n### Customization - Base URL\n\nBy default, the server connects to the Logfire API at `https://logfire-api.pydantic.dev`. You can override this by:\n\n1. Using the `--base-url` argument:\n```bash\nuvx logfire-mcp --base-url=https://your-logfire-instance.com\n```\n\n2. Setting the environment variable:\n```bash\nLOGFIRE_BASE_URL=https://your-logfire-instance.com uvx logfire-mcp\n```\n\n## Example Interactions\n\n1. Find all exceptions in traces from the last hour:\n```json\n{\n  \"name\": \"find_exceptions\",\n  \"arguments\": {\n    \"age\": 60\n  }\n}\n```\n\nResponse:\n```json\n[\n  {\n    \"filepath\": \"app/api.py\",\n    \"count\": 12\n  },\n  {\n    \"filepath\": \"app/models.py\",\n    \"count\": 5\n  }\n]\n```\n\n2. Get details about exceptions from traces in a specific file:\n```json\n{\n  \"name\": \"find_exceptions_in_file\",\n  \"arguments\": {\n    \"filepath\": \"app/api.py\",\n    \"age\": 1440\n  }\n}\n```\n\nResponse:\n```json\n[\n  {\n    \"created_at\": \"2024-03-20T10:30:00Z\",\n    \"message\": \"Failed to process request\",\n    \"exception_type\": \"ValueError\",\n    \"exception_message\": \"Invalid input format\",\n    \"function_name\": \"process_request\",\n    \"line_number\": \"42\",\n    \"attributes\": {\n      \"service.name\": \"api-service\",\n      \"code.filepath\": \"app/api.py\"\n    },\n    \"trace_id\": \"1234567890abcdef\"\n  }\n]\n```\n\n3. Run a custom query on traces:\n```json\n{\n  \"name\": \"arbitrary_query\",\n  \"arguments\": {\n    \"query\": \"SELECT trace_id, message, created_at, attributes-\u003e\u003e'service.name' as service FROM records WHERE severity_text = 'ERROR' ORDER BY created_at DESC LIMIT 10\",\n    \"age\": 1440\n  }\n}\n```\n\n## Examples of Questions for Claude\n\n1. \"What exceptions occurred in traces from the last hour across all services?\"\n2. \"Show me the recent errors in the file 'app/api.py' with their trace context\"\n3. \"How many errors were there in the last 24 hours per service?\"\n4. \"What are the most common exception types in my traces, grouped by service name?\"\n5. \"Get me the OpenTelemetry schema for traces and metrics\"\n6. \"Find all errors from yesterday and show their trace contexts\"\n\n## Getting Started\n\n1. First, obtain a Logfire read token from:\n   https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens\n\n2. Run the MCP server:\n   ```bash\n   uvx logfire-mcp --read-token=YOUR_TOKEN\n   ```\n\n3. Configure your preferred client (Cursor, Claude Desktop, or Cline) using the configuration examples above\n\n4. Start using the MCP server to analyze your OpenTelemetry traces and metrics!\n\n## Contributing\n\nWe welcome contributions to help improve the Logfire MCP server. Whether you want to add new trace analysis tools, enhance metrics querying functionality, or improve documentation, your input is valuable.\n\nFor examples of other MCP servers and implementation patterns, see the [Model Context Protocol servers repository](https://github.com/modelcontextprotocol/servers).\n\n## License\n\nLogfire MCP is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License.\n","funding_links":[],"categories":["Monitoring \u0026 Observability","Monitoring","Uncategorized","Production-Ready Servers","🤖 AI/ML","Legend","サーバー実装","Monitoring and Logging","Official Servers","官方 MCP 服务器列表","📊 Monitoring \u0026 Observability","Table of Contents","📚 Projects (2474 total)","🗂️ Extensions by Category","Code \u0026 Developer Tools"],"sub_categories":["Video","Uncategorized","📊 \u003ca name=\"monitoring\"\u003e\u003c/a\u003eMonitoring","📊 \u003ca name=\"monitoring\"\u003e\u003c/a\u003e監視","How to Submit","Monitoring","MCP Servers","⚙️ Development Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydantic%2Flogfire-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpydantic%2Flogfire-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydantic%2Flogfire-mcp/lists"}