Skip to main content

MCP server for managing Jenkins operations

Project description

Jenkins MCP

smithery badge MCP server for managing Jenkins operations.

Jenkins MCP server

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 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": ["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=sse
    MCP_PORT=8000
    

Important: For Bailian platform, use MCP_TRANSPORT=sse with endpoint path /sse, or MCP_TRANSPORT=streamable-http with endpoint path /mcp.

4. Configure in Bailian MCP Management

In the Bailian console MCP management page:

  • Transport Type: Select SSE or Streamable HTTP to match your MCP_TRANSPORT setting
  • URL: Your FC function's public endpoint
    • For SSE: https://<fc-endpoint>/sse
    • For Streamable HTTP: https://<fc-endpoint>/mcp

Troubleshooting

If you encounter error 11200053 ("No active SSE connection for session"):

  • Ensure MCP_TRANSPORT is set to sse or streamable-http (not stdio)
  • Verify the FC function port matches MCP_PORT (default 8000)
  • Check that the Bailian transport type matches the server's transport mode
  • Enable FC "extreme speed mode" (极速模式) to reduce cold start latency

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:

  1. 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
  2. API Token Mode: Uses Jenkins API tokens which are exempt from CSRF protection

    • Set JENKINS_USE_API_TOKEN=true
    • Set JENKINS_PASSWORD to your API token instead of password
    • Works with Jenkins 2.96+ which doesn't require crumbs for API token auth

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

camsnetec_jenkins_mcp-3.1.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

camsnetec_jenkins_mcp-3.1.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file camsnetec_jenkins_mcp-3.1.1.tar.gz.

File metadata

  • Download URL: camsnetec_jenkins_mcp-3.1.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for camsnetec_jenkins_mcp-3.1.1.tar.gz
Algorithm Hash digest
SHA256 3a55f3b9bd7d4c32a702c25203de8eb8766969959ddab351410a7e3d4df72455
MD5 304b80e13218cf61fab681fda628bec0
BLAKE2b-256 c39b5cf71acff8e809b0af24dc486622dacdda038cd36fb84ed3800fa8fc0850

See more details on using hashes here.

File details

Details for the file camsnetec_jenkins_mcp-3.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for camsnetec_jenkins_mcp-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77e1243a95f7b753d7599d1114a172c230342844cb4627545a322ab8cf1f174c
MD5 91e6a5e0e7ca79317e3b72afdf00e2f4
BLAKE2b-256 26814badf106ee70972f752987a00602347ae72749cbb19302289176580a0e9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page