MCP Infra Lens
SSH Linux metrics, baselines, anomaly detection, and plain-English infrastructure explanations.
README
mcp-infra-lens
Explain Linux incidents over SSH with baseline-aware MCP tooling.
Demo

Sample analyze_server response when Claude asks, "What's wrong with prod-01?":
{
"host": "prod-01.internal",
"health_score": 42,
"summary": "Found 2 anomalies on prod-01.internal. Most urgent signal: CPU is at 91% (3.4σ above baseline 28.2%). Load is 7.2/6.8/5.1. Top CPU consumer: java (87%).",
"anomalies": [
{
"metric": "cpu",
"severity": "high",
"value": 91,
"z_score": 3.4,
"explanation": "CPU is at 91% (3.4σ above baseline 28.2%). Load is 7.2/6.8/5.1. Top CPU consumer: java (87%).",
"recommendation": "Investigate java (PID 18432) and review application logs or scale-out options."
},
{
"metric": "disk:/",
"severity": "high",
"value": 91,
"explanation": "Disk / is 91% full (182GB/200GB).",
"recommendation": "Run du -sh //* | sort -rh | head -20 and clean logs or temporary files."
}
]
}
What It Does
mcp-infra-lens connects to Linux hosts over SSH, captures a live infrastructure snapshot, compares it to recently recorded baselines, and explains anomalies in plain English.
- Collects CPU, memory, disk, network, process, and OS data without mutating the target host
- Records local metric history in SQLite for baselines, comparisons, and trend lookups
- Uses z-score analysis for CPU anomaly detection once enough baseline samples exist
- Explains the likely cause of pressure, not just the raw metric value
- Supports MCP over
stdioand Streamable HTTP
How It Works
flowchart TD
A["Claude / Cursor / VS Code / Windsurf"] --> B["mcp-infra-lens"]
B --> C["server-core.ts"]
C --> D["collector.ts"]
C --> E["analyzer.ts"]
C --> F["baseline.ts + db.ts"]
D --> G["ssh.ts"]
G --> H["Linux host over SSH"]
F --> I["SQLite history + baselines"]
analyze_server now performs real sampled collection over the requested duration_minutes, averages CPU and memory pressure across the collection window, persists the resulting snapshot, and then runs anomaly detection against the selected baseline.
Tools
| Tool | What it does | Key params |
|---|---|---|
analyze_server |
Collects a sampled snapshot, stores it, and explains anomalies | connection, duration_minutes, include_processes, include_network |
snapshot |
Captures and stores the current point-in-time metrics without analysis | connection |
record_baseline |
Saves a labeled healthy-state sample for future comparisons | connection, label |
compare_to_baseline |
Compares the current state to a named baseline and explains the deltas | connection, baseline_label |
get_history |
Returns historical CPU, memory, or load points from SQLite | host, metric, hours, label? |
Quick Start
1. Run via npx
npx -y mcp-infra-lens
If you are pinned to 1.0.1, upgrade to 1.0.2 or newer to avoid Node 24 native install failures:
npx -y mcp-infra-lens@latest
2. Claude Desktop
Published package:
{
"mcpServers": {
"infra-lens": {
"command": "npx",
"args": ["-y", "mcp-infra-lens"],
"env": {
"INFRA_LENS_DB": "/Users/you/.mcp-infra-lens/metrics.db"
}
}
}
}
Local development:
{
"mcpServers": {
"infra-lens": {
"command": "node",
"args": ["/absolute/path/to/mcp-infra-lens/dist/mcp.js"],
"env": {
"INFRA_LENS_DB": "/Users/you/.mcp-infra-lens/metrics.db"
}
}
}
}
3. Docker
docker build -t mcp-infra-lens .
docker run --rm -it \
-v "$HOME/.mcp-infra-lens:/home/appuser/.mcp-infra-lens" \
mcp-infra-lens
Configuration
| Environment variable | Default | Description |
|---|---|---|
INFRA_LENS_DB |
~/.mcp-infra-lens/metrics.db |
SQLite database path. Use :memory: for tests |
HOST |
127.0.0.1 |
Bind address for the HTTP transport |
PORT |
3000 |
Port for the HTTP transport |
Health Score
90-100: healthy, no meaningful anomalies detected70-89: mild or isolated pressure40-69: multiple warnings or a major issue in progress0-39: critical condition with urgent remediation needed
Recommended Workflow
- Record
record_baselinesamples during healthy operating windows. - Use
analyze_serverduring incidents or load spikes. - Use
compare_to_baselinefor a tighter differential view against a named baseline. - Use
get_historyto inspect trends and separate default snapshots from labeled baseline sessions.
Authentication
The SSH input schema supports:
- Password authentication
- Inline private key authentication
- Optional passphrase support for encrypted keys
Credential fields are redacted from structured logs before they are written to stderr.
Security Notes
- SSH collection is read-only on the target host
- SSH credentials are never stored in SQLite
- Host key verification is permissive in v1 for compatibility; production deployments should restrict outbound network access and plan to enforce strict host verification in a later release
- The HTTP transport has no built-in authentication; bind to loopback and place it behind an authenticated reverse proxy in any non-local deployment
See SECURITY.md for the reporting policy and stored-data scope.
Integrations
Claude Desktop
{
"mcpServers": {
"infra-lens": {
"command": "npx",
"args": ["-y", "mcp-infra-lens"],
"env": {
"INFRA_LENS_DB": "/Users/you/.mcp-infra-lens/metrics.db"
}
}
}
}
Cursor IDE
{
"mcpServers": {
"infra-lens": {
"command": "npx",
"args": ["-y", "mcp-infra-lens"]
}
}
}
VS Code (MCP extension)
{
"inputs": [],
"servers": {
"infra-lens": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-infra-lens"]
}
}
}
Windsurf
{
"mcpServers": {
"infra-lens": {
"command": "npx",
"args": ["-y", "mcp-infra-lens"]
}
}
}
Docker (HTTP transport)
docker run -d \
-p 3000:3000 \
-v $HOME/.mcp-infra-lens:/home/appuser/.mcp-infra-lens \
ghcr.io/oaslananka/mcp-infra-lens:latest
Then configure your MCP client to use http://localhost:3000.
Docker
The bundled Docker image:
- Builds the TypeScript project in a separate stage
- Rebuilds
better-sqlite3for the container architecture in both stages - Runs as a non-root
appuser - Stores SQLite data in
/home/appuser/.mcp-infra-lens/metrics.db
Contributing
Contributions are welcome. Start with CONTRIBUTING.md, then use:
- docs/usage.md for tool examples
- docs/architecture.md for the component map
- docs/testing.md for local validation and publish checks
- RELEASE_POLICY.md for npm and MCP Registry versioning rules
AGENTS.md,CLAUDE.md,GEMINI.md,.github/copilot-instructions.md, and.agent/rules/repository.mdfor repository-specific AI coding guidance
Operational / CI Notes
azure-pipelines.ymlis the canonical CI pipeline and now runs aQualitystage on Node 20 and Node 22, publishes JUnit and Cobertura artifacts, and executes Docker-backed SSH e2e coverage on Node 20.azure/pipelines/publish.ymlremains the manual npm release pipeline.azure/pipelines/mirror.ymlremains available for repository mirroring workflows- Publish only after the local pre-publish checklist and CI both pass cleanly on Node 20
- Follow RELEASE_POLICY.md when deciding whether a change needs npm, MCP Registry, or registry-only prerelease publication
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。