Skip to main content

Community Edition Model Context Protocol (MCP) server for Jenkins CI/CD integration

Project description

Jenkins MCP Server - Community Edition

Build License Python Code Style MCP Jenkins

A Community Edition Model Context Protocol (MCP) server for Jenkins CI/CD integration, providing essential Jenkins operations through standardized tools. This open-source version focuses on core functionality for AI assistants to interact with Jenkins instances.

๐ŸŽฏ Overview

The Jenkins MCP Server Community Edition provides essential Jenkins integration for AI assistants with:

  • Core Job Management: List, create, and manage Jenkins jobs
  • Build Operations: Trigger builds and monitor build status
  • Lightweight Design: Focused on essential features without complexity
  • Open Source: MIT licensed for community use and contribution

โœจ Features

๐Ÿ“‹ Core Features (Community Edition)

  1. โœ… List Jenkins Jobs - Browse and filter Jenkins jobs with folder support
  2. โœ… Get Job Details - Retrieve detailed job information and build history
  3. โœ… Create Jenkins Jobs - Create freestyle, pipeline, and folder jobs
  4. โœ… Trigger Builds - Start builds with or without parameters
  5. โœ… Get Build Status - Monitor build progress and results

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   AI Assistant  โ”‚โ—„โ”€โ”€โ–บโ”‚ Jenkins MCP      โ”‚โ—„โ”€โ”€โ–บโ”‚ Jenkins Master  โ”‚
โ”‚   (Claude, etc) โ”‚    โ”‚ Server (CE)      โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚                          โ”‚
                              โ”‚                          โ–ผ
                              โ–ผ                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”‚ Jenkins Agents  โ”‚
                    โ”‚ 5 Core Tools     โ”‚       โ”‚ (Build Nodes)   โ”‚
                    โ”‚ - list_jobs      โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚ - get_details    โ”‚                โ”‚
                    โ”‚ - create_job     โ”‚                โ–ผ
                    โ”‚ - trigger_build  โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚ - get_status     โ”‚       โ”‚ Build Artifacts โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Prerequisites

System Requirements

  • Python: 3.10 or higher
  • Operating System: Linux, macOS, or Windows
  • Memory: Minimum 256MB RAM
  • Network: HTTP/HTTPS access to Jenkins server

Jenkins Requirements

  • Jenkins Version: 2.400+ (LTS recommended)
  • Required Plugins: Basic Jenkins installation (no additional plugins required)

Authentication Requirements

  • Jenkins user account with appropriate permissions
  • API token (recommended) or username/password
  • Required Jenkins permissions:
    • Overall/Read
    • Job/Build, Job/Cancel, Job/Read
    • Job/Create, Job/Configure (for job creation)

๐Ÿš€ Installation

Method 1: From Source

# Clone the repository
git clone <repository-url>
cd jenkins_mcp_community

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

Method 2: Using Docker

# Build the Docker image
docker build -t jenkins-mcp-community .

# Run with Docker
docker run --rm \
  jenkins-mcp-community \
  --jenkins-url http://your-jenkins.com:8080 \
  --jenkins-username your-username \
  --jenkins-token your-api-token

Method 3: Using uvx (Recommended for Quick Testing)

# Run directly with uvx (no installation needed)
uvx jenkins-mcp-server@latest \
  --jenkins-url http://your-jenkins.com:8080 \
  --jenkins-username your-username \
  --jenkins-token your-token

# With environment variables
JENKINS_URL=http://your-jenkins.com:8080 \
JENKINS_USERNAME=your-username \
JENKINS_TOKEN=your-token \
uvx jenkins-mcp-server@latest

โš™๏ธ Configuration

Environment Variables

# Required Configuration
JENKINS_URL=http://your-jenkins-server:8080
JENKINS_USERNAME=your-username
JENKINS_TOKEN=your-api-token

# Optional Configuration
JENKINS_TIMEOUT=30                    # Request timeout in seconds

Getting Jenkins API Token

  1. Log into your Jenkins instance
  2. Go to Manage Jenkins โ†’ Manage Users
  3. Click on your username โ†’ Configure
  4. Under API Token, click Add new Token
  5. Generate and copy the token (store securely)

๐Ÿ“– Usage

Command Line Interface

# Basic usage
python -m jenkins_mcp_server

# With custom configuration
python -m jenkins_mcp_server \
  --jenkins-url http://localhost:8080 \
  --jenkins-username your-username \
  --jenkins-token your-token \
  --log-level DEBUG

With AI Assistants

Amazon Q Developer CLI

Add to your MCP configuration:

{
  "mcpServers": {
    "jenkins": {
      "command": "python",
      "args": [
        "-m", "jenkins_mcp_server",
        "--jenkins-url", "http://your-jenkins.com",
        "--jenkins-username", "your-username", 
        "--jenkins-token", "your-token"
      ]
    }
  }
}

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "jenkins": {
      "command": "python",
      "args": ["-m", "jenkins_mcp_server"],
      "env": {
        "JENKINS_URL": "http://your-jenkins.com",
        "JENKINS_USERNAME": "your-username",
        "JENKINS_TOKEN": "your-token"
      }
    }
  }
}

Available MCP Tools (Community Edition)

Tool Description Example Usage
list_jenkins_jobs List jobs with filtering List all jobs in "production" folder
get_job_details Get detailed job information Get details for "my-pipeline" job
create_jenkins_job Create new jobs Create a freestyle job with build steps
trigger_jenkins_build Trigger builds with parameters Trigger build with BRANCH=main
get_build_status Get build status and info Get status of build #42

