log-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@log-mcpsearch for ERROR in production logs from the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
log-mcp-python
Remote log query service based on MCP (Model Context Protocol), implemented in Python.
This project is a redesign and reimplementation of the open-source Log-MCP (Java version): it exposes exactly the same MCP tool interface externally (JSON-RPC 2.0, STDIO / HTTP transport modes), while internally restructuring the overall architecture following Python conventions, and abstracting the "log retrieval method" into a pluggable execution channel — the specific commands for retrieving logs are always built by the service, and only the channels that execute the commands vary.
Features
Interface compatible: 5 MCP tools identical to the original Java version (
search_logs/tail_logs/read_log_file/list_log_files/list_servers), with aligned input/output contracts.Pluggable execution channels:
ssh— SSH private key direct connection (paramiko, with connection pool and auto-reconnect)pyinfra— reuse existing pyinfra host assets (supports host specs such as@local,root@host:22)local— local execution (development / testing)
Unified command building: all log operations are normalized into a shell command executed on the target machine (
grep -n -A -B/tail -n/sed -n/find), decoupled from the execution channel — adding a new channel only requires implementingCommandExecutor.execute().Security: parameter validation, relative path validation, dangerous character detection, and shell single-quote escaping consistent with the original version.
Zero heavy dependencies: core depends only on
paramiko;pyinfrais an optional dependency, installed only when the pyinfra channel is used.
Related MCP server: mcplogview
Architecture
MCP 客户端(AI 助手 / IDE)
│ JSON-RPC 2.0
▼
mcp/ 传输与协议层(stdio_server / http_server / handler)
▼
tools.py 5 个工具的声明式定义(名称 + JSON Schema + 处理函数)
▼
service/ 业务编排层(参数校验 → 文件推导 → 命令构建 → 解析)
▼
executors/ 可插拔执行通道(ssh_key / pyinfra_exec / local + registry)
▼
目标服务器上的 shell 命令(grep / tail / sed / find)Detailed design is in docs/DESIGN.md.
Installation
pip install . # 核心功能(ssh + local 通道)
pip install .[pyinfra] # 需要 pyinfra 通道时
pip install .[dev] # 运行测试Configuration
Refer to config.example.json. It is compatible with the original Java version's config.json structure, with the following extensions:
Each server independently specifies its execution channel via the
connectorfield:ssh(default) /pyinfra/localThe pyinfra channel supports
pyinfraHost(full host spec, e.g.root@192.168.5.20:22or@local) andpyinfraData(host data passed through to pyinfra, e.g.ssh_key)Strings support
${VAR}environment variable placeholders (left as-is if undefined)
{
"servers": [
{
"name": "ssh-server",
"connector": "ssh",
"host": "192.168.5.169",
"port": 22,
"username": "root",
"privateKeyPath": "${SSH_KEY_PATH}",
"logRootPath": "/home/docker/logs/myapp/",
"default": true
},
{
"name": "pyinfra-server",
"connector": "pyinfra",
"pyinfraHost": "root@192.168.5.20:22",
"pyinfraData": { "ssh_key": "/root/.ssh/id_rsa" },
"logRootPath": "/var/logs/app/"
},
{
"name": "dev-local",
"connector": "local",
"logRootPath": "/tmp/logs/"
}
],
"logLevels": ["info", "warn", "error", "debug"],
"logFilePattern": "{level}/log-{level}-{date}.{seq}.log"
}Key field descriptions:
Field | Description |
| Execution channel: |
| Log root directory (baseline for relative path validation) |
| Log file naming pattern, with |
| SSH connection pool (connection limit / timeout / retry) |
| Query defaults and limits (maxResults / maxReadLines / contextLines, etc.) |
Running
# STDIO 模式(MCP 客户端拉起,默认)
log-mcp --config config.json
# HTTP 模式(独立部署,端口默认 8892,路径 / 与 /mcp,健康检查 GET /health)
log-mcp --config config.json --transport http --port 8892Environment variables are also supported: LOG_CONFIG, TRANSPORT_MODE, SERVER_PORT.
Connecting to an MCP client (HTTP mode as an example):
{
"mcpServers": {
"log-mcp": {
"url": "http://your-host:8892/mcp"
}
}
}STDIO mode connection:
{
"mcpServers": {
"log-mcp": {
"command": "log-mcp",
"args": ["--config", "/path/to/config.json"]
}
}
}MCP Tools
Tool | Description |
| Search logs by keyword (optional regex) across dates and levels, with surrounding context |
| Get the latest N lines of logs for a specified level |
| Read a line range from a specified log file |
| List available log files on the server (size / modification time) |
| List all configured servers |
Call example (HTTP):
curl -s -X POST http://127.0.0.1:8892/mcp -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"search_logs","arguments":{"keyword":"ERROR","levels":["error","info"]}}}'Testing
python -m pytest tests/ -qTest coverage: parameter/path validation, shell escaping, command building, grep output parsing (including deterministic parsing of known files), JSON-RPC protocol handling, and end-to-end integration tests for the local / pyinfra(@local) channels (100 test cases in total).
License
Apache-2.0
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server that connects Claude (or any MCP compatible client) to your existing log infrastructure. Query, summarize, and trace logs in plain English across GCP Cloud Logging, AWS CloudWatch, Azure Log Analytics, Grafana Loki, and Elasticsearch without writing filter expressions or leaving your editor.113MIT
- AlicenseNot gradedqualityCmaintenanceExposes configured log files as MCP tools, enabling agents to list, query, and follow logs from local and SSH sources.MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for infrastructure discovery and remote management, enabling SSH command execution, file transfer, log tailing, and machine/service inventory with a companion web dashboard.1
- AlicenseAqualityCmaintenanceProvides a standardized MCP interface for querying Graylog logs, enabling AI agents to search, diagnose, and correlate runtime logs with code via configurable profiles.5MIT
Related MCP Connectors
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
Scans MCP servers for tool poisoning, prompt injection and supply chain risks.
A paid remote MCP for hosted MCP server, built to return verdicts, receipts, usage logs, and audit-r
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Amos666/log-mcp-python'
If you have feedback or need assistance with the MCP directory API, please join our Discord server