MCP server for managing Jenkins operations
Project description
Jenkins MCP
MCP server for managing Jenkins operations.
Installation
Installing via Smithery
To install Jenkins MCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @kjozsa/jenkins-mcp --client claude
Installing Manually
uvx camsnetec-jenkins-mcp
Publishing to PyPI (for maintainers)
# Install build tools
pip install build twine
# Build the package
cd /path/to/jenkins-mcp
python -m build
# Upload to PyPI (requires PyPI account or API token)
twine upload dist/*
# Or using API token
twine upload -u __token__ -p pypi-YOUR_API_TOKEN dist/*
After publishing, users can use the following MCP configuration directly:
Configuration
Add the MCP server using the following JSON configuration snippet:
{
"mcpServers": {
"jenkins-mcp": {
"command": "uvx",
"args": ["camsnetec-jenkins-mcp"],
"env": {
"JENKINS_URL": "https://your-jenkins-server/",
"JENKINS_USERNAME": "your-username",
"JENKINS_PASSWORD": "your-password",
"JENKINS_USE_API_TOKEN": "false"
}
}
}
}
Transport Modes
The server supports three transport modes, controlled by the MCP_TRANSPORT environment variable:
| Mode | Value | Description |
|---|---|---|
| Standard I/O | stdio (default) |
For local CLI usage (Claude Desktop, Cursor, etc.) |
| SSE | sse |
Server-Sent Events over HTTP, for cloud deployments |
| Streamable HTTP | streamable-http |
Recommended for Alibaba Cloud Bailian and similar platforms |
Additional environment variables for HTTP modes (sse / streamable-http):
| Variable | Default | Description |
|---|---|---|
MCP_HOST |
0.0.0.0 |
Bind address |
MCP_PORT |
8000 |
Listen port |
Deploying to Alibaba Cloud Bailian (阿里云百炼)
1. Build Docker Image
docker build -t jenkins-mcp .
2. Push to Alibaba Cloud Container Registry (ACR)
# Login to ACR
docker login --username=<your-acr-username> registry.<region>.aliyuncs.com
# Tag the image
docker tag jenkins-mcp registry.<region>.aliyuncs.com/<namespace>/jenkins-mcp:latest
# Push
docker push registry.<region>.aliyuncs.com/<namespace>/jenkins-mcp:latest
3. Deploy to Function Compute (FC)
Create a function in Alibaba Cloud Function Compute with the following settings:
- Runtime: Custom Container
- Image:
registry.<region>.aliyuncs.com/<namespace>/jenkins-mcp:latest - Port:
8000 - Environment Variables:
JENKINS_URL=https://your-jenkins-server/ JENKINS_USERNAME=your-username JENKINS_PASSWORD=your-password JENKINS_USE_API_TOKEN=false MCP_TRANSPORT=streamable-http MCP_PORT=8000
Important: For Bailian platform, recommended
MCP_TRANSPORT=streamable-httpwith endpoint path/mcp. Alternatively useMCP_TRANSPORT=ssewith endpoint path/sse.
4. Configure in Bailian MCP Management
In the Bailian console MCP management page:
- Transport Type: Select
SSEorStreamable HTTPto match yourMCP_TRANSPORTsetting - URL: Your FC function's public endpoint
- For SSE:
https://<fc-endpoint>/sse - For Streamable HTTP:
https://<fc-endpoint>/mcp
- For SSE:
Troubleshooting
If you encounter error 11200053 ("No active SSE connection for session"):
- Switch to
streamable-httpmode — this is the recommended transport for cloud deployments as it usesstateless_http=Trueand avoids session affinity issues - Ensure
MCP_TRANSPORTis set tostreamable-http(recommended) orsse(notstdio) - Verify the FC function port matches
MCP_PORT(default8000) - Check that the Bailian transport type matches the server's transport mode
- For SSE mode: enable FC "extreme speed mode" (极速模式), set instance limit to 1, and pre-provision 1 snapshot to ensure session affinity
- For Streamable HTTP mode: no special FC configuration needed — stateless mode works with any number of instances
CSRF Crumb Handling
Jenkins implements CSRF protection using "crumbs" - tokens that must be included with POST requests. This MCP server handles CSRF crumbs in two ways:
-
Default Mode: Automatically fetches and includes CSRF crumbs with build requests
- Uses session cookies to maintain the web session
- Handles all the CSRF protection behind the scenes
-
API Token Mode: Uses Jenkins API tokens which are exempt from CSRF protection
- Set
JENKINS_USE_API_TOKEN=true - Set
JENKINS_PASSWORDto your API token instead of password - Works with Jenkins 2.96+ which doesn't require crumbs for API token auth
- Set
You can generate an API token in Jenkins at: User → Configure → API Token → Add new Token
Features
- List Jenkins jobs
- Trigger builds with optional parameters
- Check build status
- CSRF crumb handling for secure API access
- Multiple transport modes (stdio, SSE, Streamable HTTP) for flexible deployment
Development
# Install dependencies
uv pip install -r requirements.txt
# Run in dev mode with Inspector
mcp dev jenkins_mcp/server.py
# Run with SSE transport locally
MCP_TRANSPORT=sse jenkins-mcp
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file camsnetec_jenkins_mcp-3.1.6.tar.gz.
File metadata
- Download URL: camsnetec_jenkins_mcp-3.1.6.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db981b0e7958d0338aa3d67cb289d9ad7dfa36c571ac2fcf32320e7ace74f693
|
|
| MD5 |
5ce631374d50ad17a11c3e814477ac08
|
|
| BLAKE2b-256 |
6109e2c41c53ae420d48e289993259eea47c30bc80b8bba597914572dd7e9af1
|
File details
Details for the file camsnetec_jenkins_mcp-3.1.6-py3-none-any.whl.
File metadata
- Download URL: camsnetec_jenkins_mcp-3.1.6-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f0e7b58a1edb7657f285ae4654286f9f01e8e4f97476cc6b449985436430e21
|
|
| MD5 |
316ea7e0a25b9ac29f83fc938ead5e5b
|
|
| BLAKE2b-256 |
8318613af51aedae6a3da4ab4d481501df521c48f955465aff4b7e69a83202b3
|