Jenkins MCP Tool
Supports containerized deployment for easy integration, allowing the MCP to be run as a Docker container with configuration and token management via environment variables and mounted volumes.
Provides tools for managing multiple Jenkins servers, supporting job search, parameterized build management, real-time build monitoring, and job creation from Jenkinsfiles. Enables automation of common DevOps scenarios like user permission sync, application deployment, and container image sync.
Uses Python 3.11+ as its runtime environment, providing a foundation for the server's implementation and supporting both local development and containerized deployment options.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Jenkins MCP Tool deploy the backend service version 2.5.1 to production"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Jenkins MCP Tool
๐ Introduction
Jenkins MCP is an multi-Jenkins server management and automation tool developed based on the FastMCP framework, designed for DevOps processes. It supports intelligent scenario mapping, multi-server management, complete CI/CD lifecycle operations, and dynamic job creation.
Related MCP server: Jenkins MCP Server
โจ Core Features
๐ข Multi-Server Management
Dynamic Configuration: Supports configuration and dynamic addition/removal of multiple Jenkins servers
Environment Isolation: Supports management of multiple environments such as development, testing, and production
Secure Authentication: Supports token and environment variable-based authentication
๐ฏ Intelligent Scenario Mapping
Pre-configured Scenarios: Built-in common DevOps scenarios (user permission sync, app deployment, image sync)
Smart Recommendation: Automatically selects server and job path based on scenario
Personalized Guidance: Each scenario provides customized operation guidance
โ๏ธ Full CI/CD Support
Job Search: Supports fuzzy and exact search across multi-level directories
Parameterized Build: Automatically detects and validates required parameters
Real-time Monitoring: Build status query and log retrieval
Build Control: Supports build trigger, stop, and management
Job Creation: Create/update Jenkins jobs from Jenkinsfile with automatic directory management
๐ง Developer Friendly
MCP Standard: Complies with Model Context Protocol specification
Dockerized: Containerized deployment for easy integration
Multiple Operation Modes: Supports stdio, SSE, and HTTP transport modes
โ๏ธ Configuration Guide
๐ Config File Structure
Create a config.yaml file to configure Jenkins servers and application scenarios:
# Jenkins server configuration
servers:
- name: maglev-sre # Server alias
uri: https://jenkins.server
user: xhuaustc@gmail.com
tokenEnv: JENKINS_TOKEN # Recommended: get token from environment variable
# Pre-configured application scenarios
scenarios:
"Sync User Permissions":
description: "User permission sync scenario"
server: "shlab"
job_path: "maglev/tool/permission-replicate/"
prompt_template: "Execute user permission sync task. Job path: {job_path}. Please confirm which users' permissions to sync?"
"Deploy Application":
description: "Application deployment scenario, supports diff/sync/build operations"
server: "maglev-sre"
job_path: "release/deploy/"
prompt_template: "Execute application deployment task. Job path: {job_path}. Please confirm the app name, version, and environment to deploy?"
"Sync Image to mldc":
description: "Sync container image to mldc environment"
server: "shlab"
job_path: "mldc-prod/sync-container-image-to-docker-af"
prompt_template: "Execute image sync task. Please provide the image address to sync?"๐ Security Configuration
Recommended: Use environment variables to manage sensitive information
export PROD_BLSM_JENKINS_TOKEN="your-production-token"
export SHLAB_JENKINS_TOKEN="your-shlab-token"Configuration Priority:
Environment variable (variable name specified by
tokenEnv)Direct configuration (
tokenfield)Interactive input (if neither is configured)
๐ Quick Start
๐ณ Docker Method (Recommended)
1. Build Image
cd mcps/jenkins
docker build -t jenkins-mcp .2. Prepare Configuration
Create a config.yaml file (refer to the configuration guide above)
3. Run Container
# Use config file from current directory
docker run -i --rm \
-v ./config.yaml:/app/config.yaml \
-e PROD_BLSM_JENKINS_TOKEN="${PROD_BLSM_JENKINS_TOKEN}" \
-e SHLAB_JENKINS_TOKEN="${SHLAB_JENKINS_TOKEN}" \
jenkins-mcp
# Or specify custom config path
docker run -i --rm \
-v /path/to/your/config.yaml:/app/config.yaml \
-e JENKINS_TOKEN="${JENKINS_TOKEN}" \
jenkins-mcp๐จ MCP Client Integration
Cursor Integration
Set Environment Variables:
export JENKINS_TOKEN="your-jenkins-token"Create Config File: Create
jenkins-config.yamlin the project root:servers: - name: your-jenkins uri: https://your-jenkins.company.com user: your-username tokenEnv: JENKINS_TOKEN scenarios: "Deploy Application": description: "Application deployment scenario" server: "your-jenkins" job_path: "deploy/"Configure Cursor MCP Settings: Add to Cursor's MCP config:
{ "mcpServers": { "jenkins": { "command": "docker", "args": [ "run", "--rm", "-i", "-v", "/path/to/your/jenkins-config.yaml:/app/config.yaml", "-e", "JENKINS_TOKEN=${JENKINS_TOKEN}", "docker.io/mpan083/jenkins-mcp" ], "env": { "JENKINS_TOKEN": "your-jenkins-token" } } } }Usage Example: In Cursor, ask:
"Get the list of available Jenkins scenarios" "Trigger a build for Deploy Application" "Check the status of the latest build" "Create a new test job from Jenkinsfile"
Method 2: Local Installation
Install Dependencies:
cd mcps/jenkins pip install -e .Configure Cursor MCP Settings:
{ "mcpServers": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "~/.jenkinscliconfig:/app/config.yaml", "docker.io/mpan083/jenkins-mcp" ] } } }
๐ง Command Line Arguments
Jenkins MCP supports the following command line arguments:
# Basic usage
jenkins [options]
# Available options:
--transport {stdio,sse,http} # Transport mode (default: stdio)
--host HOST # Bind host (default: 0.0.0.0)
--port PORT # Bind port (default: 8000)
--config, -c CONFIG # Config file path
--scenarios, -s SCENARIOS # Scenario file path
# Usage examples:
jenkins --config my-config.yaml --scenarios my-scenarios.yaml
jenkins --transport sse --port 8080 --scenarios custom-scenarios.yaml๐ง Traditional Startup
# Local development
python -m jenkins --transport stdio
# Use custom config and scenarios
python -m jenkins --config config.yaml --scenarios scenarios.yaml
# Web service
uvicorn jenkins.server:server --reload --host 0.0.0.0 --port 8000๐ Available Tools (11)
๐ง Server Management
Tool | Description | Params |
| Get the list of all available Jenkins servers | None |
| Validate the integrity of Jenkins config | None |
๐ฏ Intelligent Scenarios (Recommended Workflow)
Tool | Description | Params |
| Get all available scenarios | None |
| Search Jenkins jobs by scenario |
|
๐ Job Search and Management
Tool | Description | Params |
| Search Jenkins jobs on a server |
|
| Get job parameter definitions |
|
โ๏ธ Build Management
Tool | Description | Params |
| Trigger Jenkins build |
|
| Get build status |
|
| Stop Jenkins build |
|
| Get build log |
|
๐ Job Creation and Management
Tool | Description | Params |
| Create or update Jenkins job from Jenkinsfile |
|
๐ Recommended Workflow
Scenario-based Deployment (Recommended)
graph TD
A[get_scenario_list] --> B[User selects scenario]
B --> C[search_jobs_by_scenario]
C --> D[get_job_parameters]
D --> E[trigger_build]
E --> F[get_build_status]General Job Search
graph TD
A[get_server_names] --> B[search_jobs]
B --> C[get_job_parameters]
C --> D[trigger_build]
D --> E[get_build_status]Job Creation Workflow
graph TD
A[Prepare Jenkinsfile] --> B[create_or_update_job_from_jenkinsfile]
B --> C[Job created/updated in MCPS/username folder]
C --> D[trigger_build]
D --> E[get_build_status]๐ก Usage Examples
Scenario-based Deployment Example
# 1. Get available scenarios
"Get the list of available Jenkins scenarios"
# 2. Select scenario and search jobs
"Search jobs for the 'Sync Image to mldc' scenario"
# 3. Trigger build
"Trigger image sync task, image address is docker.io/user/app:latest"Direct Operation Example
# 1. View available servers
"Show all available Jenkins servers"
# 2. Search jobs
"Search for jobs containing 'deploy' on the shlab server"
# 3. Get parameters and trigger
"Get parameter definitions for job 'release/deploy/app'"
"Trigger build with parameters: {'APP_NAME': 'myapp', 'VERSION': '1.0.0'}"Job Creation Example
# 1. Create a new test job
"Create a new Jenkins job named 'my-test-job' on shlab server with this Jenkinsfile:
pipeline {
agent any
stages {
stage('Test') {
steps {
echo 'Hello World'
}
}
}
}"
# 2. Update existing job
"Update the 'my-test-job' with a new Jenkinsfile that includes deployment steps"๐ Enhanced Job Information
When searching or getting job information, the following details are returned:
Basic Info: Job name, full name, URL, description
Status: Buildable status, color indicator, parameterization status
Build History: Last build number, last build URL
Parameters: Complete parameter definitions with types and default values
๐๏ธ Job Creation Features
Automatic Directory Management
User Organization: All created jobs are organized under
MCPS/{username}/directoryUsername Extraction: Automatically extracts username from Jenkins server configuration (handles email formats)
Folder Creation: Automatically creates necessary folder structure
Nested Folders: Supports creating jobs in nested folder paths
Job Creation Process
Folder Structure: Jobs are created in
MCPS/{username}/{optional_folder_path}/Conflict Handling: Automatically detects existing jobs and updates configuration
Pipeline Jobs: Creates pipeline jobs with sandbox security enabled
Error Recovery: Robust error handling for folder creation and job updates
๐ฏ Pre-configured Scenarios
Jenkins MCP comes with 3 common DevOps scenarios:
Scenario | Description | Server | Job Path |
Sync User Permissions | User permission sync scenario | shlab |
|
Deploy Application | Application deployment, supports diff/sync/build | maglev-sre |
|
Sync Image to mldc | Sync container image to mldc environment | shlab |
|
๐จ Custom Scenario Configuration
๐ Scenario File Support
Jenkins MCP supports multiple ways to configure custom scenarios:
Standalone Scenario File (Recommended):
# Create custom scenario file cp scenarios.example.yaml scenarios.yaml # Specify scenario file at startup jenkins --scenarios scenarios.yamlEnvironment Variable:
export JENKINS_MCP_SCENARIOS_FILE="/path/to/my-scenarios.yaml" jenkinsConfigure in config.yaml:
scenarios: "Custom Deployment": description: "Custom application deployment scenario" server: "your-jenkins" job_path: "custom/deploy/" prompt_template: "Execute custom deployment task. Please confirm deployment parameters?"
๐ Scenario Merge Rules
Default Scenarios: Load built-in scenarios from
scenarios.default.yamlUser Scenarios: Load from custom scenario file
Merge Strategy: User scenarios take precedence, same-name scenarios override defaults
๐ Scenario File Example
Create a scenarios.yaml file:
scenarios:
"Database Backup":
description: "Execute database backup task"
server: "production"
job_path: "backup/database/"
prompt_template: "Execute database backup task. Please select the database and backup type?"
"Performance Test":
description: "Run application performance test"
server: "test"
job_path: "test/performance/"
prompt_template: "Execute performance test. Please select test scenario and load parameters?"
# Override default scenario
"Deploy Application":
description: "My custom deployment process"
server: "my-jenkins"
job_path: "custom/deploy/"
prompt_template: "Execute custom deployment. Please confirm deployment configuration?"๐งช Testing
Unit Tests
cd mcps/jenkins
pytest tests/ -vDocker Test
# Build and test
docker build -t jenkins-mcp-test .
docker run --rm jenkins-mcp-test jenkins --helpMCP Inspector Testing
# Test with MCP Inspector
npx @modelcontextprotocol/inspector docker run --rm -i -v ./config.yaml:/app/config.yaml jenkins-mcp๐ง Development
Local Development Environment
# Install development dependencies
pip install -e ".[dev]"
# Run code checks
ruff check src/
mypy src/
# Format code
ruff format src/Contribution Guide
Fork this repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
๐ Documentation
Tool Documentation - Complete tool list and usage
FastMCP Documentation - MCP framework docs
Model Context Protocol - MCP protocol standard
๐ Troubleshooting
Common Issues
Q: Failed to connect to Jenkins server?
A: Check network, URL, and authentication info. Use validate_jenkins_config() to validate config.
Q: Build parameter validation failed?
A: Use get_job_parameters() to check required parameters and ensure all are provided.
Q: Docker container failed to start?
A: Check config file mount path and environment variable settings.
Q: Job creation failed with 500 error?
A: Check Jenkins permissions and CSRF settings. The tool automatically handles CSRF tokens.
Q: Cannot create job in specified folder?
A: Ensure you have permission to create folders and jobs. Jobs are automatically organized under MCPS/{username}/.
Log Debugging
# Enable detailed logs
export JENKINS_MCP_LOG_LEVEL=DEBUG
jenkins --transport stdioPerformance Optimization
Multi-level Directory Support: Efficiently handles nested Jenkins folders
Intelligent Parameter Detection: Reduces API calls through smart caching
CSRF Token Management: Automatic token handling for secure Jenkins instances
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Support
If you have questions or suggestions:
Check known issues in Issues
Create a new Issue to report problems
Contact the development team for support
Jenkins MCP - Make Jenkins automation easier ๐
Available Tools
11 toolscreate_or_update_job_from_jenkinsfileA
Create or update a Jenkins job based on a Jenkinsfile.
Args:
server_name: Jenkins server name
job_name: Name for the job (create if not exists, update if exists)
jenkinsfile_content: Content of the Jenkinsfile (pipeline script)
description: Optional job description
ctx: MCP context (for logging)
Returns:
Dict containing job creation/update result with status and job_url
Raises:
JenkinsError: Job creation/update failed
Inputs: server_name (required), job_name (required), jenkinsfile_content (required), description.
get_build_logC
Get Jenkins build log.
Args:
server_name: Jenkins server name
job_full_name: Full job name
build_number: Build number
Returns:
Build log text
Inputs: server_name (required), job_full_name (required), build_number (required). Returns: result
get_build_statusC
Get the Jenkins build status for the specified build_number.
Args:
server_name: Jenkins server name
job_full_name: Full job name
build_number: Build number
Returns:
Build status info
Inputs: server_name (required), job_full_name (required), build_number (required).
get_job_parametersB
Get the parameter definitions of a Jenkins job.
Args:
server_name: Jenkins server name
job_full_name: Full job name
Returns:
List of parameter definitions, including parameter name, type, default value, and options (if choice parameter)
Inputs: server_name (required), job_full_name (required). Returns: result
get_scenario_listA
Get all available application scenarios - the preferred entry point for deployment tasks.
Important: For any deployment-related task, this function should be called first instead of directly using search_jobs.
This function returns a pre-configured scenario list, each containing the correct server and job path configuration.
Returns:
List of scenarios, each containing:
- index: Scenario index (string)
- name: Scenario name
- description: Scenario description
- server: Jenkins server name
- job_path: Job path
Workflow:
1. Call this function to get the scenario list
2. Let the user select a scenario
3. Use search_jobs_by_scenario(scenario) to get the specific job
4. Use trigger_build() to execute deployment
Inputs: no named parameters. Returns: result
get_server_namesA
Get the list of all available Jenkins server names.
Returns:
List of server names
Inputs: no named parameters. Returns: result
search_jobsA
Search Jenkins jobs on the specified server.
Note: For deployment tasks, it is recommended to use get_scenario_list() and search_jobs_by_scenario().
Args:
server_name: Jenkins server name
keyword: Search keyword
Returns:
List of matching jobs
Inputs: server_name (required), keyword (required). Returns: result
search_jobs_by_scenarioB
Get the specified Jenkins job directly by scenario.
Args:
scenario: Scenario name or index
Returns:
List of job info matching the scenario
Inputs: scenario (required). Returns: result
stop_buildB
Stop Jenkins build.
Intelligently handles permission errors and will automatically check build status to confirm if it has already been terminated.
Args:
server_name: Jenkins server name
job_full_name: Full job name
build_number: Build number
ctx: MCP context (for logging)
Returns:
Stop result
Inputs: server_name (required), job_full_name (required), build_number (required). Returns: url, status
trigger_buildA
Trigger Jenkins job build.
Automatically determines parameter requirements and waits to obtain build_number.
Args:
server_name: Jenkins server name
job_full_name: Full job name
params: Optional parameter dict
ctx: MCP context (for logging)
Returns:
Dict containing build_number or queue_id
Raises:
JenkinsParameterError: Missing required parameters
JenkinsError: Trigger failed
Inputs: server_name (required), job_full_name (required), params. Returns: status, message, queue_id, build_url, +2 more
validate_jenkins_configB
Validate the integrity of Jenkins configuration.
Returns:
Validation result, including error list and status
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 11 tools
Most tools have distinct purposes, but some potential overlap exists. For example, search_jobs and search_jobs_by_scenario both search for jobs, though the latter is scenario-specific. Additionally, get_build_log and get_build_status both retrieve build information, but their distinct focuses (log vs. status) help differentiate them. Overall, the tools are well-separated with clear boundaries.
The naming follows a consistent snake_case pattern with clear verb_noun structures, such as get_build_log and trigger_build. However, there are minor deviations like create_or_update_job_from_jenkinsfile, which is more verbose and includes a preposition, and validate_jenkins_config, which uses a noun_verb_noun pattern. These inconsistencies are minor and do not significantly hinder readability.
With 11 tools, the count is well-suited for a Jenkins MCP server. It covers essential operations like job management (create/update, search), build control (trigger, stop, get status/log), and configuration (validate, get parameters). The tools are focused and each serves a clear purpose without being overly broad or sparse.
The toolset provides strong coverage for core Jenkins workflows, including job creation, building, monitoring, and searching. However, there are minor gaps, such as the lack of tools for deleting jobs or managing Jenkins plugins/users. The inclusion of scenario-based deployment tools adds a layer of abstraction that enhances usability but doesn't fill all potential gaps in the Jenkins API surface.
Maintenance
Related MCP Connectors
The Jam MCP server provides AI tools with instant bug context without manual prompting, enabling a streamlined workflow from bug identification to ticket creation and pull request generation without switching between tools.
Build, deploy, and run apps on AWS, GCP, Azure, Oracle Cloud, and your own hardware from chat.
Build and run agents and automations across hundreds of apps using natural language.
The AI orchestration agent for modern software teams.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn integration tool that allows interaction with Jenkins CI/CD servers through a Model Context Protocol interface, enabling users to view server info, manage jobs, inspect builds, and trigger builds with parameters.1-
- AlicenseNot gradedqualityNot gradedmaintenanceA Model Context Protocol (MCP) server that enables AI tools like chatbots to interact with and control Jenkins, allowing users to trigger jobs, check build statuses, and perform other Jenkins operations through natural language.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Jenkins CI/CD systems through natural language, providing build management, job monitoring, log analysis, and debugging capabilities.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Jenkins CI/CD systems for build management, job monitoring, console log analysis, and debugging through natural language commands.2MIT