Serveur Logfire Mcp
Aperçu
Qu'est-ce que Logfire MCP ?
Logfire MCP est une solution serveur innovante développée par l'organisation Pydantic. Elle sert de plateforme robuste conçue pour améliorer les capacités de journalisation et rationaliser les processus de gestion des données. Avec son interface conviviale et ses fonctionnalités puissantes, Logfire MCP vise à simplifier les complexités de la gestion des journaux pour les développeurs et les organisations.
Fonctionnalités de Logfire MCP
- Interface Conviviale : Logfire MCP offre une interface intuitive qui permet aux utilisateurs de naviguer facilement à travers ses fonctionnalités.
- Journalisation en Temps Réel : Le serveur fournit des capacités de journalisation en temps réel, permettant aux utilisateurs de surveiller et d'analyser les journaux au fur et à mesure qu'ils se produisent.
- Gestion des Données : Logfire MCP simplifie la gestion des données en permettant aux utilisateurs de catégoriser, filtrer et rechercher des journaux de manière efficace.
- Capacités d'Intégration : Le serveur peut être intégré à diverses applications et services, améliorant ainsi sa fonctionnalité et son utilisation.
- Scalabilité : Logfire MCP est conçu pour évoluer avec vos besoins, s'adaptant à des volumes de données croissants sans compromettre les performances.
Comment Utiliser Logfire MCP
- Installation : Commencez par télécharger le serveur Logfire MCP depuis le dépôt officiel de Pydantic. Suivez les instructions d'installation fournies dans la documentation.
- Configuration : Configurez les paramètres du serveur selon vos besoins. Cela inclut la configuration des paramètres de journalisation, des options de stockage des données et des paramètres d'intégration.
- Commencer à Journaliser : Une fois configuré, démarrez le serveur et commencez à journaliser les données de votre application. Utilisez la fonctionnalité de journalisation en temps réel pour surveiller les journaux au fur et à mesure de leur génération.
- Analyser les Journaux : Utilisez les outils intégrés pour analyser et gérer vos journaux. Vous pouvez filtrer, rechercher et catégoriser les journaux pour obtenir des informations sur les performances de votre application.
- Intégrer avec d'Autres Outils : Si nécessaire, intégrez Logfire MCP avec d'autres outils et services pour améliorer ses capacités et rationaliser votre flux de travail.
Questions Fréquemment Posées
Q : Quels langages de programmation Logfire MCP prend-il en charge ?
R : Logfire MCP est conçu pour fonctionner avec plusieurs langages de programmation, le rendant polyvalent pour divers environnements de développement.
Q : Logfire MCP est-il open-source ?
R : Oui, Logfire MCP est un dépôt public, permettant aux développeurs de contribuer et de modifier le code selon leurs besoins.
Q : Comment puis-je signaler des problèmes ou contribuer à Logfire MCP ?
R : Vous pouvez signaler des problèmes ou contribuer au projet en visitant le dépôt GitHub et en suivant les directives de contribution fournies.
Q : Quelles sont les exigences système pour exécuter Logfire MCP ?
R : Les exigences système peuvent varier en fonction de l'échelle de votre application, mais en général, il nécessite un serveur avec une puissance de traitement et une mémoire adéquates pour gérer efficacement les opérations de journalisation.
Q : Où puis-je trouver la documentation pour Logfire MCP ?
R : La documentation pour Logfire MCP est disponible sur le dépôt GitHub, fournissant des instructions détaillées sur l'installation, la configuration et l'utilisation.
Détail
Logfire MCP Server
This repository contains a Model Context Protocol (MCP) server with tools that can access the OpenTelemetry traces and metrics you've sent to Logfire.
<a href="https://glama.ai/mcp/servers/@pydantic/logfire-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@pydantic/logfire-mcp/badge" alt="Logfire Server MCP server" /> </a>This MCP server enables LLMs to retrieve your application's telemetry data, analyze distributed traces, and make use of the results of arbitrary SQL queries executed using the Logfire APIs.
Available Tools
-
find_exceptions_in_file
- Get detailed trace information about exceptions in a specific file- Required arguments:
filepath
(string): Path to the file to analyzeage
(int): Number of minutes to look back (max 7 days)
- Required arguments:
-
arbitrary_query
- Run custom SQL queries on your OpenTelemetry traces and metrics- Required arguments:
query
(string): SQL query to executeage
(int): Number of minutes to look back (max 7 days)
- Required arguments:
-
get_logfire_records_schema
- Get the OpenTelemetry schema to help with custom queries- No required arguments
Setup
Install uv
The first thing to do is make sure uv
is installed, as uv
is used to run the MCP server.
For installation instructions, see the uv
installation docs.
If you already have an older version of uv
installed, you might need to update it with uv self update
.
Obtain a Logfire read token
In order to make requests to the Logfire APIs, the Logfire MCP server requires a "read token".
You can create one under the "Read Tokens" section of your project settings in Logfire: https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens
[!IMPORTANT] 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.
Manually run the server
Once you have uv
installed and have a Logfire read token, you can manually run the MCP server using uvx
(which is provided by uv
).
You can specify your read token using the LOGFIRE_READ_TOKEN
environment variable:
LOGFIRE_READ_TOKEN=YOUR_READ_TOKEN uvx logfire-mcp@latest
or using the --read-token
flag:
uvx logfire-mcp@latest --read-token=YOUR_READ_TOKEN
[!NOTE] If you are using Cursor, Claude Desktop, Cline, or other MCP clients that manage your MCP servers for you, you do NOT need to manually run the server yourself. The next section will show you how to configure these clients to make use of the Logfire MCP server.
Configuration with well-known MCP clients
Configure for Cursor
Create a .cursor/mcp.json
file in your project root:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp@latest", "--read-token=YOUR-TOKEN"]
}
}
}
The Cursor doesn't accept the env
field, so you need to use the --read-token
flag instead.
Configure for Claude Desktop
Add to your Claude settings:
{
"command": ["uvx"],
"args": ["logfire-mcp@latest"],
"type": "stdio",
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
}
}
Configure for Cline
Add to your Cline settings in cline_mcp_settings.json
:
{
"mcpServers": {
"logfire": {
"command": "uvx",
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN"
},
"disabled": false,
"autoApprove": []
}
}
}
Configure for VS Code
Make sure you enabled MCP support in VS Code.
Create a .vscode/mcp.json
file in your project's root directory:
{
"servers": {
"logfire": {
"type": "stdio",
"command": "uvx", // or the absolute /path/to/uvx
"args": ["logfire-mcp@latest"],
"env": {
"LOGFIRE_READ_TOKEN": "YOUR_TOKEN",
"LOGFIRE_BASE_URL": "https://api-eu.pydantic.dev" // choose the correct base url
}
}
}
}
Customization - Base URL
By default, the server connects to the Logfire API at https://api-us.pydantic.dev
. You can override this by:
- Using the
--base-url
argument:
uvx logfire-mcp@latest --base-url=https://your-logfire-instance.com
- Setting the environment variable:
LOGFIRE_BASE_URL=https://your-logfire-instance.com uvx logfire-mcp@latest
Example Interactions
- Get details about exceptions from traces in a specific file:
{
"name": "find_exceptions_in_file",
"arguments": {
"filepath": "app/api.py",
"age": 1440
}
}
Response:
[
{
"created_at": "2024-03-20T10:30:00Z",
"message": "Failed to process request",
"exception_type": "ValueError",
"exception_message": "Invalid input format",
"function_name": "process_request",
"line_number": "42",
"attributes": {
"service.name": "api-service",
"code.filepath": "app/api.py"
},
"trace_id": "1234567890abcdef"
}
]
- Run a custom query on traces:
{
"name": "arbitrary_query",
"arguments": {
"query": "SELECT trace_id, message, created_at, attributes->>'service.name' as service FROM records WHERE severity_text = 'ERROR' ORDER BY created_at DESC LIMIT 10",
"age": 1440
}
}
Examples of Questions for Claude
- "What exceptions occurred in traces from the last hour across all services?"
- "Show me the recent errors in the file 'app/api.py' with their trace context"
- "How many errors were there in the last 24 hours per service?"
- "What are the most common exception types in my traces, grouped by service name?"
- "Get me the OpenTelemetry schema for traces and metrics"
- "Find all errors from yesterday and show their trace contexts"
Getting Started
-
First, obtain a Logfire read token from: https://logfire.pydantic.dev/-/redirect/latest-project/settings/read-tokens
-
Run the MCP server:
uvx logfire-mcp@latest --read-token=YOUR_TOKEN
-
Configure your preferred client (Cursor, Claude Desktop, or Cline) using the configuration examples above
-
Start using the MCP server to analyze your OpenTelemetry traces and metrics!
Contributing
We 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.
For examples of other MCP servers and implementation patterns, see the Model Context Protocol servers repository.
License
Logfire 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.
Configuration du serveur
{
"mcpServers": {
"logfire-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--pydantic--logfire-mcp--logfire-mcp",
"logfire-mcp"
],
"env": {}
}
}
}