Infra Lens Mcp

io.github.oaslananka由 GitHub 帳號 oaslananka 發布v1.5.1更新於 Nov 3, 2026

SSH Linux metrics, baselines, anomaly detection, and plain-English infrastructure explanations.

發布方自己的服務:Infrapage

概覽

AI 產生的概覽

透過 SSH 連線 Linux 主機,擷取有限範圍的指標,將基準存入本機 SQLite,解釋異常並產出需人工審核的故障報告草稿。

可以做什麼
  • 分析 SSH 上的 Linux 主機:取樣區間、即時快照與單一時點觀測
  • 管理基準與歷史:記錄標記為健康狀態的樣本、與具名基準比較、從 SQLite 讀取 CPU、記憶體與負載歷史
  • 檢查主機就緒狀態:收集前確認所需 Linux 指令與 proc 檔案是否可用
  • 依已儲存的觀測產生修復方案與故障報告或事後檢討草稿,但不執行任何變更
  • 比較單一主機的相鄰時間區間,或跨兩台主機比較同一區間
適用情境
適合需要讓助理透過 SSH 診斷 Linux 伺服器效能或故障、保留本機觀測歷史,並產出有證據支撐的說明、修復方案或事後檢討草稿供人工審核的情境。
執行需求
以 stdio 本機程序執行,可透過 npx 或 Node.js(22 以上,CI 與 Docker 使用 24 LTS)啟動。需要可連線的 Linux SSH 目標,具備 /proc、free、df、ps 與 uname,並透過 known_hosts 或固定的 SHA256 主機金鑰驗證主機。選用設定包括 INFRA_LENS_DB(SQLite 路徑)與 MCP_SSH_ALLOWED_HOSTS(主機允許清單)。
安裝前請注意
涉及 SSH 憑證:預設 full 設定檔接受原始密碼、私鑰與通行碼,建議改用金鑰驗證並切換至 remote-safe、chatgpt 或 claude 設定檔,這些設定檔會拒絕原始憑證並要求設定 MCP_SSH_ALLOWED_HOSTS。相關工具會將觀測與基準寫入本機 SQLite 資料庫。修復方案僅為建議,不會被執行。非回送位址的 HTTP 綁定必須設定驗證模式及來源與主機允許清單;套件內未實作原生 OAuth 驗證。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Infra Lens Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

infra-lens-mcp

Explain Linux incidents over SSH with baseline-aware MCP tooling.

A TypeScript MCP server for live Linux diagnostics, local SQLite history,
review-first incident workflows, and secure observability exports.

[CI status] [CodeQL status] [Security Gates status] [OSV-Scanner status] [Codecov coverage] [OpenSSF Scorecard]

[npm version] [npm downloads] [Node.js 22 or newer] [MCP 2025-11-25] [Signed multi-architecture GHCR image] [MIT license]

Documentation · Usage · Architecture · Security · Governance · Roadmap · Support · Releases

[Buy me a coffee]

infra-lens-mcp connects to Linux hosts over SSH, captures bounded live metrics, stores observations and approved baselines in local SQLite, explains anomalies, and produces review-first incident artifacts. The npm package and signed container are release-ready; public connector publication remains intentionally blocked until an external OAuth/HTTPS deployment is verified.

Demo

[infra-lens-mcp demo]

See the MCP 2025-11-25 compliance matrix for current protocol support, delegated behavior, and connector publication constraints.

Tools

ToolPurpose
analyze_serverAnalyze a bounded sampled window with progress/cancellation support, then store only the completed observation
analyze_server_snapshotAnalyze and store one immediate snapshot without a sampling delay
snapshotStore a point-in-time observation without anomaly analysis
record_baselineSave a labeled healthy-state sample
compare_to_baselineCompare current state with a named baseline
get_historyReturn CPU, memory, or load history from SQLite
inspect_host_capabilitiesCheck required Linux commands and proc files before collection
plan_remediationPropose evidence-backed, approval-required remediation without executing changes
draft_incident_reportDraft an incident report and postmortem from persisted observations
compare_incident_windowsCompare adjacent windows for one host or the same window across two hosts

All tools return both readable JSON text and MCP structuredContent validated by declared outputSchema definitions, so clients and agents can consume responses without parsing the text block. Collection tools include a warnings array when optional sections cannot be collected but a partial snapshot is still usable. Use analyze_server_snapshot for interactive checks; use analyze_server only when a sampled window is required. Sampled analysis emits MCP progress when the client supplies a progress token and never persists a cancelled partial run.

Requirements

  • Node.js 24 LTS for CI, Docker, and release workflows
  • Node.js 22 or newer for package runtime compatibility
  • pnpm 11.15.1 through Corepack for development installs
  • Linux SSH targets with /proc, free, df, ps, and uname
  • Strict SSH host verification through known_hosts or pinned SHA256 host keys

Quick Start

Run the stdio MCP server from npm:

