What is ghrud92 simple loki mcp
Simple Loki MCP Server
*
Loki MCP Server is a Model Context Protocol (MCP) interface for querying Grafana Loki logs using logcli
. The server enables AI assistants to access and analyze log data from Loki directly.
Features
- Query Loki logs with full LogQL support
- Get label values and metadata
- Authentication and configuration support via environment variables or config files
- Provides formatted results in different output formats (default, raw, JSON lines)
- Automatic fallback to HTTP API when
logcli
is not available in the environment
Prerequisites
- Node.js v16 or higher
- TypeScript
- (Optional) Grafana Loki logcli installed and accessible in your PATH. If
logcli
is not available, the server will automatically use the Loki HTTP API instead - Access to a Loki server instance
Installation
Installing via Smithery
To install Simple Loki MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
for MCP
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": {
"LOKI_ADDR": "https://loki.sup.band"
}
}
}
}
npm
- Clone the repository:
git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
Available MCP Tools
query-loki
Query logs from Loki with filtering options.
Parameters:
query
(required): Loki query string (LogQL)from
: Start timestamp (e.g. "2023-01-01T12:00:00Z")to
: End timestamp (e.g. "2023-01-01T13:00:00Z")limit
: Maximum number of logs to returnbatch
: Batch size for query resultsoutput
: Output format ("default", "raw", or "jsonl")quiet
: Suppress query metadataforward
: Display results in chronological order
get-label-values
Retrieve all values for a specific label.
Parameters:
label
(required): Label name to get values for
get-labels
Retrieve all available labels.
No parameters required.
Configuration
You can configure Loki access using:
Environment Variables
LOKI_ADDR
: Loki server address (URL)LOKI_USERNAME
: Username for basic authLOKI_PASSWORD
: Password for basic authLOKI_TENANT_ID
: Tenant ID for multi-tenant LokiLOKI_BEARER_TOKEN
: Bearer token for authenticationLOKI_BEARER_TOKEN_FILE
: File containing bearer tokenLOKI_CA_FILE
: Custom CA file for TLSLOKI_CERT_FILE
: Client certificate file for TLSLOKI_KEY_FILE
: Client key file for TLSLOKI_ORG_ID
: Organization ID for multi-org setupsLOKI_TLS_SKIP_VERIFY
: Skip TLS verification ("true" or "false")LOKI_CONFIG_PATH
: Custom path to config fileDEBUG
: Enable debug logging
Note: When the client is using the HTTP API mode (when
logcli
is not available), the same configuration parameters are used to authenticate and connect to the Loki server.
Config Files
Alternatively, create a logcli-config.yaml
file in one of these locations:
- Custom path specified by
LOKI_CONFIG_PATH
- Current working directory
- Your home directory (
~/.logcli-config.yaml
)
Example config file:
addr: https://loki.example.com
username: user
password: pass
tenant_id: mytenant
Usage
Start the server:
npm start
For development:
npm run dev
Implementation Details
Automatic Fallback to HTTP API
The server will automatically check if logcli
is installed and available in the environment:
- If
logcli
is available, it will be used for all queries, providing the full functionality of the CLI tool - If
logcli
is not available, the server will automatically fall back to using the Loki HTTP API:- No additional configuration is needed
- The same authentication parameters are used for the HTTP API
- Response formatting is consistent with the CLI output
- Default limit of 1000 logs per query is applied in both modes
This automatic detection ensures that the server works seamlessly in different environments without manual configuration.
Development
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
# Run tests
npm run test
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Leave a Comment
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
chrisdoc hevy mcp
sylphlab pdf reader mcp
An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.
aashari mcp server atlassian bitbucket
Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.
aashari mcp server atlassian confluence
Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.
prisma prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Zzzccs123 mcp sentry
mcp sentry for typescript sdk
zhuzhoulin dify mcp server
zhongmingyuan mcp my mac
zhixiaoqiang desktop image manager mcp
MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)
zhixiaoqiang antd components mcp
An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询
Submit Your MCP Server
Share your MCP server with the community
Submit Now