Skip to main content
Glama
Loki MCP Server

Loki MCP Server

by ghrud92

간단한 Loki MCP 서버

대장간 배지

Loki MCP 서버는 logcli 사용하여 Grafana Loki 로그를 쿼리하기 위한 모델 컨텍스트 프로토콜(MCP) 인터페이스입니다. 이 서버를 통해 AI 어시스턴트는 Loki의 로그 데이터에 직접 접근하여 분석할 수 있습니다.

특징

  • LogQL을 완벽하게 지원하는 Loki 로그 쿼리

  • 레이블 값과 메타데이터 가져오기

  • 환경 변수 또는 구성 파일을 통한 인증 및 구성 지원

  • 다양한 출력 형식(기본값, 원시, JSON 줄)으로 형식화된 결과를 제공합니다.

  • 환경에서 logcli 사용할 수 없는 경우 HTTP API로 자동 폴백

Related MCP server: Loki MCP Server

필수 조건

  • Node.js v16 이상

  • 타입스크립트

  • (선택 사항) Grafana Loki logcli가 설치되어 PATH에 접근 가능합니다. logcli 사용할 수 없는 경우 서버는 자동으로 Loki HTTP API를 사용합니다.

  • Loki 서버 인스턴스에 액세스

설치

Smithery를 통해 설치

Smithery를 통해 Claude Desktop에 Simple Loki MCP Server를 자동으로 설치하려면:

지엑스피1

MCP용

{
  "mcpServers": {
    "simple-loki": {
      "command": "npx",
      "args": ["-y", "simple-loki-mcp"],
      "env": {
        "LOKI_ADDR": "https://loki.sup.band"
      }
    }
  }
}

엔피엠

  1. 저장소를 복제합니다.

git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp
  1. 종속성 설치:

npm install
  1. 프로젝트를 빌드하세요:

npm run build

사용 가능한 MCP 도구

쿼리-로키

필터링 옵션을 사용하여 Loki의 로그를 쿼리합니다.

매개변수:

  • query (필수): Loki 쿼리 문자열(LogQL)

  • from 시간: 시작 타임스탬프(예: "2023-01-01T12:00:00Z")

  • to : 종료 타임스탬프(예: "2023-01-01T13:00:00Z")

  • limit : 반환할 로그의 최대 개수

  • batch : 쿼리 결과에 대한 배치 크기

  • output : 출력 형식("기본", "원시" 또는 "jsonl")

  • quiet : 쿼리 메타데이터를 억제합니다

  • forward : 결과를 시간순으로 표시합니다.

레이블 값 가져오기

특정 레이블에 대한 모든 값을 검색합니다.

매개변수:

  • label (필수): 값을 가져올 레이블 이름

레이블 가져오기

사용 가능한 라벨을 모두 검색합니다.

매개변수가 필요하지 않습니다.

구성

다음을 사용하여 Loki 액세스를 구성할 수 있습니다.

환경 변수

  • LOKI_ADDR : 로키 서버 주소(URL)

  • LOKI_USERNAME : 기본 인증을 위한 사용자 이름

  • LOKI_PASSWORD : 기본 인증을 위한 비밀번호

  • LOKI_TENANT_ID : 멀티 테넌트 Loki의 테넌트 ID

  • LOKI_BEARER_TOKEN : 인증을 위한 베어러 토큰

  • LOKI_BEARER_TOKEN_FILE : 베어러 토큰을 포함하는 파일

  • LOKI_CA_FILE : TLS용 사용자 정의 CA 파일

  • LOKI_CERT_FILE : TLS용 클라이언트 인증서 파일

  • LOKI_KEY_FILE : TLS용 클라이언트 키 파일

  • LOKI_ORG_ID : 다중 조직 설정을 위한 조직 ID

  • LOKI_TLS_SKIP_VERIFY : TLS 검증 건너뛰기("true" 또는 "false")

  • LOKI_CONFIG_PATH : 구성 파일에 대한 사용자 정의 경로

  • DEBUG : 디버그 로깅 활성화

참고 : 클라이언트가 HTTP API 모드를 사용하는 경우( logcli 사용할 수 없는 경우), 동일한 구성 매개변수를 사용하여 Loki 서버를 인증하고 연결합니다.

구성 파일

또는 다음 위치 중 하나에 logcli-config.yaml 파일을 만듭니다.

  • LOKI_CONFIG_PATH 에 의해 지정된 사용자 정의 경로

  • 현재 작업 디렉토리

  • 홈 디렉토리( ~/.logcli-config.yaml )

구성 파일 예:

addr: https://loki.example.com
username: user
password: pass
tenant_id: mytenant

용법

서버를 시작합니다:

npm start

개발을 위해:

npm run dev

구현 세부 사항

HTTP API로 자동 폴백

서버는 logcli 설치되어 있고 해당 환경에서 사용 가능한지 자동으로 확인합니다.

  1. logcli 사용할 수 있는 경우 모든 쿼리에 사용되어 CLI 도구의 전체 기능을 제공합니다.

  2. logcli 사용할 수 없는 경우 서버는 자동으로 Loki HTTP API를 사용합니다.

    • 추가 구성이 필요하지 않습니다

    • HTTP API에는 동일한 인증 매개변수가 사용됩니다.

    • 응답 형식은 CLI 출력과 일치합니다.

    • 두 모드 모두 쿼리당 1000개 로그의 기본 제한이 적용됩니다.

이러한 자동 감지 기능을 통해 수동 구성 없이도 다양한 환경에서 서버가 원활하게 작동하도록 할 수 있습니다.

개발

# Run linter
npm run lint

# Fix linting issues
npm run lint:fix

# Run tests
npm run test

특허

이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 LICENSE.md 파일을 참조하세요.

Available Tools

3 tools
get_labelsD

Inputs: no named parameters.

get_label_valuesD

Inputs: label (required).

query_lokiD

Inputs: query (required), batch, forward, from, +4 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    D1.8/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get_labels retrieves label names, get_label_values fetches values for a specific label, and query_loki performs log queries. There is no overlap or ambiguity between these functions.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case (get_labels, get_label_values, query_loki). The naming is predictable and uniform throughout the set.

    Tool Count3/5

    With only 3 tools, the set feels thin for a Loki server, which typically handles log management and querying. While the tools cover basic operations, more functionality (e.g., log ingestion, stream management) might be expected.

    Completeness2/5

    The tool surface is severely incomplete for a Loki server. It lacks essential operations like pushing logs, managing log streams, configuring settings, or performing advanced queries, leaving significant gaps that could cause agent failures.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A server that enables AI assistants to access and query Grafana dashboards, metrics, logs, and configurations through an MCP protocol interface.
      10
      6
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI models to query and analyze Kubernetes cluster logs through Grafana Loki, supporting semantic operations like error aggregation and pod restart detection. It provides tools for regex-based log searching and namespace discovery to facilitate natural language troubleshooting.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      This MCP server enables natural-language querying of Grafana logs by automatically detecting log sources and service labels. It provides read-only access to log data with intelligent caching for efficient repeat queries.
      69 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI assistants to query and analyze logs from Grafana Loki using LogQL, supporting label discovery and keyword search.
      4
      -