npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

infra-mcp-runtime

v1.0.6

Published

Obfuscated runtime package for Infra MCP.

Downloads

861

Readme

Infra MCP

Infra MCP 是一个独立运行的 HTTP MCP Server,用于让 AI 按项目隔离访问服务端配置的 MySQL、Redis 和部署环境 Linux 命令行。

真实连接信息只保存在用户空间目录 ~/.infra-mcp/infra-mcp.server.config.json 中。安装或首次启动时会自动生成 ~/.infra-mcp/infra-mcp.client.config.json 模板,业务项目根目录只需要复制并维护自己的 infra-mcp.client.config.json。客户端配置可以是多环境数组,也可以是单环境对象;每个环境里用 projectName 命名环境,并保存对应 projectKey 和给 Agent 工具看的 promptprompt 用于提供额外自然语言说明,不要保存数据库、Redis 或 SSH 密码。

功能说明

  • mysql_list_databases:列出当前 MySQL 账号可见数据库,最多返回 400 条。
  • mysql_list_tables:列出指定数据库的表,最多返回 400 条。
  • mysql_select:只允许执行单条 SELECT 查询,返回记录最多 400 条。
  • redis_query:只允许执行 Redis 只读命令白名单。
  • linux_exec:通过 SSH 执行结构化部署环境 Linux 命令;单命令传 programargscwdexplanation,多命令传 commands 数组,不要用 bash -lcsh -c 包装多条命令。只读诊断命令命中白名单会直接执行,有副作用或未知命令会在网页控制台触发人工确认。
  • 网页控制台:访问 http://127.0.0.1:3120/console 查看 MySQL、Redis、Linux 三类输入输出,维护 Linux 风险类型审批策略,并通过动态表单编辑保存 ~/.infra-mcp/infra-mcp.server.config.json

使用方式

  1. 安装 Node.js 20 或更高版本。

  2. 全局安装运行版包:

    npm install -g infra-mcp-runtime
  3. 直接启动服务端:

    infra

    infra 等同于 infra start,默认会在后台守护进程中运行,启动成功后终端可以关闭。安装完成后会自动执行初始化;首次启动时如果 ~/.infra-mcp 不存在模板文件,也会自动创建默认模板。

    服务管理命令:

    infra start
    infra stop
    infra restart
    infra status
    infra log
    infra help

    其中 infra stop 用于停止后台服务,infra status 用于查看运行状态和进程 PID,infra restart 用于重启服务,infra log 用于查看最近日志,infra help 用于查看命令帮助。

    如果需要前台运行,可以使用:

    infra --foreground

    前台运行时需要保持当前终端窗口打开;停止服务时按 Ctrl+C,或关闭当前终端窗口。

  4. 配置文件会保存在用户空间目录 ~/.infra-mcp 下。

    Windows 默认路径示例:

    %USERPROFILE%\.infra-mcp\infra-mcp.server.config.json

    macOS / Linux 默认路径示例:

    ~/.infra-mcp/infra-mcp.server.config.json

    客户端模板路径与它位于同一目录:

    ~/.infra-mcp/infra-mcp.client.config.json
  5. 打开网页控制台配置服务端:

    http://127.0.0.1:3120/console

    网页控制台的“配置”页会通过动态表单保存 ~/.infra-mcp/infra-mcp.server.config.json。这里配置 http 监听参数、projects、MySQL、Redis 和 Linux SSH 连接即可,不需要手动编辑服务端配置文件。

  6. 首次安装或启动后,会在 ~/.infra-mcp/infra-mcp.client.config.json 生成客户端模板。把它复制到需要使用 MCP 的业务项目根目录,再按项目和环境实际情况修改。多环境写成数组:

    [
      {
        "projectName": "开发环境",
        "projectKey": "order-service-dev",
        "prompt": "这是给 Agent 工具使用的额外自然语言说明:当前环境用于开发调试,常用数据库为 order_dev,Redis key 通常以 order:dev: 开头;查询前先确认表含义,不要填写账号密码、token 等敏感信息。"
      },
      {
        "projectName": "生产环境",
        "projectKey": "order-service-prod",
        "prompt": "这是给 Agent 工具使用的额外自然语言说明:当前环境为生产环境,只做必要的只读排查;执行查询前说明目的并控制范围,不要填写账号密码、token 等敏感信息。"
      }
    ]

    只有一个环境时,也可以直接写成对象:

    {
      "projectName": "生产环境",
      "projectKey": "order-service-prod",
      "prompt": "这是给 Agent 工具使用的额外自然语言说明:当前环境为生产环境,只做必要的只读排查;执行查询前说明目的并控制范围,不要填写账号密码、token 等敏感信息。"
    }
  7. 在 MCP 客户端中使用下面的 HTTP 地址连接本服务:

    http://127.0.0.1:3120/mcp
  8. 使用工具前,Agent 应先读取当前业务项目根目录的 infra-mcp.client.config.json;如果配置是数组,则根据目标环境的 projectName 选择配置,如果配置是对象则直接使用;随后遵循所选配置的 prompt,再把 projectKey 传给 MCP 工具。prompt 是为了给 Agent 工具提供额外的自然语言说明,例如库表含义、Redis key 前缀、查询边界和环境注意事项。网页控制台的“配置”页只编辑服务端配置,不会替代业务项目根目录里的客户端配置。

Codex 配置方式

在 Codex 的用户配置文件中添加 Infra MCP 服务配置。Windows 默认路径为:

%USERPROFILE%\.codex\config.toml

示例:

[mcp_servers.infra-mcp]
type = "streamable_http"
url = "http://127.0.0.1:3120/mcp"
startup_timeout_ms = 20000
tool_timeout_sec = 60
enabled = true

如果 ~/.infra-mcp/infra-mcp.server.config.json 中修改过 http.porthttp.path,需要同步修改上面 url 的端口或路径。保存后重启 Codex,或在 Codex 中重新加载 MCP Server。使用前只需要保持 infra 启动的服务进程正在运行。

Codex 配置文件只写 MCP 服务地址,不写数据库、Redis 或 SSH 账号密码。每个业务项目仍需要在项目根目录放置 infra-mcp.client.config.json,其中每个配置项的 projectKey 必须和服务端 projects 中的 projectKey 一致。

安全说明

  • MySQL 只开放数据库列表、表列表和单条 SELECT 查询,不允许写入或 DDL。
  • Redis 只开放白名单内的只读命令。
  • Linux 自动执行只允许结构化命令格式化后的简单命令或只读白名单命令组成的管道。
  • Linux 命令包含 sudo、多语句、重定向、后台执行、命令替换、未知命令或疑似副作用操作时,会在网页控制台等待人工确认。
  • Linux 审批弹窗会按列表显示待执行命令和 Agent 提供的 explanation,触发审批的命令会用红色强调。
  • Linux 审批按风险类型控制,策略保存在用户空间目录的 ~/.infra-mcp/infra-mcp.approval-policy.json。在网页取消某个风险类型的“需要审批”后,同类型命令后续会按策略免审批执行。
  • 不要把 HTTP 服务监听到不可信网络。