Skip to main content
Glama
ghrud92

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
ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_label_valuesD
ParametersJSON Schema
NameRequiredDescriptionDefault
labelYesLabel name to get values for

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

query_lokiD
ParametersJSON Schema
NameRequiredDescriptionDefault
batchNoBatch size for query results
forwardNoDisplay results in chronological order
fromNoStart timestamp in UTC (e.g. '2023-01-01T12:00:00Z'). Relative time expressions like '1h ago' are not supported. Use ISO 8601 format.
limitNoMaximum number of logs to return. Maximum value is 1000
outputNoOutput format - valid values are 'default' (formatted log lines), 'raw' (unprocessed log lines), or 'jsonl' (JSON Lines format). Note: values like 'text' or 'json' are not supported.
queryYesLoki query string
quietNoSuppress query metadata
toNoEnd timestamp in UTC (e.g. '2023-01-01T13:00:00Z'). Relative time expressions like 'now' are not supported. Use ISO 8601 format.

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 3 tool updatesv1.0.0
    • First observedget_label_values
    • First observedget_labels
    • First observedquery_loki

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 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.
    12 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
    -