Provides comprehensive tools for managing Jenkins builds, jobs, artifacts, and queue operations, including triggering builds, retrieving job information, monitoring system health, and handling build artifacts.
Jenkins MCP Server
A comprehensive Jenkins Model Context Protocol (MCP) server that provides tools for managing Jenkins builds, jobs, artifacts, and queue operations through the MCP interface.
📋 Table of Contents
- Features
- Architecture
- Installation
- Configuration
- Available Tools
- Usage Examples
- Development
- Contributing
- License
🚀 Features
- Build Management: Trigger, stop, schedule, and update Jenkins builds
- Job Information: Retrieve comprehensive job and build information
- System Monitoring: Get Jenkins instance status and health information
- Artifact Management: List and read build artifacts
- Queue Operations: Manage and monitor build queues
- CSRF Protection: Automatic handling of Jenkins CSRF tokens
- Authentication: Support for Jenkins API tokens and basic auth
🏗️ Architecture
The codebase is organized into a modular, scalable structure:
📦 Installation
- Clone the repository:
- Install dependencies:
- Configure environment variables (see Configuration)
- Start the server:Or for development with auto-restart:
⚙️ Configuration
Configure the server using environment variables:
Getting a Jenkins API Token
- Log into your Jenkins instance
- Click on your username (top right) → Configure
- Under "API Token", click "Add new Token"
- Give it a name and click "Generate"
- Copy the generated token and use it as
JENKINS_API_TOKEN
MCP Client Configuration
This Jenkins MCP Server can be integrated with various MCP clients. Here's how to configure it with popular clients:
🤖 GitHub Copilot (VS Code)
- Install the MCP extension in VS Code
- Add to your mcp.json:
🧠 Claude Desktop
- Edit Claude's config file (
~/.config/claude-desktop/claude_desktop_config.json
):
⚡ EliteA MCP Client
- Add to EliteA configuration(config.json):
Important Notes:
- Replace
path/to/jenkins-mcp/src/index.js
with the actual absolute path to your installation - Ensure Node.js is in your system PATH
- The server communicates via stdin/stdout following the MCP protocol
- All Jenkins tools will be available once configured
🛠️ Available Tools
Build Management
triggerBuild
Trigger a build for a Jenkins job.
- jobFullName (string, required): Full path of the Jenkins job
- parameters (object, optional): Build parameters
stopBuild
Stop or kill a running Jenkins build.
- jobFullName (string, required): Full path of the Jenkins job
- buildNumber (integer, optional): Build number to stop (defaults to last build)
scheduleBuild
Schedule a Jenkins build to run at a specific time.
- jobFullName (string, required): Full path of the Jenkins job
- scheduleTime (string, required): Time to schedule (e.g., '22:15', '10:30 PM')
- parameters (object, optional): Build parameters
updateBuild
Update build display name and/or description.
- jobFullName (string, required): Full path of the Jenkins job
- buildNumber (integer, optional): Build number (defaults to last build)
- displayName (string, optional): New display name
- description (string, optional): New description
Job Information
getJob
Get information about a Jenkins job.
- jobFullName (string, required): Full path of the Jenkins job
getBuild
Get information about a specific build or the last build.
- jobFullName (string, required): Full path of the Jenkins job
- buildNumber (integer, optional): Build number (defaults to last build)
getJobs
Get a paginated list of Jenkins jobs.
- parentFullName (string, optional): Full path of the parent folder
- skip (integer, optional): Number of items to skip (default: 0)
- limit (integer, optional): Maximum items to return (default: 10, max: 10)
System Information
whoAmI
Get information about the current authenticated user.
getStatus
Get Jenkins instance status and health information.
Artifact Management
listBuildArtifacts
List all artifacts from a specific build or the last build.
- jobFullName (string, required): Full path of the Jenkins job
- buildNumber (integer, optional): Build number (defaults to last build)
readBuildArtifact
Read the content of a specific build artifact.
- jobFullName (string, required): Full path of the Jenkins job
- artifactPath (string, required): Relative path to the artifact
- buildNumber (integer, optional): Build number (defaults to last build)
- format (string, optional): Format for binary files ('text' or 'base64')
Queue Management
cancelQueuedBuild
Cancel a pending/queued Jenkins build that hasn't started yet.
- jobFullName (string, required): Full path of the Jenkins job
- queueId (integer, optional): Specific queue item ID to cancel
getQueueInfo
Get information about queued builds.
- jobFullName (string, optional): Full path of the Jenkins job (returns all if not provided)
💡 Usage Examples
Triggering a Build
Getting Build Information
Reading an Artifact
Scheduling a Build
🔧 Development
Adding New Tools
- Create the tool function in the appropriate file under
src/tools/
- Add the tool definition to
src/tools/index.js
in thetoolRegistry
- Update the README with the new tool documentation
Example tool structure:
Project Structure Explained
src/client/
: HTTP client for Jenkins API communicationsrc/server/
: MCP server implementation and request handlingsrc/tools/
: Individual tool implementations organized by functionalitysrc/config/
: Configuration management and environment variablessrc/utils/
: Shared utility functions
Code Style
- Use ES6+ features and async/await
- Follow consistent error handling patterns
- Include JSDoc comments for functions
- Use descriptive variable and function names
- Maintain modular structure for scalability
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Troubleshooting
Common Issues
Authentication Errors
- Ensure
JENKINS_API_TOKEN
is correctly set - Verify the token has appropriate permissions
- Check if the Jenkins user has access to the jobs
CSRF Token Issues
- The server automatically handles CSRF tokens
- Ensure Jenkins CSRF protection is enabled
- For older Jenkins versions, you may need to disable CSRF protection
Connection Issues
- Verify
JENKINS_URL
is accessible - Check firewall settings
- Ensure Jenkins is running and responding
Tool Execution Errors
- Check job names and paths are correct
- Verify build numbers exist
- Ensure proper permissions for the requested operations
For more specific issues, enable debug logging by setting:
Made with ❤️ by Utkarsh Mishra
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables comprehensive Jenkins automation through MCP interface, allowing users to manage builds, jobs, artifacts, and queues with natural language commands. Supports build triggering, monitoring, artifact retrieval, and system status checks with automatic CSRF protection and authentication.