Example Interactions

# List all jobs
"Show me all Jenkins jobs"

# Create a new job
"Create a freestyle job called 'my-app-build'"

# Trigger a build with parameters
"Trigger a build for 'my-pipeline' with ENVIRONMENT=staging"

# Get build status
"What's the status of the latest build for 'my-app'?"

# Get job details
"Show me details for the 'deployment-pipeline' job"

๐Ÿ“ Project Structure

jenkins_mcp_community/
โ”œโ”€โ”€ ๐Ÿ“„ README.md                     # This file
โ”œโ”€โ”€ ๐Ÿ“„ LICENSE                       # MIT license
โ”œโ”€โ”€ โš™๏ธ pyproject.toml                # Project configuration
โ”œโ”€โ”€ ๐Ÿณ Dockerfile                    # Docker image definition
โ”œโ”€โ”€ ๐Ÿ“ฆ jenkins_mcp_server/           # Main package
โ”‚   โ”œโ”€โ”€ ๐Ÿ __init__.py              # Package initialization
โ”‚   โ”œโ”€โ”€ ๐Ÿ __main__.py              # CLI entry point
โ”‚   โ”œโ”€โ”€ ๐Ÿ server.py                # FastMCP server implementation
โ”‚   โ”œโ”€โ”€ ๐Ÿ models.py                # Pydantic data models
โ”‚   โ”œโ”€โ”€ ๐Ÿ exceptions.py            # Custom exception classes
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ handlers/                # Request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ base_handler.py      # Base handler with common functionality
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ job_handler.py       # Job management operations
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ build_handler.py     # Build management operations
โ”‚   โ””โ”€โ”€ ๐Ÿ“ utils/                   # Utility modules
โ”‚       โ”œโ”€โ”€ ๐Ÿ cache.py             # Simple caching system
โ”‚       โ”œโ”€โ”€ ๐Ÿ connection_pool.py   # HTTP connection pooling
โ”‚       โ”œโ”€โ”€ ๐Ÿ retry.py             # Retry logic with backoff
โ”‚       โ”œโ”€โ”€ ๐Ÿ validation.py        # Input validation
โ”‚       โ”œโ”€โ”€ ๐Ÿ logging_helper.py    # Structured logging
โ”‚       โ””โ”€โ”€ ๐Ÿ path_utils.py        # Path manipulation utilities
โ””โ”€โ”€ ๐Ÿงช tests/                       # Test suite
    โ”œโ”€โ”€ ๐Ÿงช conftest.py              # Pytest configuration
    โ”œโ”€โ”€ ๐Ÿ“ unit/                    # Unit tests
    โ””โ”€โ”€ ๐Ÿ“ integration/             # Integration tests

๐Ÿงช Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=jenkins_mcp_server --cov-report=html

# Run specific test categories
pytest tests/unit/          # Unit tests only
pytest tests/integration/   # Integration tests only

๐Ÿ”’ Security Considerations

Authentication & Authorization

  • API Tokens: Use Jenkins API tokens instead of passwords
  • Least Privilege: Grant minimum required permissions
  • Secure Storage: Store credentials in environment variables

Required Jenkins Permissions

Overall:
  - Read

Job:
  - Build (for triggering builds)
  - Configure (for creating/updating jobs)
  - Create (for creating new jobs)
  - Read (for viewing job details)

Network Security

  • HTTPS: Use HTTPS for Jenkins connections in production
  • Firewall: Restrict network access to Jenkins server
  • Certificate Validation: Enable SSL certificate verification

๐Ÿค Contributing

We welcome contributions to this open-source project!

Development Setup

# Fork and clone the repository
git clone <your-fork-url>
cd jenkins_mcp_community

# Create development environment
python -m venv venv
source venv/bin/activate

# Install development dependencies
pip install -e ".[dev,test]"

# Run tests
pytest

Pull Request Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Ensure all tests pass (pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Standards

  • Code Style: Follow PEP 8 (enforced by ruff)
  • Type Hints: Use type hints throughout
  • Documentation: Update docstrings and documentation
  • Tests: Add tests for new functionality
  • Commit Messages: Use conventional commit format

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 Jenkins MCP Community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

๐Ÿ™ Acknowledgements

Core Dependencies

Special Thanks

  • Jenkins Community - For the amazing CI/CD platform
  • MCP Protocol Team - For the standardized AI integration protocol
  • Python Community - For the excellent ecosystem of tools and libraries

Jenkins MCP Server Community Edition - Open Source Jenkins Integration for AI

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

jenkins_mcp_community-1.0.0.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

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

jenkins_mcp_community-1.0.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file jenkins_mcp_community-1.0.0.tar.gz.

File metadata

  • Download URL: jenkins_mcp_community-1.0.0.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for jenkins_mcp_community-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dd4aee83572d7ee5058099930258e3bad5161f4aa63370174a1f694a85d74030
MD5 33a9c91dd78ed6c8f32efef172095552
BLAKE2b-256 25725e7df6905fce0be29965acb3c237c42b330a0c548b0b48301730429ffa73

See more details on using hashes here.

File details

Details for the file jenkins_mcp_community-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jenkins_mcp_community-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc354096170df43d4cfe759aa5f6bfcc90ba3056f33b21ad83aa1e7880f7e4e1
MD5 f976b8fb56d96dcae842d8c1ad36cae9
BLAKE2b-256 38df92c2b4702aaeee2be88e98314329f0df7363b69e8d9a17bc836afb4d83a8

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