bash
npx -y infra-lens-mcp

Desktop MCP client style configuration:

json
{  "mcpServers": {    "infra-lens": {      "command": "npx",      "args": ["-y", "infra-lens-mcp"],      "env": {        "INFRA_LENS_DB": "/Users/you/.infra-lens-mcp/metrics.db"      }    }  }}

Local development:

bash
corepack enablecorepack prepare [email protected] --activatepnpm install --frozen-lockfilepnpm run buildnode dist/mcp.js

Configuration

Transport is selected by the executable entry point, not by an environment variable: npx -y infra-lens-mcp or node dist/mcp.js starts stdio, while node dist/server-http.js starts Streamable HTTP.

VariableDefaultDescription
INFRA_LENS_DB~/.infra-lens-mcp/metrics.dbSQLite database path
INFRA_LENS_RETENTION_DAYS30Snapshot retention in days; 0 disables automatic pruning
MCP_HTTP_HOST127.0.0.1HTTP bind host. HOST remains a deprecated alias
MCP_HTTP_PORT3000HTTP bind port. PORT remains a deprecated alias
MCP_HTTP_ENDPOINT_PATH/mcpCanonical Streamable HTTP MCP endpoint path
MCP_HTTP_ALLOWED_ORIGINSunsetComma-separated allowed Origin values
MCP_HTTP_ALLOWED_HOSTSunsetComma-separated allowed Host values
MCP_HTTP_AUTH_MODEnonenone, bearer, or oauth-gateway; oauth is accepted as a compatibility alias
MCP_HTTP_BEARER_TOKENunsetLocal/dev bearer fallback token
MCP_HTTP_OAUTH_GATEWAY_HEADERx-infra-lens-gateway-authHeader injected by a trusted OAuth gateway
MCP_HTTP_OAUTH_GATEWAY_SECRETunsetShared backend secret required for oauth-gateway mode
MCP_HTTP_BODY_LIMIT_BYTES1048576Maximum JSON request body size
MCP_HTTP_REQUEST_TIMEOUT_MS30000Maximum time to receive and handle an HTTP request before the socket is closed
MCP_HTTP_MAX_CONCURRENT_REQUESTS100Maximum concurrent HTTP requests accepted by the Node process
MCP_HTTP_RATE_LIMIT_PER_MINUTE0Optional per-client in-memory rate limit; 0 disables it
MCP_HTTP_AUTHORIZATION_SERVERSunsetOAuth authorization server metadata URLs
MCP_PROFILEfullfull, remote-safe, chatgpt, or claude
MCP_SSH_STRICT_HOST_CHECKINGtrueStrict host key verification toggle
MCP_SSH_KNOWN_HOSTS~/.ssh/known_hostsKnown hosts file
MCP_SSH_ALLOWED_HOSTSunsetExact host/IP or IPv4 CIDR allowlist; required for remote-safe profiles and enforced in full profile when set
MCP_SSH_ALLOWED_USERSunsetOptional comma-separated SSH username allowlist
MCP_SSH_ALLOWED_PORTSunsetOptional comma-separated SSH port allowlist
MCP_SSH_MAX_SESSIONS_PER_HOST0Optional active SSH session cap per host:port; 0 disables it
MCP_SSH_MAX_CONNECTION_ATTEMPTS_PER_MINUTE0Optional SSH connection-attempt cap per host:port per minute; 0 disables it

MCP_DB_PATH from older examples is not used; use INFRA_LENS_DB.

SSH Security

Strict host key checking is enabled by default. Provide either:

  • a hostKeySha256 value in the connection input, such as SHA256:...
  • a knownHostsPath in the connection input
  • MCP_SSH_KNOWN_HOSTS pointing at an OpenSSH known_hosts file

Raw passwords, private keys, and passphrases are accepted only in the default full profile for trusted local MCP contexts. remote-safe, chatgpt, and claude profiles reject raw SSH credentials in tool input and require MCP_SSH_ALLOWED_HOSTS. Production SSH policy can also restrict exact hosts or IPv4 CIDR ranges, users, ports, per-host active sessions, and per-host connection attempts.

Process command arguments are not collected by the default process command. Secret-like values in process data, SSH errors, and logs are redacted before storage or output.

HTTP Transport

Run the Streamable HTTP transport locally. The canonical MCP endpoint is http://127.0.0.1:3000/mcp unless MCP_HTTP_ENDPOINT_PATH is changed. HTTP mode is stateless today: the server does not issue or accept MCP-Session-Id, and only POST JSON-RPC calls are supported on the MCP endpoint. MCP_HTTP_REQUEST_TIMEOUT_MS and any proxy timeout must exceed the requested sampled window; otherwise use analyze_server_snapshot. stdio has no server-owned wall-clock request timeout, so the client controls its timeout and MCP cancellation.

bash
MCP_HTTP_HOST=127.0.0.1 MCP_HTTP_PORT=3000 node dist/server-http.js

