Loki MCP Server
간단한 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"
}
}
}
}엔피엠
저장소를 복제합니다.
git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp종속성 설치:
npm install프로젝트를 빌드하세요:
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의 테넌트 IDLOKI_BEARER_TOKEN: 인증을 위한 베어러 토큰LOKI_BEARER_TOKEN_FILE: 베어러 토큰을 포함하는 파일LOKI_CA_FILE: TLS용 사용자 정의 CA 파일LOKI_CERT_FILE: TLS용 클라이언트 인증서 파일LOKI_KEY_FILE: TLS용 클라이언트 키 파일LOKI_ORG_ID: 다중 조직 설정을 위한 조직 IDLOKI_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 설치되어 있고 해당 환경에서 사용 가능한지 자동으로 확인합니다.
logcli사용할 수 있는 경우 모든 쿼리에 사용되어 CLI 도구의 전체 기능을 제공합니다.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 toolsget_labelsD
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Label name to get values for |
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| batch | No | Batch size for query results | |
| forward | No | Display results in chronological order | |
| from | No | Start timestamp in UTC (e.g. '2023-01-01T12:00:00Z'). Relative time expressions like '1h ago' are not supported. Use ISO 8601 format. | |
| limit | No | Maximum number of logs to return. Maximum value is 1000 | |
| output | No | Output 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. | |
| query | Yes | Loki query string | |
| quiet | No | Suppress query metadata | |
| to | No | End timestamp in UTC (e.g. '2023-01-01T13:00:00Z'). Relative time expressions like 'now' are not supported. Use ISO 8601 format. |
TDQS
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.
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.
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.
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.
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.
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.
3 tool updates
v1.0.0- First observed
get_label_values - First observed
get_labels - First observed
query_loki
TDQS
Scored across 3 tools
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.
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.
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.
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
Related MCP Connectors
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
- SpanlyOAuthcom.spanly
MCP observability. Query live traffic, errors, duration, and alerts from your AI agent.
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.
Related MCP Servers
- AlicenseAqualityDmaintenanceA server that enables AI assistants to access and query Grafana dashboards, metrics, logs, and configurations through an MCP protocol interface.106MIT
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- AlicenseNot gradedqualityBmaintenanceThis 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 npmMIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to query and analyze logs from Grafana Loki using LogQL, supporting label discovery and keyword search.4-