mcp_jenkins
Jenkins MCP 服务器。模型上下文协议 (MCP) 允许 AI 工具(例如聊天机器人)与您的 Jenkins 设置进行通信并控制您的设置,例如检索信息和修改设置。
**注意:**这是 MCP Jenkins 服务器的最小实验版本,目前处于早期开发阶段。
描述
该项目提供了一个用于与 Jenkins 交互的模型上下文协议 (MCP) 服务器。它允许用户通过 MCP 界面触发 Jenkins 作业、获取构建状态以及执行其他与 Jenkins 相关的操作。
成分
server.py
:核心 MCP Jenkins 服务器应用程序。functions_schema.md
:定义 MCP Jenkins 服务器公开的函数的模式。client.py
:一个示例客户端,演示如何与 MCP Jenkins 服务器交互(仅供参考)。functional tests
:包含 MCP Jenkins 服务器的功能测试。
安装
要安装该软件包,请运行:
用法
常见工作流程
运行服务器
要运行 MCP 服务器:
运行示例客户端
运行示例客户端:
例如,要列出使用特定模型的名为“备份”的作业的构建,您可以运行:
注意:如果通过pip install .
那么mcp_jenkins_client
控制台脚本也可用。
这可能会产生类似以下内容的输出:
使用 Docker 进行构建和测试
开发和测试的常见工作流程是首先构建 Docker 镜像,然后执行测试:
- **构建Docker镜像:**此步骤准备测试所需的环境。
- **运行测试:**构建完成后,执行测试。
此序列确保在一致的 Dockerized 环境中针对最新版本执行测试。
部署测试环境
部署本地 Jenkins 测试实例(无需身份验证,仅用于功能测试):
连接到现有的 Jenkins 实例
要将 MCP Jenkins 服务器与现有的 Jenkins 实例一起使用,您需要配置以下环境变量:
JENKINS_URL
:你的 Jenkins 实例的完整 URL(例如http://your-jenkins-host:8080
)。此参数为必填项。JENKINS_USER
:(可选)如果需要身份验证,请输入您的 Jenkins 用户名。JENKINS_API_TOKEN
:(可选)您的 Jenkins API 令牌。如果使用身份验证,则必须将此令牌与JENKINS_USER
一起提供。您可以在 Jenkins 用户的配置页面 (<Jenkins URL>/me/configure
) 中生成 API 令牌。MCP_API_KEY
:用于保护此 MCP 服务器的 API 密钥。发送至 MCP 服务器的请求需要在X-API-Key
标头中包含此密钥。除非DEBUG_MODE
设置为true
,否则此项为必需。DEBUG_MODE
:设置为true
即可在调试模式下运行 MCP 服务器,从而绕过MCP_API_KEY
要求并提供更详细的日志记录。请勿在生产环境中使用。
示例配置(Bash):
设置这些环境变量后,您可以使用 Docker 脚本运行 MCP 服务器:
然后,MCP 服务器将尝试连接到您指定的 Jenkins 实例。
OpenWebUI 集成
文件open-webui/open_webui_interface.py
提供了如何将此 MCP Jenkins 服务器与 OpenWebUI 实例集成的示例。
使用方法:
- 在您的 OpenWebUI 界面中,导航到添加或配置工具的部分。
- 创建新工具。
- 将
open-webui/open_webui_interface.py
文件的全部内容复制并粘贴到 OpenWebUI 中的工具配置中。 - 重要提示:您需要调整粘贴的代码中的连接参数,具体来说:
MCP_JENKINS_SERVER_URL
:在您的 OpenWebUI 环境中将此环境变量设置为正在运行的 MCP Jenkins 服务器的 URL(例如http://localhost:5000
)。如果未设置此变量,则脚本默认使用http://localhost:5000
。MCP_API_KEY
:如果您的 MCP Jenkins 服务器配置为需要 API 密钥,请确保在 OpenWebUI 环境中设置此环境变量。如果未找到密钥,脚本会打印警告,但仍会尝试发出请求。
配置完成后, open_webui_interface.py
中定义的工具(例如list_jobs
、 trigger_build
、 get_build_status
)就可以在您的 OpenWebUI 聊天界面中使用了。
执照
该项目已获得 MIT 许可。
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
模型上下文协议 (MCP) 服务器使聊天机器人等 AI 工具能够与 Jenkins 交互并控制它,允许用户通过自然语言触发作业、检查构建状态以及执行其他 Jenkins 操作。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants to interact with Jenkins CI/CD servers, providing tools to check build statuses, trigger builds, and retrieve build logs.Last updated -38JavaScriptMIT License
- AsecurityAlicenseAqualityA server that uses the Model Context Protocol (MCP) to allow AI agents to safely execute shell commands on a host system.Last updated -1762TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables real-time, interactive AI chat with Selector AI through a streaming-capable server and Docker-based client communicating via stdin/stdout.Last updated -1PythonApache 2.0
- -securityAlicense-qualityThe Model Context Protocol (MCP) Jenkins integration is an open-source implementation that bridges Jenkins with AI language models following Anthropic's MCP specification. This project enables secure, contextual AI interactions with Jenkins tools while maintaining data privacy and security.Last updated -25PythonMIT License