Loopback HTTP can run without auth for local development. Any non-loopback bind, such as 0.0.0.0, fails fast unless all of these are configured:

  • MCP_PROFILE=remote-safe, chatgpt, or claude
  • MCP_HTTP_AUTH_MODE=bearer or oauth-gateway
  • MCP_HTTP_ALLOWED_ORIGINS
  • MCP_HTTP_ALLOWED_HOSTS

Native OAuth/JWT validation is not implemented inside this package. Public deployments should use MCP_HTTP_AUTH_MODE=oauth-gateway behind a production OAuth-aware gateway or reverse proxy, configure HTTPS MCP_HTTP_RESOURCE_URL, and block direct access to the Node process. Keep origin/host allowlists, body limits, request timeout, concurrency limit, and optional rate limit enabled at the Node process even when an upstream proxy also enforces them. See ADR 0006. Connector publication readiness remains false until a full connector deployment is verified.

Docker

The Docker image defaults to stdio mode:

bash
docker build -t infra-lens-mcp .docker volume create infra-lens-datadocker run --rm -i \  --read-only \  --cap-drop=ALL \  --security-opt=no-new-privileges:true \  --tmpfs /tmp:rw,noexec,nosuid,nodev,size=64m \  --mount type=volume,src=infra-lens-data,dst=/home/appuser/.infra-lens-mcp \  infra-lens-mcp

For local HTTP testing, override the command and keep the bind host on loopback unless a remote-safe profile and auth controls are configured:

bash
docker run --rm -p 127.0.0.1:3000:3000 \  --read-only \  --cap-drop=ALL \  --security-opt=no-new-privileges:true \  --tmpfs /tmp:rw,noexec,nosuid,nodev,size=64m \  --mount type=volume,src=infra-lens-data,dst=/home/appuser/.infra-lens-mcp \  -e MCP_HTTP_HOST=0.0.0.0 \  -e MCP_HTTP_ALLOWED_ORIGINS=http://localhost:3000 \  -e MCP_HTTP_ALLOWED_HOSTS=localhost:3000 \  -e MCP_HTTP_AUTH_MODE=bearer \  -e MCP_HTTP_BEARER_TOKEN=local-dev-token \  infra-lens-mcp node dist/server-http.js

Observability exports

Observability is a separate, disabled-by-default process that reads the latest persisted observations without initiating SSH collection:

bash
INFRA_LENS_OBSERVABILITY_ENABLED=true infra-lens-observe

The default OpenMetrics endpoint is http://127.0.0.1:9464/metrics. Optional OTLP/HTTP JSON export uses standard OTEL_EXPORTER_OTLP_* variables. See Observability exports for Prometheus, OpenTelemetry, privacy, and remote-access guidance.

Development

bash
pnpm run format:checkpnpm run lintpnpm testpnpm run test:coveragepnpm run buildpnpm run check:metadatapnpm run package:dry-run

Docker-backed SSH e2e validation uses a self-contained fixture lifecycle:

bash
pnpm run test:e2e

If a fixture is already running and you intentionally want to skip lifecycle management, use:

bash
INFRA_LENS_E2E_SKIP_FIXTURE=1 pnpm run test:e2e:raw

Start with the documentation index for usage, client setup, operations, incident workflows, observability, storage, security, governance, testing, and release guidance. Generated API docs live in docs/api, and reviewed incident examples live in examples/incidents.

Community

Use SUPPORT.md for support channels and response expectations. Active work is tracked in the infra-lens-mcp Governance project. Project conduct is defined in CODE_OF_CONDUCT.md, and maintainer triage policy lives in docs/governance.md.

Release

Releases are managed through release-please manifest mode and the guarded GitHub Actions release workflow. Implementation PRs must not publish packages, containers, MCP Registry entries, marketplace artifacts, or production GitHub Releases.

See docs/release.md and docs/release-state-machine.md.

License

MIT

Agent plugin and runtime configuration

This repository owns the product-level agent plugin, MCP runtime configuration, and product-specific skills for infra-lens-mcp. The central agent-tools repository should catalog this plugin, but the manifest and workflow instructions live here so they stay synchronized with the actual MCP server package.

FilePurpose
.claude-plugin/plugin.jsonClaude Code-valid product plugin manifest.
.mcp.jsonClaude Code project-local MCP server configuration.
.codex/config.example.tomlCodex CLI MCP configuration example.
.vscode/mcp.example.jsonVS Code / GitHub Copilot workspace MCP configuration example.
opencode.example.jsoncOpenCode project MCP configuration example.
.opencode/skills/OpenCode-native mirrored skill definitions.
docs/agent-runtime-config.mdAgent runtime setup and validation notes.

Validate plugin packaging locally:

bash
claude plugin validate .

For review-first remediation plans, incident drafts, and host/time-window comparisons, see Incident workflows.

來源:README.md,提交 35c072a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.5.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Infra 整合