Skip to main content

The Model Context Protocol (MCP) 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.

Project description

MCP Jenkins

PyPI Version PyPI Downloads test License

The Model Context Protocol (MCP) 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.

Cursor Demo

cursor demo

Setup Guide

Installation

Choose one of these installation methods:

# 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

Docker Installation

Pull the latest image from GitHub Container Registry:

docker pull ghcr.io/lanbaoshen/mcp-jenkins:latest

Configuration and Usage

Cursor

  1. Open Cursor Settings
  2. Navigate to MCP
  3. Click + Add new global MCP server

This will create or edit the ~/.cursor/mcp.json file with your MCP server configuration.

{
  "mcpServers": {
    "mcp-jenkins": {
      "command": "uvx",
      "args": [
        "mcp-jenkins",
        "--jenkins-url=xxx",
        "--jenkins-username=xxx",
        "--jenkins-password=xxx"
      ]
    }
  }
}

Note: You can set your Jenkins token to password too!

VSCode Copilot Chat

  1. Create .vscode folder with mcp.json file in you workspace for local setup or edit settings.json trough settings menù.
  2. Insert the following configuration:

Option 1: Using HTTP Headers (Recommended)

Pass Jenkins credentials directly via HTTP headers in the mcp.json configuration. This method leverages FastMCP's ASGI middleware to securely extract credentials from HTTP request headers.

  • SSE mode
{
    "servers": {
        "jenkins": {
            "url": "http://localhost:3000/sse",
            "type": "sse",
            "headers": {
                "x-jenkins-url": "https://your-jenkins-server.com",
                "x-jenkins-username": "your-username",
                "x-jenkins-password": "your-api-token"
            }
        }
    }
}
  • Streamable-Http mode (Recommended)
{
    "servers": {
        "mcp-jenkins": {
            "autoApprove": [],
            "disabled": false,
            "timeout": 60,
            "type": "streamableHttp",
            "url": "http://localhost:3000/mcp",
            "headers": {
                "x-jenkins-url": "https://your-jenkins-server.com",
                "x-jenkins-username": "your-username",
                "x-jenkins-password": "your-api-token"
            }
        }
    }
}

Then start the MCP server without credentials (they'll be automatically extracted from headers):

# For SSE transport
uvx mcp-jenkins --transport sse --port 3000

# For streamable-http transport  
uvx mcp-jenkins --transport streamable-http --port 3000

Option 2: Using CLI Arguments (Traditional Method)

Pass credentials when starting the server:

  • SSE mode
{
    "servers": {
        "jenkins": {
            "url": "http://localhost:9887/sse",
            "type": "sse"
        }
    }
}
  • Streamable-Http mode
{
    "servers": {
        "mcp-jenkins": {
            "autoApprove": [],
            "disabled": false,
            "timeout": 60,
            "type": "streamableHttp",
            "url": "http://localhost:9887/mcp"
        }
    }
}

Start the server (credentials will be read from environment variables):

uvx mcp-jenkins --transport sse --port 3000
# or
uvx mcp-jenkins --transport streamable-http --port 3000

Option 3: Using CLI Arguments (Sets Environment Variables)

Pass credentials as command-line arguments. These will be set as environment variables for the server process:

uvx mcp-jenkins \
  --jenkins-url https://your-jenkins-server.com \
  --jenkins-username your_username  \
  --jenkins-password your_password_or_token \
  --transport sse --port 9887

line arguments

# Stdio Mode
uvx mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx --read-only

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

# Streamable-Http Mode
uvx mcp-jenkins --jenkins-url xxx --jenkins-username xxx --jenkins-password xxx --transport streamable-http --port 9887

AutoGen

Install and exec

Install autogen:

pip install "autogen-ext[azure,ollama,openai,mcp]" autogen-chat

Run python scripts:

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())

Available Tools

Tool Description
get_all_jobs Get all jobs
get_job_config Get job config
search_jobs Search job by specific field
get_running_builds Get running builds
stop_build Stop running build
get_build_info Get build info
get_build_sourcecode Get the pipeline source code of a specific build in Jenkins
get_job_info Get job info
build_job Build a job with param
get_build_logs Get build logs
get_test_results Get test results for a specific build
get_all_nodes Get nodes
get_node_config Get the config of node
get_all_queue_items Get all queue items
get_queue_item Get queue item info
cancel_queue_item Cancel queue item
get_multibranch_jobs Get all multibranch pipeline jobs from Jenkins, optionally filtered by patterns
get_multibranch_branches Get all branches for a specific multibranch pipeline job
scan_multibranch_pipeline Trigger a scan of a multibranch pipeline to discover new branches

Development & Debugging

# 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

Pre-Commit Hook

# Install Dependency
uv sync --all-extras --dev
pre-commit install

# Manually execute
pre-commit run --all-files

UT

# Install Dependency
uv sync --all-extras --dev

# Execute UT
uv run pytest --cov=mcp_jenkins

License

Licensed under MIT - see LICENSE file. This is not an official Jenkins product.

MCP-Jenkins in MCP Registries

Star History

Star History Chart

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

mcp_jenkins-0.5.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

mcp_jenkins-0.5.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file mcp_jenkins-0.5.0.tar.gz.

File metadata

  • Download URL: mcp_jenkins-0.5.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcp_jenkins-0.5.0.tar.gz
Algorithm Hash digest
SHA256 855601b96ff61b6c00e3197433c0043999b18a3dc4147349353a04fc296f31fa
MD5 081deb78c42d8dbe4fadba43b6f8f8d6
BLAKE2b-256 17f0f7fdb30162f9f10fdb3171d1f6f5e99ce2308f1b61d94909a90b22f2e9ea

See more details on using hashes here.

File details

Details for the file mcp_jenkins-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_jenkins-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcp_jenkins-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d39557cc8004fd77de9403e1a1e31f0cf4383dd26fcbb277e1f51a797a37b48
MD5 1779e6a12091266356a17d7d2dd8882b
BLAKE2b-256 6c0bc1818c134cb1c7af87bf80713ac6a19592561fb40e449195f94fdfe1400f

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