Loki MCP Server

Integrate Grafana Loki log querying into your AI workflows with the Loki MCP Server for real-time insights, monitoring, and operational automation.

Loki MCP Server

What does “Loki” MCP Server do?

The Loki MCP Server is a Go-based implementation of the Model Context Protocol (MCP) designed to integrate with Grafana Loki, a log aggregation system. It serves as a bridge between AI assistants and external log data sources, enabling the AI to query and interact with log streams stored in Loki. By exposing Loki’s querying capabilities via the MCP protocol, developers and AI clients can enhance their workflows—such as searching, filtering, and analyzing logs—directly through standardized LLM-driven interfaces. This empowers tasks like real-time log investigation, troubleshooting, and dashboard creation, providing seamless access to operational data for improved observability and automation.

List of Prompts

No prompt templates are documented in the repository.

List of Resources

No explicit MCP resources are described in the repository.

List of Tools

  • loki_query
    Allows querying Grafana Loki log data.
    • Required parameters:
      • query: LogQL query string
    • Optional parameters:
      • url: Loki server URL (default from LOKI_URL env or http://localhost:3100)
      • start: Start time for the query (default: 1 hour ago)
      • end: End time for the query (default: now)
      • limit: Max number of entries to return (default: 100)

Use Cases of this MCP Server

  • Log Data Exploration
    Developers or AI agents can programmatically query and analyze log data stored in Grafana Loki, assisting with troubleshooting and incident response.
  • Automated Log Monitoring
    Enables LLM-driven monitoring workflows, where AI assistants can scan logs for anomalies, error patterns, or specific events.
  • Operational Dashboards
    Facilitates dynamic dashboard creation by fetching log data required for visualization or reporting tools.
  • Root Cause Analysis
    Empowers AI to sift through large volumes of logs, pinpointing the origin of issues using flexible LogQL queries.

How to set it up

Windsurf

  1. Install Go 1.16 or higher.

  2. Build the server:
    go build -o loki-mcp-server ./cmd/server

  3. Edit your Windsurf configuration to add the MCP server.

  4. Add the Loki MCP server with a JSON snippet (adapt as needed):

    {
      "mcpServers": {
        "loki-mcp": {
          "command": "./loki-mcp-server",
          "args": []
        }
      }
    }
    
  5. Save the configuration and restart Windsurf.

  6. Verify the server is running and accessible.

Securing API Keys (Environment Variables Example):

{
  "mcpServers": {
    "loki-mcp": {
      "command": "./loki-mcp-server",
      "env": {
        "LOKI_URL": "https://your-loki-server.example"
      }
    }
  }
}

Claude

  1. Install Go 1.16 or higher.

  2. Build the server as above.

  3. Open Claude’s MCP configuration file.

  4. Add the Loki MCP server:

    {
      "mcpServers": {
        "loki-mcp": {
          "command": "./loki-mcp-server",
          "args": []
        }
      }
    }
    
  5. Save/restart Claude.

  6. Confirm setup is working.

Securing API Keys:

{
  "mcpServers": {
    "loki-mcp": {
      "command": "./loki-mcp-server",
      "env": {
        "LOKI_URL": "https://your-loki-server.example"
      }
    }
  }
}

Cursor

  1. Ensure Go 1.16+ is installed.

  2. Build Loki MCP server.

  3. Edit Cursor’s configuration.

  4. Add Loki MCP server entry:

    {
      "mcpServers": {
        "loki-mcp": {
          "command": "./loki-mcp-server",
          "args": []
        }
      }
    }
    
  5. Save and restart Cursor.

  6. Verify integration.

Using Environment Variables:

{
  "mcpServers": {
    "loki-mcp": {
      "command": "./loki-mcp-server",
      "env": {
        "LOKI_URL": "https://your-loki-server.example"
      }
    }
  }
}

Cline

  1. Install Go >=1.16.

  2. Build with:
    go build -o loki-mcp-server ./cmd/server

  3. Locate Cline’s MCP server config.

  4. Add Loki MCP server:

    {
      "mcpServers": {
        "loki-mcp": {
          "command": "./loki-mcp-server",
          "args": []
        }
      }
    }
    
  5. Save and restart Cline.

  6. Test the setup.

Secure API Keys via env:

{
  "mcpServers": {
    "loki-mcp": {
      "command": "./loki-mcp-server",
      "env": {
        "LOKI_URL": "https://your-loki-server.example"
      }
    }
  }
}

How to use this MCP inside flows

Using MCP in FlowHunt

To integrate MCP servers into your FlowHunt workflow, start by adding the MCP component to your flow and connecting it to your AI agent:

FlowHunt MCP flow

Click on the MCP component to open the configuration panel. In the system MCP configuration section, insert your MCP server details using this JSON format:

{
  "loki-mcp": {
    "transport": "streamable_http",
    "url": "https://yourmcpserver.example/pathtothemcp/url"
  }
}

Once configured, the AI agent is now able to use this MCP as a tool with access to all its functions and capabilities. Remember to change "loki-mcp" to whatever the actual name of your MCP server is and replace the URL with your own MCP server URL.


Overview

SectionAvailabilityDetails/Notes
OverviewSummary available in README.md
List of PromptsNo prompt templates documented
List of ResourcesNo explicit MCP resources listed
List of Toolsloki_query tool described in README.md
Securing API KeysUses LOKI_URL env variable
Sampling Support (less important in evaluation)No mention of sampling support

Based on the above tables, Loki MCP Server offers a clear overview and a functional tool for querying logs, but lacks documented prompts, resources, and advanced MCP features like sampling or roots. The documentation is minimal, and setup is developer-oriented.

Our opinion

The Loki MCP Server is focused and functional for integrating LLMs with Grafana Loki log querying, but it is minimalistic and lacks breadth in MCP features and documentation. For a score, it would receive a 4/10: it works for its main purpose, but is not a feature-complete, polished, or highly documented MCP server.

MCP Score

Has a LICENSE
Has at least one tool
Number of Forks1
Number of Stars5

Frequently asked questions

What is the Loki MCP Server?

The Loki MCP Server is a Go-based service that connects AI assistants to Grafana Loki, allowing log data queries and analysis through the Model Context Protocol (MCP). It enables advanced log monitoring, troubleshooting, and dashboard automation within AI workflows.

Which tool does the Loki MCP Server provide?

It provides the `loki_query` tool, letting users query logs in Grafana Loki using LogQL, with support for parameters like query string, time range, and result limit.

What are the key use cases for Loki MCP?

Key use cases include log data exploration, automated log monitoring, AI-powered operational dashboards, and root cause analysis—all directly from your AI workflows.

How do I secure my Loki MCP Server configuration?

Set sensitive information such as the Loki server URL via environment variables, for example: `LOKI_URL=https://your-loki-server.example` in your MCP server configuration.

Does Loki MCP Server support prompt templates or advanced MCP features?

No, it does not currently support prompt templates, sampling, or advanced MCP features—its functionality is focused on querying and analyzing logs through a single tool.

What is the recommended way to use Loki MCP Server in FlowHunt?

Add the MCP component to your FlowHunt flow, provide your Loki MCP connection details in JSON, and connect it to your AI agent. This enables direct log querying and analysis from your AI workflows.

Start Using Loki MCP Server

Bridge the gap between AI and log data. Deploy Loki MCP Server to power advanced log analysis and monitoring in your FlowHunt workflows.

Learn more