Sponsored by Deepsite.site

Tempo MCP Server

Created By
scottlepp8 months ago
An MCP ( Model Context Protocol ) Server for Grafana Tempo
Content

Tempo MCP Server

A Go-based server implementation for the Model Context Protocol (MCP) with Grafana Tempo integration.

Overview

This MCP server allows AI assistants to query and analyze distributed tracing data from Grafana Tempo. It follows the Model Context Protocol to provide tool definitions that can be used by compatible AI clients such as Claude Desktop.

Getting Started

Prerequisites

  • Go 1.21 or higher
  • Docker and Docker Compose (for local testing)

Building and Running

Build and run the server:

# Build the server
go build -o tempo-mcp-server ./cmd/server

# Run the server
./tempo-mcp-server

Or run directly with Go:

go run ./cmd/server

The server now supports two modes of communication:

  1. Standard input/output (stdin/stdout) following the Model Context Protocol (MCP)
  2. HTTP Server with Server-Sent Events (SSE) endpoint for integration with tools like n8n

The default port for the HTTP server is 8080, but can be configured using the SSE_PORT environment variable.

Server Endpoints

When running in HTTP mode, the server exposes the following endpoints:

  • SSE Endpoint: http://localhost:8080/sse - For real-time event streaming
  • MCP Endpoint: http://localhost:8080/mcp - For MCP protocol messaging

Docker Support

You can build and run the MCP server using Docker:

# Build the Docker image
docker build -t tempo-mcp-server .

# Run the server
docker run -p 8080:8080 --rm -i tempo-mcp-server

Alternatively, you can use Docker Compose for a complete test environment:

# Build and run with Docker Compose
docker-compose up --build

Project Structure

.
├── cmd/
│   ├── server/       # MCP server implementation
│   └── client/       # Client for testing the MCP server
├── internal/
│   └── handlers/     # Tool handlers
├── pkg/
│   └── utils/        # Utility functions and shared code
└── go.mod            # Go module definition

MCP Server

The Tempo MCP Server implements the Model Context Protocol (MCP) and provides the following tools:

Tempo Query Tool

The tempo_query tool allows you to query Grafana Tempo trace data:

  • Required parameters:
    • query: Tempo query string (e.g., {service.name="frontend"}, {duration>1s})
  • Optional parameters:
    • url: The Tempo server URL (default: from TEMPO_URL environment variable or http://localhost:3200)
    • start: Start time for the query (default: 1h ago)
    • end: End time for the query (default: now)
    • limit: Maximum number of traces to return (default: 20)
    • username: Username for basic authentication (optional)
    • password: Password for basic authentication (optional)
    • token: Bearer token for authentication (optional)

Environment Variables

The Tempo query tool supports the following environment variables:

  • TEMPO_URL: Default Tempo server URL to use if not specified in the request
  • SSE_PORT: Port for the HTTP/SSE server (default: 8080)

Testing

./run-client.sh tempo_query "{resource.service.name=\\\"example-service\\\"}"

Using with Claude Desktop

You can use this MCP server with Claude Desktop to add Tempo query tools. Follow these steps:

  1. Build the server or Docker image
  2. Configure Claude Desktop to use the server by adding it to your Claude Desktop configuration file

Example Claude Desktop configuration:

{
  "mcpServers": {
    "temposerver": {
      "command": "path/to/tempo-mcp-server",
      "args": [],
      "env": {
        "TEMPO_URL": "http://localhost:3200"
      },
      "disabled": false,
      "autoApprove": ["tempo_query"]
    }
  }
}

For Docker:

{
  "mcpServers": {
    "temposerver": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "TEMPO_URL=http://host.docker.internal:3200", "tempo-mcp-server"],
      "disabled": false,
      "autoApprove": ["tempo_query"]
    }
  }
}

The Claude Desktop configuration file is located at:

  • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%\Claude\claude_desktop_config.json
  • On Linux: ~/.config/Claude/claude_desktop_config.json

Using with Cursor

You can also integrate the Tempo MCP server with the Cursor editor. To do this, add the following configuration to your Cursor settings:

{
  "mcpServers": {
    "tempo-mcp-server": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "TEMPO_URL=http://host.docker.internal:3200", "tempo-mcp-server:latest"]
    }
  }
}

Using with n8n

To use the Tempo MCP server with n8n, you can connect to it using the MCP Client Tool node:

  1. Add an MCP Client Tool node to your n8n workflow

  2. Configure the node with these parameters:

    • SSE Endpoint: http://your-server-address:8080/sse (replace with your actual server address)
    • Authentication: Choose appropriate authentication if needed
    • Tools to Include: Choose which Tempo tools to expose to the AI Agent
  3. Connect the MCP Client Tool node to an AI Agent node that will use the Tempo querying capabilities

Example workflow: Trigger → MCP Client Tool (Tempo server) → AI Agent (Claude)

Example Usage

Once configured, you can use the tools in Claude with queries like:

  • "Query Tempo for traces with the query {duration>1s}"
  • "Find traces from the frontend service in Tempo using query {service.name=\"frontend\"}"
  • "Show me the most recent 50 traces from Tempo with {http.status_code=500}"
Screenshot 2025-04-11 at 5 24 03 PM

License

This project is licensed under the MIT License.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
WindsurfThe new purpose-built IDE to harness magic
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
Playwright McpPlaywright MCP server
CursorThe AI Code Editor
Tavily Mcp
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop