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

ops-automation-mcp-ts

v2.12.6

Published

TypeScript MCP server for Docker, K3s, Systemd service management and Jenkins builds

Readme

ops-automation-mcp-ts

TypeScript 版本的 ops-automation MCP 服务器,通过 npx 分发。

安装使用

```bash

直接运行(首次会引导配置)

npx ops-automation-mcp-ts

或全局安装

npm install -g ops-automation-mcp-ts ops-automation-mcp-ts ```

功能

  • Docker 服务管理
  • K3s 服务管理
  • Systemd 服务管理
  • Jenkins 构建
  • 服务器状态查询
  • 前端自动化部署(集成 Jenkins)

前端自动化部署

deploy_frontend_auto

一站式前端部署工具,集成 Jenkins 构建:

使用示例:

1. 部署前端项目
   deploy_frontend_auto(git_url="http://git.example.com/city-web")

2. 指定分支部署
   deploy_frontend_auto(git_url="...", branch="test")

流程:

  1. 触发 Jenkins 构建
  2. 自动处理缺失的 Nginx 配置
  3. 自动安装缺失的环境(Nginx/K3s)
  4. 继续 Jenkins 构建
  5. 等待部署完成

Intent Parsing (自然语言意图解析)

服务器支持使用自然语言进行 Jenkins 构建和服务操作。

Jenkins 构建意图

使用自然语言查找项目:

用户: "水务大脑部署"
→ 调用: jenkins_menu(input="水务大脑部署")
→ 返回: "水务大脑" 视图下的项目列表
→ 用户选择项目
→ 返回: 该项目的分支列表
→ 用户选择分支
→ 执行构建

匹配优先级:

  1. 精确项目名 (confidence: 1.0) → 直接列出分支
  2. 项目描述 (confidence: 0.8) → 列出分支
  3. 视图名称 (confidence: 0.6) → 列出该视图下的项目
  4. 无匹配 → 列出所有视图

支持的模式:

  • "构建管网项目" - 精确项目名匹配
  • "管网项目 develop 分支" - 指定分支
  • "地理信息系统打包" - 项目描述匹配
  • "水务大脑" - 视图匹配(列出该视图下的项目)

分支提取模式:

  • "test/v1.0.0 分支"
  • "feature/new-api 打包"
  • "develop 部署"

服务意图

使用自然语言查找服务:

用户: "重启 nginx"
→ 调用: service_find_restart(service="nginx")
→ 返回: 所有 nginx 服务(按类型/服务器分组)
→ 用户选择服务
→ 调用: service_do_restart(service_id="...")

支持的操作:

  • 重启 / restart
  • 停止 / stop(需要两阶段确认)
  • 启动 / start

结果分组:

  • 按类型: Docker, K3s, Systemd
  • 按服务器: server1, server2, ...
  • 带置信度评分

危险操作的两阶段确认

项目提供两种令牌化确认机制:

  1. 服务操作 (service_prepare_stop / service_do_stop) - 用于服务停止等操作
  2. 命令执行 (execute_prepare / execute_execute) - 用于通用命令执行(详见下方)

服务操作确认

service_do_stop 这样的危险操作需要令牌验证:

1. 调用: service_prepare_stop(service_id="k3s:components:ns:pod:nginx")
   → 返回: { exec_token: "abc123...", warning: "...", risk_level: "high" }

2. 向用户显示警告并等待确认

3. 用户确认后: service_do_stop(service_id="...", exec_token="abc123...")
   → 令牌验证通过,执行操作

令牌特性:

  • 加密随机生成(32 位十六进制)
  • 5 分钟有效期
  • 一次性使用(验证后删除)
  • 命令匹配验证

令牌化命令执行 (Token-Based Command Execution)

新的两阶段确认机制,用于危险命令的执行。

execute_prepare

准备命令执行,并根据命令风险生成令牌。

使用示例:

// 致命命令 - 直接拒绝
execute_prepare({ command: "rm -rf /" })
→ 返回: { blocked: true, reason: "致命命令已被禁止" }

// 危险命令 - 返回令牌
execute_prepare({ command: "rm file.txt" })
→ 返回: { token: "abc123...", warning: "删除文件", expires_at: "2026-03-09T12:35:00Z" }

// 安全命令 - 无需确认
execute_prepare({ command: "ls -la" })
→ 返回: { message: "此命令安全,可以直接执行" }

参数:

  • command (必填): 要执行的命令
  • server (可选): 目标服务器名称

execute_execute

执行命令,支持令牌验证。

使用示例:

// 安全命令 - 无需令牌
execute_execute({ command: "ls -la" })
→ 返回: { success: true, output: "..." }

// 危险命令 - 需要令牌
execute_execute({ command: "rm file.txt", token: "abc123..." })
→ 返回: { success: true, output: "..." }

// 危险命令缺少令牌
execute_execute({ command: "rm file.txt" })
→ 返回: { error: { code: "TOKEN_REQUIRED" } }

参数:

  • command (必填): 要执行的命令
  • token (可选): 执行令牌(危险命令需要)
  • server (可选): 目标服务器名称

工作流示例

// 步骤 1: 检查命令是否需要确认
const prepareResult = await execute_prepare({ command: "rm important.txt" });

// 步骤 2: 如果返回令牌,显示警告给用户
if (prepareResult.requires_confirmation) {
  console.log(`警告: ${prepareResult.warning}`);
  console.log(`令牌: ${prepareResult.token}`);
  // 等待用户确认...
}

// 步骤 3: 用户确认后,使用令牌执行
const executeResult = await execute_execute({
  command: "rm important.txt",
  token: prepareResult.token
});

令牌安全特性

  • 生成方式: 使用 crypto.randomBytes + SHA-256 生成 32 位十六进制字符串
  • 有效期: 从创建起 5 分钟
  • 使用限制: 仅可使用一次(验证后即删除)
  • 绑定关系: 令牌与特定命令和服务器绑定
  • 存储位置: 仅存储在内存中(服务器重启后清除)

配置

配置文件位于 ~/.ops-automation/hosts.yaml

极简配置示例

```yaml defaults: port: 22 user: root password: "your_password"

hosts: my-server: host: 192.168.1.100 tags: [docker] ```

配置说明

  • defaults: 定义默认值,所有服务器继承
  • hosts: 服务器配置列表
    • host: [必填] IP 地址或域名
    • port: SSH 端口(默认从 defaults)
    • user: SSH 用户名(默认从 defaults)
    • password: SSH 密码(默认从 defaults)
    • tags: 标签(自动生成分组)
    • k3sCluster: K3s 集群名称
    • role: 角色(control-plane/worker)

自动生成

  • groups: 自动从 tags 生成,无需手动配置
  • k3s_clusters: 自动从 k3sCluster + role 生成,首选节点为 role=control-plane 的服务器

Skill 文件

MCP 会自动将 Skill 文件安装到 ~/.claude/skills/ops-automation-mcp/,AI 将更好地理解如何使用此工具。

手动更新 Skill(如有新版本): ```bash

Linux/macOS

cp -r node_modules/ops-automation-mcp-ts/.claude/skills/ops-automation-mcp ~/.claude/skills/

Windows

xcopy /E /I /Y node_modules\ops-automation-mcp-ts\.claude\skills\ops-automation-mcp %USERPROFILE%\.claude\skills\ ```

禁用 Skill 自动安装: ```bash export OPSAUTO_SKIP_SKILL_UPDATE=1 ```

技术栈

  • TypeScript 5.0+
  • Node.js 20+
  • MCP SDK
  • node-ssh
  • vitest