Labsco
ddang-jung logo

Jenkins MCP Server

β˜… 1

from ddang-jung

An MCP server for automating tasks and managing jobs on a Jenkins server.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup

Jenkins MCP Server

A Model Context Protocol (MCP) server that enables Claude to interact with Jenkins through various automation tools. This server provides comprehensive Jenkins management capabilities including job monitoring, build control, and queue management.

Features

  • Job Management: List jobs, get job configurations, and monitor job status
  • Build Control: Trigger builds with parameters, stop running builds, and check build status
  • Build History: Retrieve build history and detailed build information
  • Console Logs: Access build console output for debugging
  • Queue Management: Monitor Jenkins build queue and stuck builds
  • Folder Support: Navigate Jenkins folders and organizational structures

Available Tools

1. get_build_status

Get the status of a specific Jenkins build.

Parameters:

  • jobPath (required): Path to the Jenkins job (e.g., "job/MyProject/job/main")
  • buildNumber (optional): Build number or "lastBuild" for most recent

Example:

{
  "jobPath": "job/MyProject",
  "buildNumber": "lastBuild"
}

2. trigger_build

Trigger a new Jenkins build with optional parameters.

Parameters:

  • jobPath (required): Path to the Jenkins job
  • parameters (optional): Build parameters as key-value pairs

Example:

{
  "jobPath": "job/MyProject",
  "parameters": {
    "BRANCH": "main",
    "DEPLOY_ENV": "staging"
  }
}

3. get_build_log

Retrieve the console output of a specific build.

Parameters:

  • jobPath (required): Path to the Jenkins job
  • buildNumber (required): Build number or "lastBuild"

4. list_jobs

List all Jenkins jobs in a folder or at root level.

Parameters:

  • folderPath (optional): Path to folder (e.g., "job/MyFolder") or empty for root

5. get_build_history

Get build history for a specific Jenkins job.

Parameters:

  • jobPath (required): Path to the Jenkins job
  • limit (optional): Number of recent builds to retrieve (default: 10)

6. stop_build

Stop a running Jenkins build.

Parameters:

  • jobPath (required): Path to the Jenkins job
  • buildNumber (required): Build number or "lastBuild"

7. get_queue

Get the current Jenkins build queue status.

Parameters: None

8. get_job_config

Get the configuration details of a Jenkins job.

Parameters:

  • jobPath (required): Path to the Jenkins job

Job Path Format

Jenkins job paths follow this format:

  • Root level job: job/JobName
  • Folder job: job/FolderName/job/JobName
  • Multi-level: job/Folder1/job/Folder2/job/JobName

Error Handling

The server provides comprehensive error handling:

  • Authentication errors: Check your Jenkins credentials
  • Job not found: Verify the job path format
  • Permission errors: Ensure your Jenkins user has appropriate permissions
  • Network errors: Check Jenkins server connectivity

Development

Project Structure

jenkins-mcp-server/
β”œβ”€β”€ src/
β”‚   └── index.ts          # Main server implementation
β”œβ”€β”€ build/                # Compiled JavaScript output
β”œβ”€β”€ package.json          # Project configuration
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
β”œβ”€β”€ .gitignore           # Git ignore rules
└── README.md            # This file

Scripts

  • npm run build: Compile TypeScript to JavaScript
  • npm run watch: Watch for changes and rebuild
  • npm run inspector: Start MCP Inspector for debugging
  • npm run prepare: Prepare build (runs automatically)
  • npm run clean: Clean build artifacts and dependencies (macOS/Linux)
  • npm run clean:win: Clean build artifacts and dependencies (Windows)

Cleaning Project

To reset the project to its initial state (remove build artifacts and dependencies):

macOS/Linux:

npm run clean
# or manually:
rm -rf node_modules build package-lock.json

Windows:

npm run clean:win
# or manually:
rmdir /s /q node_modules & rmdir /s /q build & del package-lock.json