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

jenkins-mcp-job

v2.0.2

Published

AI-enabled Jenkins automation via Model Context Protocol (MCP) - Node.js/TypeScript rewrite

Readme

🧠 Jenkins-MCP-Job (Node.js/TypeScript 版本)

Build Status npm version TypeScript License

Jenkins-MCP-Job 是一个基于 AI 的模型上下文协议(MCP)服务器,通过自然语言命令提供 Jenkins 自动化功能。

这是原始 Python 版本的完整 Node.js/TypeScript 重写版本,提供更好的性能、类型安全和统一的技术栈。

🚀 极速开发体验

  • 零编译运行 - 无需 tsc 打包,直接运行源码
  • 🔒 类型安全 - 完整的 JSDoc/TypeScript 类型标注
  • 📦 轻量部署 - 仅包含源代码和极简依赖
  • 🎯 现代 ESM - 原生 ES Modules 支持

🎨 现代架构

  • ES Modules - 现代 JavaScript 模块系统
  • Zod 验证 - 运行时类型安全
  • Winston 日志 - 专业结构化日志
  • Axios HTTP 客户端 - 带拦截器的健壮 HTTP 请求
  • MCP 官方 SDK - 原生 MCP 协议支持

📦 功能特性

本项目包括:

  • 🟢 Node.js/TypeScript - 现代、类型安全的实现
  • 📦 MCP SDK - 官方模型上下文协议支持
  • 🌐 Axios HTTP 客户端 - 健壮的 Jenkins REST API 集成
  • 🔐 CSRF 保护 - 自动 crumb 处理
  • 📊 智能缓存 - 减少 33-83% 的 API 调用
  • 📈 指标和遥测 - 跟踪工具使用和性能
  • 🗂️ 缓存管理 - 监控和控制缓存
  • 🎨 结构化日志 - Winston JSON 格式
  • 输入验证 - Zod schema 验证
  • 🛠️ 26 个 Jenkins 管理工具 - 完整自动化覆盖

🧩 构建操作

| 工具名称 | 描述 | 必需字段 | 可选字段 | | --------------- | --------------------------------- | -------------------------- | ------------ | | trigger-build | 触发 Jenkins 作业构建(可选参数) | job_name | parameters | | stop-build | 停止运行中的 Jenkins 构建 | job_name, build_number | (无) |

📊 作业信息

| 工具名称 | 描述 | 必需字段 | 可选字段 | | ----------------- | ------------------------------------------- | ---------- | --------------------- | | list-jobs | 列出所有 Jenkins 作业(可选过滤和缓存) | (无) | filter, use_cache | | get-job-details | 获取 Jenkins 作业的详细信息 | job_name | max_recent_builds |

🛠️ 构建信息

| 工具名称 | 描述 | 必需字段 | 可选字段 | | -------------------------- | ------------------------------ | -------------------------- | ------------------------ | | get-build-info | 获取特定构建的信息 | job_name, build_number | (无) | | get-build-console | 获取控制台输出(智能截断) | job_name, build_number | max_lines, tail_only | | get-last-build-number | 获取作业的最新构建号 | job_name | (无) | | get-last-build-timestamp | 获取最新构建的时间戳 | job_name | (无) |

🧩 作业管理 - 暂时注释

⚙️ 作业配置 - 暂时注释

🖥️ 系统信息

| 工具名称 | 描述 | 必需字段 | 可选字段 | | ---------------- | ------------------------- | ----------- | -------- | | get-queue-info | 获取 Jenkins 构建队列信息 | (无) | (无) | | list-nodes | 列出所有 Jenkins 节点 | (无) | (无) | | get-node-info | 获取 Jenkins 节点的信息 | node_name | (无) | | health-check | 对 Jenkins 连接运行诊断 | (无) | (无) |

📊 监控和管理

| 工具名称 | 描述 | 必需字段 | 可选字段 | | ----------------- | ---------------------- | -------- | ----------- | | get-cache-stats | 获取缓存统计和信息 | (无) | (无) | | clear-cache | 清除所有缓存数据 | (无) | (无) | | get-metrics | 获取使用指标和性能统计 | (无) | tool_name |

