This document provides the jenkins mcp server development method, how to retrieve the job list registered on the jenkins server, and actual working source code. Since jenkins mcp was released on June 18, 2025, I tried running all jenkins mcp projects uploaded to github, but confirmed that they did not work properly. After trial and error, I am releasing the jenkins mcp code that actually works.

Table of Contents
creating a working directory Create the application file that will retrieve the jenkins job list with the name client.py. Create a Python virtual .venv directory to be used in the same directory by running the command below. The python version I use is 3.13.5.
configuring python virtual environment Packages installed from now on will be installed in the virtual environment .venv using pip install
mkdir jenkins_job cd ./jenkins_job
touch client.py
python -m venv .venv
source .venv/bin/activate
Install jenkins mcp development package
To develop the server code for jenkins mcp, you must install packages that support HTTP communication and output logs. Write and save the following content in a file named requirements.txt. Running the pip command below will install the packages.
pip install -r requirements.txt
Record the following content in the .env file in the directory where the project was created.
pip install python-dotenv
vim .env
The following content should be recorded in the .env file. To enter text in the vim editor, you must press the ‘i’ key. After completing the recording, to save the file, you must press the ESC button once and then type :wq!.
If you simply exit the vim editor, the content recorded in the file will not be saved to disk.
JENKINS_URL="http://localhost:8080"
JENKINS_USERNAME="ID"
JENKINS_PASSWORD="password"
JENKINS_TOKEN="API token key issued by jenkins server"
The jenkins mcp program, as a client program, must be running with a jenkins server installed. Copy and paste the following content into the client.py file. Run vim client.py to enter the editor screen, then press the ‘i’ key to enter edit mode.
Click the right mouse button to paste the copied source code into the editor window. Press the ESC key, then press :wq! to save the source code content to the file and exit the vim editor.
import os
import ssl
import jenkins
from dotenv import load_dotenv
load_dotenv() # Load environment variables from .env file
# --- Jenkins Server Settings (Environment Variables or Direct Configuration) ---
# Strongly recommend using environment variables for security.
# Example:
# export JENKINS_URL="http://your.jenkins.server:8080"
# export JENKINS_USER="your_jenkins_username"
# export JENKINS_TOKEN="your_jenkins_api_token" # Use an API token!
JENKINS_URL = os.getenv("JENKINS_URL", "http://localhost:8080") # Set default value
JENKINS_USER = os.getenv("JENKINS_USER", "user")
JENKINS_TOKEN = os.getenv("JENKINS_TOKEN", "your_api_token_here") # Replace with actual token!
# Disable SSL certificate verification (Recommended for development/test environments only)
# In actual production environments, you should use a valid SSL certificate or enable verification correctly.
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't have _create_unverified_context
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
def get_all_jenkins_jobs():
"""
Retrieves all Job lists from Jenkins using the python-jenkins library.
"""
try:
# Create Jenkins client
# Connect directly to the Jenkins server using the python-jenkins library.
jenkins_client = jenkins.Jenkins(
JENKINS_URL,
username=JENKINS_USER,
password=JENKINS_TOKEN # Use API token as password
)
print(f"Connecting to Jenkins server: {JENKINS_URL} (User: {JENKINS_USER})...")
# Call get_jobs() method
# This method retrieves all Job lists from the Jenkins server.
jobs = jenkins_client.get_jobs()
if jobs:
print("\n--- Jenkins Job List (via python-jenkins client) ---")
for job in jobs:
# Print Job name using the 'name' key.
if isinstance(job, dict) and 'name' in job:
print(f"- {job['name']}")
else:
print(f"- Job information format error or unexpected data: {job}")
print("---------------------------------------")
else:
print("No Jobs exist on the Jenkins server or cannot be retrieved.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please check if the Jenkins URL, username, and API token (or password) are correct, or")
print("confirm that the Jenkins server is running and accessible.")
if __name__ == "__main__":
get_all_jenkins_jobs()
jenkins mcp git to get code
You can download the example code that I developed and successfully tested by running the git command below.
git clone https://github.com/big0001data/jenkins_mcp.git
Jenkins mcp server 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_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
Jenkins MCP Server Implementation
The functionality that operates as mcp_server is implemented in sysinfo.py. When mcp_client and mcp_server are linked, the path to the python code that functions as the mcp_server is specified in the config.json file.
As the simplest example, the MCP_SERVER reads the CPU platform information (version, release number, etc.) and GPU information and transmits it to the mcp_client.
import platform
import psutil
import GPUtil
import asyncio
async def get_system_info():
output = []
system_info = platform.uname()
output.append("System Information:")
cpu_info = platform.processor()
cpu_count = psutil.cpu_count(logical=False)
logical_cpu_count = psutil.cpu_count(logical=True)
output.append("\nCPU Information:")
memory_info = psutil.virtual_memory()
output.append("\nMemory Information:")
disk_info = psutil.disk_usage('/')
output.append("\nDisk Information:")
output.append(f"Total Disk Space: {disk_info.total} bytes")
return "\n".join(output)
if __name__ == "__main__":
res = asyncio.run(get_system_info())
print(res)
connecting jenkins api and chat natural language input
Attaching the @mcp.tool() decorator to the front of the get_sysinfo() function is used to connect the natural language input via chat with the jenkins api function on the mcp server.
from typing import Any
from mcp.server.fastmcp import FastMCP
from fetch_info import get_system_info
# Initialize FastMCP server
mcp = FastMCP("sysinfo")
@mcp.tool()
async def get_sysinfo() -> str:
"""Get the current system information.
Gives system information such as System, Node name, Release, Version, Machine, Processor
CPU Information such as Processor, Physical Cores, Logical Cores
Memory Information such as Total Memory, Available Memory, Used Memory, Memory Utilization
Disk Information such as Total Disk Space, Used Disk Space, Free Disk Space, Disk Space Utilization
"""
data = await get_system_info()
return data
if __name__ == "__main__":
# Initialize and run the server
mcp.run(transport='stdio')
implementing jenkins mcp client
The jenkins mcp client functionality implements the part that receives natural language input through chat and the part that calls the jenkins api function after interpreting the natural language.
Using jenkins mcp, the function to retrieve the job list from the jenkins server running at http://localhost:8080 is implemented as follows, and the @mcp.tool() decorator is added so that it can be called from the chat client app.
adding jenkins mcp server functionality to read jenkins job list If you add an English comment before the function name, the OPENAI language model or OLLAMA language model in the chat client app will understand this function and call it. Inside each function, the official jenkins_api provided by the jenkins company is called.
# The job list request uses the GET method.
# No request body or Content-Type header is required.
@mcp.tool( )
def get_jenkins_job_list():
# Send GET request
try:
print("Fetching Jenkins job list...")
response = requests.get( # Use GET instead of POST.
api_url,
auth=(username, api_token),
# requests library follows redirects by default.
# verify=False skips SSL certificate verification (not needed for HTTP).
)
# Check response status code
if response.status_code == 200:
print("Successfully fetched Jenkins job list.")
# Parse JSON response
jobs_data = response.json()
# Check for "jobs" key in response and print job list
if "jobs" in jobs_data:
print("\n--- Jenkins Job List ---")
if jobs_data["jobs"]:
for job in jobs_data["jobs"]:
# Print only the job_list provided as "name".
print(f"- {job['name']}")
else:
print("No jobs found in Jenkins.")
else:
print("Could not find 'jobs' key in response. Check Jenkins API response format.")
print(f"Full response: {jobs_data}")
else:
print(f"Error fetching job list: {response.status_code} - {response.text}")
print("Jenkins response details:")
print(response.text)
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
How to create a job on jenkins mcp server
If you send the job_config.xml file to jenkins server running on http://localhost:8080, a new job will be created in the jenkins server’s job list. job_config.xml can be written in the following form.
<?xml version='1.1' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>{shell_command}</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
In the above code, you can add tasks to be executed on the jenkins server as a shell script in the {shell_command} part. You can send the content directly as a message to the jenkins server from within the python code without creating a job_config.xml file.
running jenkins mcp job When jenkins mcp requests to build a selected job from the jenkins server’s job list, the result of the job execution is sent to jenkins_mcp_server. If the job execution is successful on the jenkins server, a success message is output on jenkins_mcp_server.
@mcp.tool()
def jenkins_server_build_job(job_name: str) -> str:
"""
Triggers a build for the specified Jenkins job.
Args:
job_name (str): The name of the Jenkins job to build.
Returns:
str: Success or error message.
"""
api_url = f"{jenkins_url}/job/{job_name}/build"
try:
response = requests.post(
api_url,
auth=(username, api_token),
timeout=10
)
if response.status_code in [200, 201, 302]:
msg = f"Job '{job_name}' build triggered successfully."
if response.status_code == 302 and 'Location' in response.headers:
msg += f" Redirected to: {response.headers['Location']}"
return msg
else:
return f"Error triggering build for job '{job_name}': {response.status_code} - {response.text}"
except requests.exceptions.RequestException as e:
return f"Request failed: {e}"
except Exception as e:
return f"Unexpected error: {e}"
How to connect chatting jenkins mcp client app and jenkins mcp server The core of developing a jenkins mcp server directly was connecting the chat app code (e.g., mcp_client.py) and the jenkins server code (e.g., jenkins_mcp_server.py).
This involves adding the “jenkins_mcp” name and the actual path to the code that operates as the jenkins mcp server and the executable jenkins_mcp_server.py to mcp_config.json located in the mcp_client directory.
The language model (OPENAI or OLLAMA) running in mcp_client/main.py recognizes the mcp_config.json file, parses jenkins_mcp_server.py, and recognizes the @mcp.tool() decorator placed directly before the function.
The language model interprets the comments before and after @mcp.tool() to determine the role of the function.
If the language model determines that the natural language request entered by the user through the chat window is a service that can be provided using the jenkins api, it calls the jenkins api corresponding to the most similar comment among the functions marked with @mcp.tool().
A specific function within jenkins_mcp_server.py is called, and a request is sent in a requests frame format to the real jenkins server’s endpoint, http://localhost:8080, to create a job, delete a job, or provide a job list.
The jenkins server endpoint responds to the jenkins_mcp_server.py that made the request, and the language model then interprets that content, converts it into human-readable natural language, and provides it as an answer in the chat window.
Helpful articles for jenkins mcp server development
It is convenient to use various mcp server modules from smithery. However, if developers cannot develop mcp server services themselves and cannot learn how to monetize them directly, they will be at risk of survival in an era where automatic code generation services like gemini_cli are provided for free.
Learn more about atlassian mcp installation and usage
I have explained in detail how to install atlassian mcp using claude, create and delete jira web pages, and create, update, and delete collab pages by entering natural language in the chat window, so please read it once.
Conclusion
We have learned in detail how to directly implement the functionality of the jenkins mcp server. The jenkins mcp server interprets messages received through natural language chat input from the jenkins mcp client and calls the jenkins api.
It can create and delete jobs by transmitting request messages to the Jenkins Server through the jenkins api.
In the next post, we will cover in detail how to develop code that allows the jenkins mcp server code to execute pipelines on the Jenkins endpoint server.