# MCP Jenkins 集成
## 基本信息
- Slug: `lanbaoshen-mcp-jenkins`
- Source: modelscope
- Publisher: @lanbaoshen/mcp-jenkins
- Categories: developer-tools / monitoring
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@lanbaoshen/mcp-jenkins
## 简介
模型上下文协议（MCP）Jenkins集成是一种开源实现，它根据Anthropic的MCP规范将Jenkins与人工智能语言模型桥接起来。该项目在保持数据隐私和安全的同时，实现了与Jenkins工具的安全、基于上下文的人工智能交互。
## 安装提示

```bash
# Using uv (recommended) pip install uv uvx mcp-jenkins # Using pip pip install mcp-jenkins # Using Smithery npx -y @smithery/cli@latest install @lanbaoshen/mcp-jenkins --client claude
```

## MCP Server 详情

# MCP Jenkins
![PyPI Version](https://img.shields.io/pypi/v/mcp-jenkins)
![PyPI - Downloads](https://img.shields.io/pypi/dm/mcp-jenkins)
[![PyPI Downloads](https://static.pepy.tech/badge/mcp-jenkins)](https://pepy.tech/projects/mcp-jenkins)
![License](https://img.shields.io/github/license/lanbaoshen/mcp-jenkins)
[![smithery badge](https://smithery.ai/badge/@lanbaoshen/mcp-jenkins)](https://smithery.ai/server/@lanbaoshen/mcp-jenkins)

Model Context Protocol (MCP) 是一个开源实现，它根据 Anthropic 的 MCP 规范将 Jenkins 与 AI 语言模型连接起来。该项目能够在保持数据隐私和安全的同时，实现与 Jenkins 工具的安全、上下文相关的 AI 交互。

## 光标演示
![光标演示](https://github.com/user-attachments/assets/ba954a67-e9ca-4d38-b962-19fb8856bdde)

## 设置指南

### 安装
选择以下安装方法之一：
```
# Using uv (recommended)
pip install uv
uvx mcp-jenkins

# Using pip
pip install mcp-jenkins

# Using Smithery
npx -y @smithery/cli@latest install @lanbaoshen/mcp-jenkins --client claude
```

### 配置与使用

#### Cursor
1. 打开 Cursor 设置
2. 导航到 MCP
3. 点击 + 添加新的全局 MCP 服务器

这将创建或编辑 ~/.cursor/mcp.json 文件以包含您的 MCP 服务器配置。
```shell
{
  "mcpServers": {
    "mcp-jenkins": {
      "command": "uvx",
      "args": [
        "mcp-jenkins",
        "--jenkins-url=xxx",
        "--jenkins-username=xxx",
        "--jenkins-password=xxx"
      ]
    }
  }
}
```

#### 命令行参数
```shell
# Stdio Mode
uvx mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx

# SSE Mode
uvx mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx --transport sse --port 9887
```

#### AutoGen
<details>
<summary>安装并执行</summary>

安装 autogen:
```shell
pip install "autogen-ext[azure,ollama,openai,mcp]" autogen-chat
```


运行 Python 脚本:
```python
import asyncio

from autogen_ext.tools.mcp import StdioMcpToolAdapter, StdioServerParams
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken


async def main() -> None:
    # Create server params for the remote MCP service
    server_params = StdioServerParams(
        command='uvx',
        args=[
            'mcp-jenkins',
            '--jenkins-username',
            'xxx',
            '--jenkins-password',
            'xxx',
            '--jenkins-url',
            'xxx'
        ],
    )

    # Get the translation tool from the server
    adapter = await StdioMcpToolAdapter.from_server_params(server_params, 'get_all_jobs')

    # Create an agent that can use the translation tool
    agent = AssistantAgent(
        name='jenkins_assistant',
        model_client=[Replace_with_your_model_client],
        tools=[adapter],
    )

    # Let the agent translate some text
    await Console(
        agent.run_stream(task='Get all jobs', cancellation_token=CancellationToken())
    )


if __name__ == "__main__":
    asyncio.run(main())
```

</details>

## 可用工具
| 工具               | 描述                  |
|--------------------|------------------------------|
| get_all_jobs       | 获取所有作业                 |
| get_job_config     | 获取作业配置               |
| search_jobs        | 按特定字段搜索作业 |
| get_running_builds | 获取正在运行的构建           |
| get_build_info     | 获取构建信息               |
| get_job_info       | 获取作业信息                 |
| build_job          | 使用参数构建作业       |

## 开发与调试
```shell
# Using MCP Inspector
# For installed package
npx @modelcontextprotocol/inspector uvx mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx

# For local development version
npx @modelcontextprotocol/inspector uv --directory /path/to/your/mcp-jenkins run mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx
```

### 单元测试
```
# Install Dependency
uv sync --all-extras --dev

# Execute UT
uv run pytest --cov=mcp_jenkins 
```

## 许可证
在 MIT 许可下发布 - 查看 [LICENSE](LICENSE) 文件。这不是官方的 Jenkins 产品。

