A Python-based Jenkins MCP server using the Model Context Protocol Python SDK
Project description
Jenkins MCP Server
A Python-based Jenkins MCP server using the Model Context Protocol Python SDK. This server integrates with Jenkins CI/CD systems to provide AI-powered insights, build management, and debugging capabilities.
Note: This server follows the Model Context Protocol (MCP), enabling AI assistants to interact with Jenkins systems directly.
Installation
Option 1: Install as a Python Package (Recommended)
The easiest way to install and run this server is as a Python package:
# Install directly from GitHub
pip install git+https://github.com/yourusername/jenkins-mcp-server.git
# Run the server
jenkins-mcp-server --verbose
Option 2: Clone and Run
# Clone the repository
git clone https://github.com/yourusername/jenkins-mcp-server.git
cd jenkins-mcp-server
# Create a virtual environment and install dependencies
uv venv
uv pip install -e .
# Run the server
python -m jenkins_mcp_server
VS Code Integration
To use this MCP server in VS Code:
- Install the MCP extension for VS Code
- Configure your VS Code settings as shown below
- Connect any AI assistant that supports MCP to your Jenkins environment
Components
Resources
The server provides access to Jenkins jobs as resources:
- Custom jenkins:// URI scheme for accessing individual jobs
- Each job resource contains details about the job and its builds in JSON format
- Job status is reflected in the resource description
Prompts
The server provides prompts for Jenkins data analysis:
-
analyze-job-status: Creates analysis of all Jenkins jobs
- Optional "detail_level" argument to control analysis depth (brief/detailed)
- Analyzes job statuses, identifies potential issues, and suggests improvements
-
analyze-build-logs: Analyzes build logs for a specific job
- Required "job_name" argument to specify which job to analyze
- Optional "build_number" argument (defaults to latest build)
- Examines build logs to identify issues, errors, warnings, and suggests fixes
Tools
The server implements three tools for Jenkins operations:
-
trigger-build: Triggers a Jenkins job build
- Required "job_name" argument to specify which job to build
- Optional "parameters" object containing job parameters
- Returns build queue information
-
stop-build: Stops a running Jenkins build
- Required "job_name" and "build_number" arguments
- Halts an in-progress build execution
-
get-job-details: Gets detailed information about a specific job
- Required "job_name" argument
- Returns comprehensive job information including recent builds
Configuration
Option 1: VS Code Settings (Recommended)
Configure your Jenkins connection in VS Code settings.json:
- Open VS Code Settings (Press
Cmd+,on Mac orCtrl+,on Windows/Linux) - Click on the "Open Settings (JSON)" button in the top right
- Add these settings:
"mcp.servers": {
"jenkins-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": ["jenkins-mcp-server"]
}
},
"jenkins-mcp-server.jenkins": {
"url": "http://your-jenkins-server:8080",
"username": "your-username",
"token": "your-api-token" // Recommended: use token instead of password
// "password": "your-password" // Alternative: use password
}
This configuration:
- Registers the MCP server in VS Code
- Stores your Jenkins credentials securely in VS Code settings
- Uses
uvxto run the server automatically when needed
Option 2: Environment Variables
Alternatively, configure your Jenkins connection by setting environment variables:
-
Copy the
.env.examplefile to create a.envfile:cp .env.example .env
-
Edit the
.envfile with your Jenkins details:JENKINS_URL=http://your-jenkins-server:8080 JENKINS_USERNAME=your-username JENKINS_PASSWORD=your-password # OR use an API token instead of password (recommended) JENKINS_TOKEN=your-api-token
Security Note: Using VS Code settings is more secure as they are stored encrypted. Environment variables in a
.envfile are stored in plain text.
Usage with AI Assistants
Once configured, AI assistants that support MCP can now interact with your Jenkins server through natural language. Here are some examples of what you can do:
GitHub Copilot Chat
- Open GitHub Copilot Chat in VS Code
- Type prompts like:
- "List all my Jenkins jobs"
- "What's the status of my 'deployment' job?"
- "Show me the build logs for the failed build in 'test-project'"
- "Trigger a new build for 'deploy-api'"
Command Line Usage
You can also run the server directly from the command line:
# Run the MCP server
uvx jenkins-mcp-server
# In another terminal, use curl to test it:
curl -X POST http://localhost:8080/mcp/v1/listResources -H "Content-Type: application/json" -d '{}'
Command-Line Usage
The uvx command makes it easy to use the MCP server in command-line environments without VS Code:
# Install UVX if you don't have it yet
pip install uv
# Install the Jenkins MCP server
uvx install git+https://github.com/yourusername/jenkins-mcp-server.git
# Run the server with verbose output
uvx jenkins-mcp-server --verbose
Testing from Command Line
You can test the server directly using the included demo script:
# Run the demo script
./demo.py
Or manually send JSON-RPC requests:
echo '{"jsonrpc":"2.0","id":1,"method":"listResources","params":{}}' | uvx jenkins-mcp-server
Development Setup
If you're developing this MCP server:
- Clone this repository
- Install dependencies:
uv venv uv pip install -e ".[dev]"
- Run the server in development mode:
python -m jenkins_mcp_server --verbose
VS Code Configuration for Development
For development in VS Code:
"mcp": {
"servers": {
"jenkins-mcp-server": {
"type": "stdio",
"command": "bash",
"args": [
"-c",
"uvx jenkins-mcp-server"
]
}
}
}
- Install the GitHub Copilot Chat extension
- Enable MCP in Copilot settings
- Start a new chat with Copilot and interact with your Jenkins server!
3. Claude Desktop
For Claude Desktop users:
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
Development Configuration
"mcpServers": {
"jenkins-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/Users/annmariyajoshy/vibecoding/jenkins-mcp-server-v2",
"run",
"jenkins-mcp-server"
]
}
}
Published Configuration (using uvx)
"mcpServers": {
"jenkins-mcp-server": {
"command": "uvx",
"args": [
"jenkins-mcp-server"
]
}
}
Development
Building and Publishing
To prepare the package for distribution:
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/ directory.
- Publish to PyPI:
uv publish
Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token:
--tokenorUV_PUBLISH_TOKEN - Or username/password:
--username/UV_PUBLISH_USERNAMEand--password/UV_PUBLISH_PASSWORD
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm with this command:
npx @modelcontextprotocol/inspector uv --directory /Users/annmariyajoshy/vibecoding/jenkins-mcp-server-v2 run jenkins-mcp-server
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
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 jenkins_mcp_server-0.1.2.tar.gz.
File metadata
- Download URL: jenkins_mcp_server-0.1.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e26822ebc5ccdf030b6175031955f9306b9cc23493cfa977c65bb4b7495aeab
|
|
| MD5 |
a59c1fa2af02738b5d29ca4d8f0a2612
|
|
| BLAKE2b-256 |
c4757d02f4a48aa4fbad0d4594c9005e60f7c7f81955970c124454013b2b99e9
|
File details
Details for the file jenkins_mcp_server-0.1.2-py3-none-any.whl.
File metadata
- Download URL: jenkins_mcp_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af9d989185f164d2a686b5eec3db79663a01eac82abd4b8ce7c5d83f49ac4c7f
|
|
| MD5 |
63ba70110a4efa33d32bd032fc9bd042
|
|
| BLAKE2b-256 |
9c2a27d878dd902d1d8eb856487efae6550f55eb0282c9fb72d7bc8c18d8cce9
|