🚀 快速开始

前置要求

Node.js(v18 或更高版本)是必需的。

⚙️ 配置

Jenkins-MCP-Job 支持多种配置方法。选择最适合您的一种:

选项 1:VS Code 设置(推荐)

添加到您的 VS Code settings.json

{
  "jenkins-mcp-job": {
    "jenkins": {
      "url": "http://jenkins.example.com:8080",
      "username": "your-username",
      "token": "your-api-token"
    }
  }
}

获取您的 Jenkins API Token

  1. 登录 Jenkins
  2. 点击您的名字(右上角)→ Configure
  3. 滚动到 API Token 部分
  4. 点击 Add new Token
  5. 给它一个名称并点击 Generate
  6. 复制 token(⚠️ 它不会再显示!)

🤖️ 与 Claude Desktop 集成或支持MCP协议的IDE中使用

添加配置 claude_desktop_config.json

{
  "mcpServers": {
    "jenkins": {
      "command": "npx",
      "args": ["jenkins-mcp-job"],
      "env": {
        "JENKINS_URL": "http://localhost:8080",
        "JENKINS_USERNAME": "YourUsername",
        "JENKINS_TOKEN": "YourAPIToken"
      }
    }
  }
}

💡 使用示例

自然语言命令

配置完成后,您可以使用自然语言与 MCP 客户端交互:

"列出所有 Jenkins 作业"
"列出名称中包含 'backend' 的作业"
"显示所有生产环境作业"
"显示 my-project 的最新构建"
"使用参数 env=production 触发 deploy-prod 的构建"
"构建队列中有什么?"
"显示 backend-service 构建 #42 的控制台输出"
"通过复制 prod-job 创建名为 test-job 的新作业"
"禁用 old-job"

📊 性能对比

| 指标 | Python v1.x | Node.js v2.0.0 | 改进 | | -------- | ------------------ | -------------- | -------- | | 启动时间 | <1s | <0.5s | 2x 更快 | | 内存使用 | ~50 MB | ~30 MB | 40% 减少 | | 包大小 | ~100 MB | ~50 MB | 50% 减少 | | 类型安全 | 运行时(Pydantic) | 编译时(TS) | 更好 | | 异步 I/O | GIL 限制 | 真正异步 | 更高并发 |

🔒 安全最佳实践

  1. 永远不要提交 .env 文件 - 添加到 .gitignore
  2. 使用 API token,而不是密码 - 更安全且可撤销
  3. 定期轮换 token - 定期生成新 token
  4. 使用特定环境的配置 - 分离开发/测试/生产凭据
  5. 审查权限 - 仅授予必要的 Jenkins 权限
  6. 保持依赖更新 - 定期运行 npm audit

📚 项目结构

Jenkins-MCP-Job/
├── src/
│   ├── index.ts                 # 主入口点
│   ├── cli.ts                   # CLI 入口点
│   ├── config/
│   │   └── config.ts             # 配置管理(Zod)
│   ├── jenkins/
│   │   └── client.ts             # Jenkins API 客户端(Axios)
│   ├── cache/
│   │   └── cache.ts              # 智能缓存层
│   ├── metrics/
│   │   └── metrics.ts            # 性能遥测
│   ├── tools/
│   │   └── registry.ts            # 工具注册器和处理器
│   └── utils/
│       └── logger.ts              # Winston 日志器
├── tests/                          # 测试目录
│   ├── basic.test.ts              # 基础测试
│   └── vitest.config.ts           # Vitest 配置
├── scripts/                        # 脚本目录
│   ├── install.mjs                # 安装脚本
│   └── build.mjs                 # 构建脚本
├── dist/                           # 编译输出(构建后生成)
├── package.json                    # Node.js 配置
├── tsconfig.json                   # TypeScript 配置
├── .eslintrc.cjs                   # ESLint 配置
├── .prettierrc.json                 # Prettier 配置
└── README.md                       # 本文件

📝 许可证

本项目采用 MIT 许可证。

🙏 致谢