jenkins-server
AI-enabled Jenkins automation via Model Context Protocol (MCP)
Installation
npx @rishibhushan/jenkins-mcp-serverAsk AI about jenkins-server
Powered by Claude Β· Grounded in docs
I know everything about jenkins-server. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
π§ Jenkins MCP Server
Jenkins MCP Server is an AI-enabled Model Context Protocol (MCP) server that exposes Jenkins automation through natural-language commands.
Designed to work seamlessly with automation clients such as:
- π₯οΈ VS Code MCP - Direct integration with Claude in VS Code
- π₯οΈ Claude Desktop - AI-powered Jenkins automation
- π Any MCP-compatible client - Universal compatibility
β¨ What's New in v1.1.16
π Latest Improvements (v1.1.16)
- β‘ Instant startup - Server initialization in <1 second (previously 30-60s)
- π§ Simplified architecture - Streamlined Node.js wrapper for better reliability
- π Universal compatibility - Works seamlessly with VSCode, Claude Desktop, and all MCP clients
- π Critical fixes - Resolved initialization timeouts and network blocking issues
π Performance Enhancements (v1.1.0)
- β‘ 10x faster - Client connection caching for repeated operations
- π Smart caching - Job list caching with 30-60s TTL (5-10x improvement)
- π― Optimized queries - Reduced API calls by 33-83%
π‘οΈ Reliability Improvements
- β 86% validation coverage - Input validation on 18/21 tools
- β±οΈ Configurable timeouts - No more hanging API calls
- π¬ Better error messages - Clear troubleshooting steps
- π₯ Health check tool - Instant diagnostics
ποΈ Advanced Features
- π¦ Batch operations - Trigger up to 20 builds at once
- π Metrics & telemetry - Track tool usage and performance
- ποΈ Cache management - Monitor and control caching
- π Console improvements - Line-based truncation with tail mode
- π¨ Structured logging - Better debugging with JSON logs
β¨ About codebase
- β Codebase - cleaner, more maintainable
- β Error messages - Know exactly what's wrong and how to fix it
- β Flexible configuration - Multiple ways to configure (VS Code, .env, environment)
- β Cross-platform - Seamless support for Windows, macOS, and Linux
- β
Logging - Professional logging with
--verboseflag - β Dependency management - Automatic detection and installation
- β Performance - 10x faster with intelligent caching and optimization
- β Reliability - Comprehensive input validation and error handling
π¦ Features
This project includes:
- π Python backend powered by
python-jenkins - π¦ Node.js
npxwrapper for zero-install execution - π Automatic virtual environment creation + dependency installation
- π Corporate proxy/certificate auto-detection support
- πͺ Windows, macOS, and Linux support
- π οΈ 26 Jenkins management tools (upgraded from 20!)
π§© Build Operations
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
trigger-build | Trigger a Jenkins job build with optional parameters | job_name | parameters |
stop-build | Stop a running Jenkins build | job_name, build_number | (none) |
trigger-multiple-builds | NEW! Trigger builds for multiple jobs at once | job_names | parameters, wait_for_start |
π Job Information
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
list-jobs | List all Jenkins jobs with optional filtering and caching | (none) | filter, use_cache |
get-job-details | Get detailed information about a Jenkins job | job_name | max_recent_builds |
π οΈ Build Information
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
get-build-info | Get information about a specific build | job_name, build_number | (none) |
get-build-console | Get console output with smart truncation | job_name, build_number | max_lines, tail_only |
get-last-build-number | Get the last build number for a job | job_name | (none) |
get-last-build-timestamp | Get the timestamp of the last build | job_name | (none) |
π§© Job Management
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
create-job | Create a new Jenkins job with XML configuration | job_name, config_xml | (none) |
create-job-from-copy | Create a new job by copying an existing one | new_job_name, source_job_name | (none) |
create-job-from-data | Create a job from structured data (auto-generated XML) | job_name, config_data | root_tag |
delete-job | Delete an existing job | job_name | (none) |
enable-job | Enable a disabled Jenkins job | job_name | (none) |
disable-job | Disable a Jenkins job | job_name | (none) |
rename-job | Rename an existing Jenkins job | job_name, new_name | (none) |
βοΈ Job Configuration
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
get-job-config | Fetch job XML configuration | job_name | (none) |
update-job-config | Update job XML configuration | job_name, config_xml | (none) |
π₯οΈ System Information
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
get-queue-info | Get Jenkins build queue info | (none) | (none) |
list-nodes | List all Jenkins nodes | (none) | (none) |
get-node-info | Get information about a Jenkins node | node_name | (none) |
health-check | NEW! Run diagnostics on Jenkins connection | (none) | (none) |
π Monitoring & Management
| Tool Name | Description | Required Fields | Optional Fields |
|---|---|---|---|
get-cache-stats | NEW! Get cache statistics and information | (none) | (none) |
clear-cache | NEW! Clear all cached data | (none) | (none) |
get-metrics | NEW! Get usage metrics and performance stats | (none) | tool_name |
configure-webhook | NEW! Configure webhook notifications | job_name, webhook_url, events | (none) |
For detailed technical documentation, see docs/ARCHITECTURE.md.
π Quick Start
Prerequisites
Node.js (v14 or higher) is required for the npx wrapper.
Windows Installation
# Using winget (recommended)
winget install OpenJS.NodeJS.LTS
# Verify installation
node -v
npm -v
Or download manually from https://nodejs.org/
macOS Installation
# Install nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Reload shell
source ~/.nvm/nvm.sh
# Install Node LTS
nvm install --lts
nvm use --lts
# Verify installation
node -v
npm -v
Linux Installation
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Fedora/RHEL
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo dnf install -y nodejs
# Verify installation
node -v
npm -v
βοΈ Configuration
Jenkins MCP Server supports multiple configuration methods. Choose the one that works best for you:
Option 1: VS Code Settings (Recommended)
Add to your VS Code settings.json:
{
"jenkins-mcp-server": {
"jenkins": {
"url": "http://jenkins.example.com:8080",
"username": "your-username",
"token": "your-api-token"
}
}
}
Where to find settings.json:
- Windows:
%APPDATA%\Code\User\settings.json - macOS:
~/Library/Application Support/Code/User/settings.json - Linux:
~/.config/Code/User/settings.json
Option 2: Environment File (.env)
Create a file .env in your local:
JENKINS_URL=http://jenkins.example.com:8080
JENKINS_USERNAME=your-username
JENKINS_TOKEN=your-api-token
Note: Use API token instead of password for better security.
Option 3: Environment Variables
# Linux/macOS
export JENKINS_URL=http://jenkins.example.com:8080
export JENKINS_USERNAME=your-username
export JENKINS_TOKEN=your-api-token
# Windows (PowerShell)
$env:JENKINS_URL="http://jenkins.example.com:8080"
$env:JENKINS_USERNAME="your-username"
$env:JENKINS_TOKEN="your-api-token"
Configuration Priority
Settings are loaded in this order (later overrides earlier):
- Default
.envfile - Environment variables
- Custom
.envfile (via--env-file) - VS Code settings
- Direct parameters
Getting Your Jenkins API Token
- Log into Jenkins
- Click your name (top right) β Configure
- Scroll to API Token section
- Click Add new Token
- Give it a name and click Generate
- Copy the token (β οΈ it won't be shown again!)
π Installation/Running the Server
Option 1: Using npx (No Installation Required)
# if .env file is located in the current directory
npx @rishibhushan/jenkins-mcp-server --env-file .env
# OR if .env file is located in /path/to/.env
npx @rishibhushan/jenkins-mcp-server --env-file /path/to/.env
NPX Usage:
- Always use
--yesflag with npx for automatic package installation - First run may take 10-20 seconds to set up Python environment
- Subsequent runs are instant (environment is cached)
Example:
npx --yes @rishibhushan/jenkins-mcp-server --env-file .env
Option 2: Global Installation
# Install globally
npm install -g @rishibhushan/jenkins-mcp-server
# Run
jenkins-mcp-server --env-file .env
Option 3: From GitHub
npx github:rishibhushan/jenkins_mcp_server --env-file .env
This automatically:
- β Installs all dependencies
- β Starts the Jenkins MCP server
Method 2: Direct Python Execution
# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
# Linux/macOS:
source .venv/bin/activate
# Windows:
.venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the server
python -m jenkins_mcp_server --env-file /path/to/.env
Command-Line Options
jenkins-mcp-server [options]
Options:
--env-file PATH Path to custom .env file
--verbose, -v Enable verbose/debug logging
--no-vscode Skip loading VS Code settings
--version Show version information
--help, -h Show help message
π³ Run with Docker (Standalone / CI / Headless environments)
Docker support allows you to run the MCP server without installing Node or Python locally.
βΆοΈ Run the container
docker run -it --rm \
-p 3000:3000 \
-e JENKINS_URL=http://your-jenkins:8080 \
-e JENKINS_USERNAME=your_username \
-e JENKINS_TOKEN=your_token \
ghcr.io/rishibhushan/jenkins-mcp-server:latest
π₯ Pull Prebuilt Image (Recommended)
Pull the official prebuilt image from GitHub Container Registry:
docker pull ghcr.io/rishibhushan/jenkins-mcp-server:latest
This ensures you always run the official published image and do not need the repository locally.
π MCP Client Configuration (Docker)
Example configuration for MCP clients:
{
"jenkins": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"JENKINS_URL",
"-e",
"JENKINS_USERNAME",
"-e",
"JENKINS_TOKEN",
"ghcr.io/rishibhushan/jenkins-mcp-server:latest"
],
"env": {
"JENKINS_URL": "http://your-jenkins:8080",
"JENKINS_USERNAME": "your_username",
"JENKINS_TOKEN": "your_token"
}
}
}
π Required Environment Variables
| Variable | Description |
|---|---|
| JENKINS_URL | Jenkins base URL |
| JENKINS_USERNAME | Jenkins username |
| JENKINS_TOKEN | API token (recommended) |
| JENKINS_PASSWORD | Password (if not using token) |
π§ When to use Docker
Docker is recommended when running the MCP server:
- In CI/CD pipelines
- On Jenkins agents
- As a shared service
- Outside VS Code
- In production-like environments
π§° Docker Troubleshooting
If you run into issues while using the Docker image, try the steps below.
β Image pull fails
docker pull ghcr.io/rishibhushan/jenkins-mcp-server:latest
Fix:
- Ensure Docker Desktop / Docker Engine is running
- Check internet connectivity
- If your org requires authentication, run:
docker login ghcr.io
β Architecture error (e.g. βno matching manifestβ)
Fix:
- Ensure youβre pulling the latest image:
docker pull ghcr.io/rishibhushan/jenkins-mcp-server:latest
- Remove any old local image and retry:
docker rmi ghcr.io/rishibhushan/jenkins-mcp-server:latest
β Container starts but cannot connect to Jenkins
Fix:
- Verify Jenkins URL is reachable from your machine:
curl -I http://your-jenkins:8080
- If Jenkins is on your host machine, use:
http://host.docker.internal:8080
- Ensure VPN is connected if required
β Missing environment variables
The server will not start if credentials are missing.
Ensure these are provided:
JENKINS_URLJENKINS_USERNAMEJENKINS_TOKEN(recommended)
Example:
docker run -it --rm \
-e JENKINS_URL=http://your-jenkins:8080 \
-e JENKINS_USERNAME=user \
-e JENKINS_TOKEN=token \
ghcr.io/rishibhushan/jenkins-mcp-server:latest
β Need logs for debugging
Run container without --rm to inspect logs:
docker run -it \
-e JENKINS_URL=... \
-e JENKINS_USERNAME=... \
-e JENKINS_TOKEN=... \
ghcr.io/rishibhushan/jenkins-mcp-server:latest
Or view logs from another terminal:
docker ps
docker logs <container_id>
β Port already in use
If you see a port conflict:
Bind for 0.0.0.0:3000 failed: port is already allocated
Run with a different port:
docker run -p 3001:3000 ...
If problems persist, please open an issue with:
- Your OS and Docker version
- Full error message
- Steps to reproduce
βοΈ Configuration Priority
The server resolves configuration in this order:
1οΈβ£ Environment variables
2οΈβ£ .env file
3οΈβ£ VS Code settings.json
π§ͺ Verify Server is Running
After starting, you should see logs indicating:
- Jenkins configuration loaded
- MCP server started
- Listening on port
3000
π Integration with VSCode
-
Install VSCode MCP Extension (if not already installed)
-
Configure the server in your workspace or user settings:
Option A: Using mcp.json (Recommended)
{
"servers": {
"jenkins": {
"type": "stdio",
"command": "npx",
"args": [
"@rishibhushan/jenkins-mcp-server"
]
}
}
}
Option B: Using settings.json
Add to your VSCode settings.json. With .env file, --verbose, and proxy settings:
{
"mcp": {
"servers": {
"jenkins": {
"type": "stdio",
"command": "npx",
"args": [
"@rishibhushan/jenkins-mcp-server",
"--verbose",
"--env-file",
"/absolute/path/to/your/.env"
],
"env": {
"HTTP_PROXY": "http://proxy.example.com:8080",
"HTTPS_PROXY": "http://proxy.example.com:8080",
"NO_PROXY": "localhost,127.0.0.1,.example.com"
}
}
}
}
}
Important:
- Always use absolute paths for the
--env-fileparameter - Restart VSCode completely after configuration changes
- Check Output β Model Context Protocol for connection status
- Verify connection:
- Open Command Palette (Cmd/Ctrl+Shift+P)
- Type "MCP" to see available commands
- Should see "Discovered 26 tools" in Output panel
Troubleshooting VSCode Connection
If VSCode shows "Waiting for initialize response":
- Ensure
.envfile path is absolute, not relative - Verify
.envfile has correct Jenkins credentials - Restart VSCode completely (quit and reopen)
- Check Output β Model Context Protocol for error messages
- Try running manually first:
npx --yes @rishibhushan/jenkins-mcp-server --env-file /path/to/.env
π€ Integration with Claude Desktop
-
Locate Claude Desktop config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Add server configuration:
Add to claude_desktop_config.json:
{
"mcpServers": {
"jenkins": {
"command": "npx",
"args": [
"@rishibhushan/jenkins-mcp-server",
"--env-file",
"/absolute/path/to/your/.env"
]
}
}
}
-
Restart Claude Desktop completely
-
Verify:
- You should see a π icon in Claude's input area
- Click it to see "jenkins" server with 26 tools
Troubleshooting Claude Desktop
Common issues:
- Server disconnects after 60s: Make sure you're on VPN if Jenkins requires it
- No tools appear: Check the config file path and restart Claude Desktop
- Connection timeout: Verify Jenkins URL is accessible from your network
π’ Corporate Network / Proxy Setup
If you're behind a corporate proxy or firewall:
Option 1: Set Environment Variables (Recommended)
# Set proxy environment variables
export HTTP_PROXY=http://your-proxy:8080
export HTTPS_PROXY=http://your-proxy:8080
export NO_PROXY=localhost,127.0.0.1
# Run the server (wrapper will auto-detect proxy)
npx @rishibhushan/jenkins-mcp-server --env-file .env
Option 2: Configure npm and pip
# Configure npm proxy
npm config set proxy http://your-proxy:8080
npm config set https-proxy http://your-proxy:8080
# Configure pip proxy (for SSL issues)
pip config set global.proxy http://your-proxy:8080
pip config set global.trusted-host "pypi.org pypi.python.org files.pythonhosted.org"
# Run the server
npx @rishibhushan/jenkins-mcp-server --env-file .env
Option 3: Claude Desktop with Proxy
Add proxy settings to your claude_desktop_config.json:
{
"mcpServers": {
"jenkins": {
"command": "npx",
"args": [
"@rishibhushan/jenkins-mcp-server",
"--env-file",
"/path/to/.env"
],
"env": {
"HTTP_PROXY": "http://your-proxy:8080",
"HTTPS_PROXY": "http://your-proxy:8080",
"NO_PROXY": "localhost,127.0.0.1"
}
}
}
}
SSL Certificate Issues
If you encounter SSL certificate errors:
# Disable SSL verification for pip (one-time setup)
pip config set global.trusted-host "pypi.org pypi.python.org files.pythonhosted.org"
# Or use environment variable
export PIP_TRUSTED_HOST="pypi.org pypi.python.org files.pythonhosted.org"
The Node.js wrapper automatically handles SSL certificate issues when it detects proxy environment variables.
π‘ Usage Examples
Natural Language Commands
Once configured, you can use natural language with your MCP client:
"List all Jenkins jobs"
"List jobs with 'backend' in the name" - # Filter jobs containing "backend"
"Show me all production jobs" - # Filter jobs containing "prod"
"Show me the last build of my-project"
"Trigger a build for deploy-prod with parameter env=production"
"What's in the build queue?"
"Show me the console output of build #42 for backend-service"
"Create a new job called test-job by copying prod-job"
"Disable the old-job"
Programmatic Usage (Python)
from config import get_settings
from jenkins_client import get_jenkins_client
# Load settings
settings = get_settings()
# Create client
client = get_jenkins_client(settings)
# List jobs
all_jobs = client.get_jobs()
for job in all_jobs:
print(f"Job: {job['name']} - Status: {job['color']}")
# Filter in Python
backend_jobs = [job for job in all_jobs if 'backend' in job['name'].lower()]
# Trigger a build
result = client.build_job(
"my-job",
parameters={"BRANCH": "main", "ENV": "staging"}
)
print(f"Build queued: {result['queue_id']}")
print(f"Build number: {result['build_number']}")
# Get console output
if result['build_number']:
output = client.get_build_console_output(
"my-job",
result['build_number']
)
print(output)
π Quick Troubleshooting
Server won't start
# Test if server works manually
npx --yes @rishibhushan/jenkins-mcp-server --env-file /path/to/.env
# Should start and wait for input (Ctrl+C to exit)
VSCode/Claude Desktop can't connect
- β
Use absolute paths for
--env-file - β
Include
--yesflag with npx - β Restart application completely after config changes
- β Check if Jenkins is accessible (try in browser)
- β
Verify
.envfile has correct credentials
Server connects but times out
- β Connect to VPN if Jenkins is on private network
- β Check firewall settings
- β Verify Jenkins URL is correct
- β
Test with:
curl -I http://your-jenkins-url:8080
"Module not found" errors
- β
Delete
.venvfolder and let it reinstall - β
Clear npm cache:
npm cache clean --force - β
Try with latest version:
npx --yes @rishibhushan/jenkins-mcp-server@latest
π§ Troubleshooting
Common Issues
Python Not Found
Error: Python 3 is required but not found.
Solution: Install Python 3.8+ from https://www.python.org/downloads/
Configuration Issues
ERROR: Jenkins configuration is incomplete!
Solution: Verify you have set JENKINS_URL, JENKINS_USERNAME, and JENKINS_TOKEN
Check your configuration:
# View .env file
cat .env
# Check environment variables
env | grep JENKINS
# Check VS Code settings
cat ~/.config/Code/User/settings.json | grep jenkins
Connection Failed
Failed to connect to Jenkins at http://localhost:8080
Solution:
- Verify Jenkins is running:
curl http://localhost:8080/api/json - Check firewall settings
- Verify URL is correct (include port if needed)
- Test authentication credentials
Dependency Installation Failed
Failed to install dependencies
Solution:
- Check internet connection
- If behind a proxy, set
HTTP_PROXYandHTTPS_PROXYenvironment variables - Try manual installation:
.venv/bin/pip install -r requirements.txt
π¨ VPN & Corporate Network Issues
If you're experiencing timeout issues with Claude Desktop or other MCP clients when using a VPN or corporate network, this section provides step-by-step solutions.
Symptom: Request Timeout After 60 Seconds
Error in logs:
McpError: MCP error -32001: Request timed out
Server transport closed unexpectedly
Root Cause: The Python process spawned by npx may not properly inherit VPN network routing, causing it to fail when connecting to internal Jenkins servers.
Solution 1: Bypass Proxy for PyPI (For Dependency Installation Issues)
If you're getting proxy errors during dependency installation:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"jenkins": {
"command": "npx",
"args": [
"@rishibhushan/jenkins-mcp-server",
"--env-file",
"/path/to/.env"
],
"env": {
"NO_PROXY": "pypi.org,pypi.python.org,files.pythonhosted.org",
"PIP_NO_PROXY": "pypi.org,pypi.python.org,files.pythonhosted.org"
}
}
}
}
Solution 2: Use Direct Python Execution (Recommended for VPN)
This bypasses the npx wrapper entirely and uses Python directly, which properly inherits your system's network routing.
Step 1: Locate the Installed Package
For macOS/Linux:
# Find the npx cache directory
PACKAGE_DIR=$(find ~/.npm/_npx -name "jenkins-mcp-server" -type d 2>/dev/null | head -1)
echo $PACKAGE_DIR
For Windows (PowerShell):
# Find the npx cache directory
$PACKAGE_DIR = Get-ChildItem -Path "$env:LOCALAPPDATA\npm-cache\_npx" -Recurse -Directory -Filter "jenkins-mcp-server" | Select-Object -First 1 -ExpandProperty FullName
Write-Host $PACKAGE_DIR
The output will be something like:
- macOS/Linux:
/Users/username/.npm/_npx/<hash>/node_modules/@rishibhushan/jenkins-mcp-server - Windows:
C:\Users\username\AppData\Local\npm-cache\_npx\<hash>\node_modules\@rishibhushan\jenkins-mcp-server
Step 2: Update Claude Desktop Configuration
Replace <PACKAGE_DIR> with the path from Step 1:
macOS/Linux:
{
"mcpServers": {
"jenkins": {
"command": "<PACKAGE_DIR>/.venv/bin/python",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"/path/to/your/.env"
],
"env": {
"PYTHONPATH": "<PACKAGE_DIR>/src"
}
}
}
}
Windows:
{
"mcpServers": {
"jenkins": {
"command": "<PACKAGE_DIR>\\.venv\\Scripts\\python.exe",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"C:\\path\\to\\your\\.env"
],
"env": {
"PYTHONPATH": "<PACKAGE_DIR>\\src"
}
}
}
}
Step 3: Example Configuration
Complete example for macOS:
{
"mcpServers": {
"jenkins": {
"command": "/Users/username/.npm/_npx/a88b5f55f40c4229/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"/Users/username/projects/jenkins_mcp_server/.env"
],
"env": {
"PYTHONPATH": "/Users/username/.npm/_npx/a88b5f55f40c4229/node_modules/@rishibhushan/jenkins-mcp-server/src"
}
}
}
}
Step 4: Restart Claude Desktop
- Connect to your VPN first
- Quit Claude Desktop completely
- Start Claude Desktop
- Check the MCP server connection in settings
Solution 3: Use Local Git Clone (Best for Development)
If you're developing or frequently updating, use a local clone:
Step 1: Clone and Setup
# Clone the repository
git clone https://github.com/rishibhushan/jenkins_mcp_server.git
cd jenkins_mcp_server
# Create virtual environment and install dependencies
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
Step 2: Configure Claude Desktop
macOS/Linux:
{
"mcpServers": {
"jenkins": {
"command": "/path/to/jenkins_mcp_server/.venv/bin/python",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"/path/to/jenkins_mcp_server/.env"
],
"env": {
"PYTHONPATH": "/path/to/jenkins_mcp_server/src"
}
}
}
}
Windows:
{
"mcpServers": {
"jenkins": {
"command": "C:\\path\\to\\jenkins_mcp_server\\.venv\\Scripts\\python.exe",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"C:\\path\\to\\jenkins_mcp_server\\.env"
],
"env": {
"PYTHONPATH": "C:\\path\\to\\jenkins_mcp_server\\src"
}
}
}
}
Solution 4: Use Global Installation with Direct Python Path
If you prefer to use global installation but still face VPN/timeout issues, you can combine both approaches.
Step 1: Install Globally
Disconnect from VPN first (to avoid proxy issues during installation):
# Install globally
npm install -g @rishibhushan/jenkins-mcp-server
# Verify installation
jenkins-mcp-server --version
Step 2: Locate Global Installation Directory
For macOS/Linux:
# Find the global npm directory
npm root -g
# This typically returns something like:
# /usr/local/lib/node_modules
# or
# /Users/username/.npm-global/lib/node_modules
# Your package will be at:
# <npm-root>/@rishibhushan/jenkins-mcp-server
For Windows (PowerShell):
# Find the global npm directory
npm root -g
# This typically returns something like:
# C:\Users\username\AppData\Roaming\npm\node_modules
# Your package will be at:
# <npm-root>\@rishibhushan\jenkins-mcp-server
Step 3: Find the Python Path
Once you know the installation directory:
macOS/Linux:
# If npm root -g shows: /usr/local/lib/node_modules
# Your Python path will be:
/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python
# Verify it exists:
ls -la /usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python
Windows:
# If npm root -g shows: C:\Users\username\AppData\Roaming\npm\node_modules
# Your Python path will be:
C:\Users\username\AppData\Roaming\npm\node_modules\@rishibhushan\jenkins-mcp-server\.venv\Scripts\python.exe
# Verify it exists:
Test-Path "C:\Users\username\AppData\Roaming\npm\node_modules\@rishibhushan\jenkins-mcp-server\.venv\Scripts\python.exe"
Step 4: Configure Your MCP Client
For Claude Desktop (macOS/Linux):
{
"mcpServers": {
"jenkins": {
"command": "/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/.venv/bin/python",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"/path/to/your/.env"
],
"env": {
"PYTHONPATH": "/usr/local/lib/node_modules/@rishibhushan/jenkins-mcp-server/src"
}
}
}
}
For Claude Desktop (Windows):
{
"mcpServers": {
"jenkins": {
"command": "C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\@rishibhushan\\jenkins-mcp-server\\.venv\\Scripts\\python.exe",
"args": [
"-m",
"jenkins_mcp_server",
"--env-file",
"C:\\path\\to\\your\\.env"
],
"env": {
"PYTHONPATH": "C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\@rishibhushan\\jenkins-mcp-server\\src"
}
}
}
}
For Other MCP Clients:
Use the same pattern - replace the command with the direct Python path and set the PYTHONPATH environment variable.
Step 5: Test and Use
- Connect to your VPN
- Restart your MCP client (Claude Desktop, VS Code, etc.)
- Verify the connection works
Why This Solution Works
- β Persistent installation - No need to download on each use
- β Proper network routing - Python process inherits VPN routing
- β Works across sessions - Survives VPN connect/disconnect cycles
- β
Easy updates - Just run
npm update -g @rishibhushan/jenkins-mcp-server - β Universal - Works with any MCP client (Claude, VS Code, etc.)
Quick Reference Commands
# Find your global installation
npm root -g
# Update global installation
npm update -g @rishibhushan/jenkins-mcp-server
# Uninstall if needed
npm uninstall -g @rishibhushan/jenkins-mcp-server
# Test the Python path works
/path/to/global/installation/.venv/bin/python -m jenkins_mcp_server --help
π§ͺ Testing Your Connection
Before configuring MCP clients, test your Jenkins connection manually:
Create a Test Script
Save this as test_jenkins_connection.py:
#!/usr/bin/env python3
"""
Test Jenkins connectivity for MCP server troubleshooting
"""
import os
import sys
import time
import requests
from dotenv import load_dotenv
def test_connection():
# Load environment
env_file = '/path/to/your/.env' # Update this path
print(f"Loading environment from: {env_file}")
load_dotenv(env_file)
url = os.getenv('JENKINS_URL')
username = os.getenv('JENKINS_USERNAME')
token = os.getenv('JENKINS_TOKEN')
print(f"\nJenkins Configuration:")
print(f" URL: {url}")
print(f" Username: {username}")
print(f" Token: {'***' if token else 'NOT SET'}")
# Test 1: DNS Resolution
print(f"\n[Test 1] Testing DNS resolution...")
import socket
try:
hostname = url.split('://')[1].split(':')[0]
ip = socket.gethostbyname(hostname)
print(f" β DNS resolved: {hostname} -> {ip}")
except Exception as e:
print(f" β DNS resolution failed: {e}")
return False
# Test 2: Basic connectivity
print(f"\n[Test 2] Testing basic HTTP connectivity...")
try:
start = time.time()
response = requests.get(f"{url}/api/json", timeout=5)
elapsed = time.time() - start
print(f" β Connection successful (no auth): {response.status_code} in {elapsed:.2f}s")
except requests.exceptions.Timeout:
print(f" β Connection timed out after 5 seconds")
return False
except Exception as e:
print(f" β Connection failed: {e}")
return False
# Test 3: Authenticated request
print(f"\n[Test 3] Testing authenticated request...")
try:
start = time.time()
response = requests.get(
f"{url}/api/json",
auth=(username, token),
timeout=10
)
elapsed = time.time() - start
print(f" β Authenticated request: {response.status_code} in {elapsed:.2f}s")
if response.status_code == 200:
data = response.json()
print(f" β Jenkins version: {data.get('version', 'unknown')}")
print(f" β Number of jobs: {len(data.get('jobs', []))}")
elif response.status_code == 401:
print(f" β Authentication failed - check username/token")
return False
elif response.status_code == 403:
print(f" β Access forbidden - check permissions")
return False
except Exception as e:
print(f" β Authenticated request failed: {e}")
return False
# Test 4: python-jenkins library
print(f"\n[Test 4] Testing python-jenkins library...")
try:
import jenkins
start = time.time()
server = jenkins.Jenkins(url, username=username, password=token)
user = server.get_whoami()
elapsed = time.time() - start
print(f" β python-jenkins connection: {user['fullName']} in {elapsed:.2f}s")
except Exception as e:
print(f" β python-jenkins failed: {e}")
return False
print(f"\nβ All tests passed! Jenkins MCP Server should work.")
return True
if __name__ == "__main__":
print("=" * 60)
print("Jenkins MCP Server - Connection Diagnostic")
print("=" * 60)
success = test_connection()
sys.exit(0 if success else 1)
Run the Test
# Connect to VPN first
# Then run:
cd /path/to/jenkins_mcp_server
source .venv/bin/activate
python test_jenkins_connection.py
Expected output if everything works:
============================================================
Jenkins MCP Server - Connection Diagnostic
============================================================
[Test 1] Testing DNS resolution...
β DNS resolved: jenkins.example.com -> 10.0.0.1
[Test 2] Testing basic HTTP connectivity...
β Connection successful (no auth): 200 in 0.45s
[Test 3] Testing authenticated request...
β Authenticated request: 200 in 0.52s
β Jenkins version: 2.401.3
β Number of jobs: 42
[Test 4] Testing python-jenkins library...
β python-jenkins connection: John Doe in 0.38s
β All tests passed! Jenkins MCP Server should work.
If all tests pass but MCP still fails, use Solution 2 (Direct Python Execution).
π Still Having Issues?
If you're still experiencing problems after trying the solutions above:
-
Check Claude Desktop logs:
- macOS:
~/Library/Logs/Claude/mcp-server-jenkins.log - Windows:
%APPDATA%\Claude\logs\mcp-server-jenkins.log - Linux:
~/.config/Claude/logs/mcp-server-jenkins.log
- macOS:
-
Enable verbose logging by adding
--verboseto args:"args": [ "-m", "jenkins_mcp_server", "--env-file", "/path/to/.env", "--verbose" ] -
Verify VPN is active before starting Claude Desktop:
# Test if you can reach your Jenkins server curl -I http://your-jenkins-server:8080 -
Check if other tools can reach Jenkins while on VPN:
- Try accessing Jenkins in your browser
- Try
curlfrom terminal - If both work but MCP doesn't, use Solution 2
-
Open an issue with:
- Your operating system
- Claude Desktop log file
- Output of the connection test script
- Your configuration (with credentials redacted)
Enable Debug Logging
Run with verbose flag to see detailed logs:
jenkins-mcp-server --verbose
π§ͺ Development & Testing
Run Tests
# Install test dependencies
pip install pytest pytest-asyncio
# Run tests
pytest tests/ -v
Build Package
# Install build tools
pip install build
# Build distribution
python -m build
# This creates:
# - dist/jenkins_mcp_server-1.0.0.tar.gz
# - dist/jenkins_mcp_server-1.0.0-py3-none-any.whl
Local Development
# Clone repository
git clone https://github.com/rishibhushan/jenkins_mcp_server.git
cd jenkins_mcp_server
# Install in editable mode
pip install -e .
# Make changes, then test
jenkins-mcp-server --verbose
π Project Structure
jenkins_mcp_server/
βββ bin/
β βββ jenkins-mcp.js # Simplified Node.js wrapper (v1.1.16+)
βββ src/
β βββ jenkins_mcp_server/
β βββ __init__.py # Package initialization & main()
β βββ __main__.py # Entry point for python -m
β βββ config.py # Configuration management
β βββ jenkins_client.py # Jenkins API client (with caching)
β βββ cache.py # Smart caching layer
β βββ metrics.py # Performance telemetry
β βββ server.py # MCP server implementation (26 tools)
βββ tests/ # Test suite
βββ requirements.txt # Python dependencies
βββ package.json # Node.js configuration (ES modules)
βββ README.md # This file
π Security Best Practices
- Never commit
.envfiles - Add to.gitignore - Use API tokens, not passwords - More secure and revocable
- Rotate tokens regularly - Generate new tokens periodically
- Use environment-specific configs - Separate dev/staging/prod credentials
- Review permissions - Only grant necessary Jenkins permissions
- Keep dependencies updated - Run
pip install --upgrade -r requirements.txt
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Built on the Model Context Protocol (MCP)
- Powered by python-jenkins
- Inspired by the need for AI-powered DevOps automation
π Support
- Issues: https://github.com/rishibhushan/jenkins_mcp_server/issues
- Discussions: https://github.com/rishibhushan/jenkins_mcp_server/discussions
πΊοΈ Roadmap
- Add pipeline support
- Multi-Jenkins instance management
- Build artifact management
- Advanced filtering and search
- Real-time build monitoring
- Webhook integration
- Docker container support
Made with β€οΈ by Rishi Bhushan
