Jenkins AI Optimizer
Provides tools for interacting with Jenkins CI/CD, including intelligent failure diagnostics, multi-instance management, semantic log search, and pipeline analysis.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Jenkins AI OptimizerWhy did the 'backend' job fail?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Jenkins AI Optimizer
Enterprise-grade Model Context Protocol (MCP) server for Jenkins CI/CD integration β Empowering AI assistants with deep Jenkins insights, intelligent build diagnostics, and semantic log analysis.
Transform how you interact with Jenkins through AI. This production-ready MCP server enables AI assistants like Claude to understand your Jenkins environment, diagnose build failures, analyze complex pipelines, and search massive logsβall through natural conversation.
π Quick Install
pip install jenkins-ai-optimizerSee Quick Start for complete setup instructions.
Table of Contents
Overview
Jenkins AI Optimizer is a sophisticated MCP (Model Context Protocol) server that bridges AI assistants with Jenkins CI/CD infrastructure. Unlike simple API wrappers, this server provides:
Intelligent failure diagnosis using configurable error pattern recognition
Multi-instance Jenkins management with automatic credential resolution
Semantic log search powered by vector embeddings (Qdrant)
Deep pipeline analysis including complex sub-build tree traversal
Enterprise-grade caching with compression and intelligent cleanup
Real-time streaming capabilities for large log processing
What is MCP?
Model Context Protocol is an open standard that enables AI assistants to securely connect to external tools and data sources. This server implements MCP to expose Jenkins functionality to AI assistants, allowing them to interact with your CI/CD infrastructure intelligently.
Why Jenkins AI Optimizer?
Traditional Approach:
Developer β Jenkins UI β Browse jobs β Find failed build β
Download logs β Search manually β Google errors β Debug
β±οΈ Time: 30-60 minutes per failureWith Jenkins AI Optimizer:
Developer β Ask AI: "Why did my build fail?" β
AI analyzes automatically β Get actionable diagnosis
β±οΈ Time: 10-30 secondsKey Features
π Intelligent Diagnostics
AI-Powered Failure Analysis: Automatically categorizes build failures using configurable regex patterns
Error Pattern Recognition: Pre-configured patterns for compilation, timeout, permission, and dependency errors
Contextual Recommendations: Provides actionable suggestions based on failure type
Data Extraction: Automatically extracts error codes, version numbers, file paths, and timestamps
π’ Multi-Jenkins Management
Centralized Configuration: Manage multiple Jenkins instances from a single config file
Automatic Credential Resolution: Routes requests to the correct Jenkins instance based on job URLs
Instance Health Monitoring: Tracks availability and performance of each Jenkins server
Flexible Authentication: Supports individual API tokens and SSL verification per instance
π§ Vector-Powered Search
Semantic Log Search: Find relevant log sections using natural language queries
Qdrant Integration: High-performance vector database for embedding storage
Chunk-Based Indexing: Efficiently processes and searches logs of any size
Configurable Embedding Models: Defaults to
all-MiniLM-L6-v2with options for customization
π Performance & Scalability
Streaming Log Processing: Handles multi-gigabyte logs without memory issues
Smart Caching: Compresses and stores frequently accessed logs locally
Parallel Build Analysis: Process multiple pipeline branches concurrently
Automatic Cleanup: Scheduled maintenance of cache and vector store
Connection Pooling: Efficient HTTP session management with retry logic
π οΈ Developer Experience
FastMCP Framework: Built on modern async Python with FastAPI
Comprehensive Tool Set: 10+ specialized tools for different Jenkins operations
Dependency Injection: Clean architecture with testable components
Health Endpoints: Built-in monitoring for Docker deployments
Extensive Logging: Configurable logging levels with structured output
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Assistant (Claude) β
β Natural Language Interface β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β MCP Protocol (SSE/stdio)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Jenkins MCP Enterprise Server β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
β β Tool Factory β β DI Container β β Multi-Jenkins Mgr β β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Tool Registry (10+ Tools) β β
β β β’ Diagnostics β’ Logs β’ Search β’ Subbuilds β β
β β β’ Trigger β’ Parameters β’ Ripgrep β’ Navigation β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
β β Cache Mgr β β Vector Mgr β β Cleanup Scheduler β β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββ ββββββββββββββββββββββββββ
β Jenkins Instances β β Qdrant Vector DB β
β β’ Production β β β’ Semantic Search β
β β’ Staging β β β’ Log Embeddings β
β β’ Development β β β’ 6333 (HTTP/REST) β
β β’ API: REST/JSON β β β’ 6334 (gRPC) β
ββββββββββββββββββββββββ ββββββββββββββββββββββββββComponent Breakdown:
FastMCP Server: HTTP/SSE and stdio transport support
Tool Factory: Dynamic tool instantiation with dependency injection
DI Container: Manages lifecycle of Jenkins clients, caches, and managers
Multi-Jenkins Manager: Routes requests to appropriate Jenkins instance
Cache Manager: Local filesystem cache with LRU eviction and compression
Vector Manager: Qdrant client for semantic search operations
Cleanup Scheduler: APScheduler-based maintenance tasks
Quick Start
Prerequisites
Python 3.10+ (for local development)
Docker & Docker Compose (for production deployment)
Jenkins instance(s) with REST API access
Jenkins API Token(s) - How to generate β
Docker Deployment (Recommended)
1. Clone the repository:
git clone https://github.com/karadHub/jenkins-ai-optimizer.git
cd jenkins-ai-optimizer2. Configure Jenkins instances:
# Copy example configuration
cp config/mcp-config.example.yml config/mcp-config.yml
# Edit with your Jenkins credentials
# Windows: notepad config/mcp-config.yml
# Linux/Mac: nano config/mcp-config.ymlExample configuration:
jenkins_instances:
production:
url: "https://jenkins.company.com"
username: "your.email@company.com"
token: "11a1b2c3d4e5f6789012345678901234" # From Jenkins: User β Configure β API Token
display_name: "Production Jenkins"
timeout: 30
verify_ssl: true
max_log_size: 100000000 # 100MB
staging:
url: "https://jenkins-staging.company.com"
username: "your.email@company.com"
token: "another-api-token-here"
display_name: "Staging Environment"
timeout: 30
verify_ssl: true
default_instance:
id: "production"
vector:
disable_vector_search: false
host: "http://qdrant:6333"
collection_name: "jenkins-logs"
embedding_model: "all-MiniLM-L6-v2"3. Start the services:
# Linux/Mac
./start-jenkins.sh
# Windows (PowerShell)
docker-compose up -d4. Verify deployment:
# Check service health
curl http://localhost:3008/health
# Expected: OK
# Check Qdrant
curl http://localhost:6333/health
# Expected: {"title":"qdrant - vector search engine","version":"..."}
# View logs
docker-compose logs -f jenkins_mcp_enterprise-serverAccess Points:
MCP Server:
http://localhost:3008MCP SSE Endpoint:
http://localhost:3008/sseHealth Check:
http://localhost:3008/healthQdrant Dashboard:
http://localhost:6333/dashboardQdrant API:
http://localhost:6333
Local Development Setup
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in editable mode with dev tools
pip install -e .[dev]
# Configure (same as Docker setup)
cp config/mcp-config.example.yml config/mcp-config.yml
# Edit config/mcp-config.yml with your Jenkins details
# Start Qdrant separately (optional, for vector search)
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant:latest
# Run the server
python -m jenkins_mcp_enterprise.server --transport stdio --config config/mcp-config.yml
# Or with HTTP transport
python -m jenkins_mcp_enterprise.server --transport http --config config/mcp-config.ymlConfiguration
Configuration Files
File | Purpose | Required |
| Main configuration (Jenkins instances, vector search, cache) | β Yes |
| Error patterns for failure analysis | β Yes (bundled) |
| Docker service orchestration | For Docker deployment |
| Python package metadata and dependencies | For development |
Environment Variables
Variable | Default | Description |
|
| Qdrant vector database URL |
|
| Local cache directory path |
|
| Logging verbosity (DEBUG, INFO, WARNING, ERROR) |
|
| HTTP server bind address (Docker mode) |
|
| HTTP server port (mapped to 3008 in Docker) |
|
| Disable Qdrant integration if true |
Multi-Instance Configuration
Configure multiple Jenkins servers for centralized management:
jenkins_instances:
prod-main:
url: "https://jenkins-prod.company.com"
username: "ci-bot@company.com"
token: "prod-token-here"
display_name: "Production Main"
description: "Primary production Jenkins"
timeout: 30
verify_ssl: true
max_log_size: 104857600 # 100MB
default_timeout: 120
prod-backup:
url: "https://jenkins-prod-dr.company.com"
username: "ci-bot@company.com"
token: "prod-backup-token"
display_name: "Production DR"
timeout: 30
verify_ssl: true
staging:
url: "https://jenkins-staging.company.com"
username: "dev-bot@company.com"
token: "staging-token"
display_name: "Staging"
timeout: 20
verify_ssl: false # Self-signed cert
settings:
fallback_instance: "prod-main"
enable_health_checks: true
health_check_interval: 300 # 5 minutesDiagnostic Patterns
Customize error detection in jenkins_mcp_enterprise/diagnostic_config/diagnostic-parameters.yml:
error_patterns:
compilation:
- pattern: "error: .* undeclared"
severity: high
category: "Compilation Error"
guidance: "Check for missing imports or variable declarations"
timeout:
- pattern: "timeout|timed out|took too long"
severity: medium
category: "Timeout"
guidance: "Increase timeout values or investigate performance bottlenecks"
permission:
- pattern: "permission denied|access denied|403 Forbidden"
severity: high
category: "Permission Error"
guidance: "Verify service account permissions and file access rights"See config/README-diagnostic-config.md for complete documentation.
Available Tools
The MCP server exposes the following tools to AI assistants:
Core Jenkins Operations
Tool | Description | Key Parameters |
| Analyzes build failures using AI pattern matching |
|
| Retrieves comprehensive build metadata |
|
| Lists configurable parameters for a job |
|
| Initiates a new build with optional parameters |
|
| Starts build and monitors completion |
|
Log Analysis
Tool | Description | Key Parameters |
| Fetches log sections with line number ranges |
|
| Extracts error lines using pattern matching |
|
| Fast regex search across logs |
|
| Interactive log navigation with sections |
|
Advanced Features
Tool | Description | Key Parameters |
| Vector-based semantic log search |
|
| Traverses complex pipeline hierarchies |
|
Example Tool Usage (via AI Assistant)
User: "Why did the Deploy-Production job build #47 fail?"
AI Assistant calls:
diagnose_build_failure(
job_name="Deploy-Production",
build_number=47,
instance_id="production" # Auto-resolved if only one instance
)AI receives structured response:
{
"build_info": {
"job_name": "Deploy-Production",
"build_number": 47,
"status": "FAILURE",
"duration_ms": 342500
},
"failure_analysis": {
"category": "Timeout",
"severity": "medium",
"matched_patterns": ["Connection timeout after 300 seconds"],
"guidance": "Increase timeout values or investigate network connectivity",
"extracted_data": {
"timeout_value": "300",
"service": "database-prod.company.internal"
}
},
"recommendations": [
"Check database server health and response times",
"Verify network connectivity to database-prod.company.internal",
"Consider increasing connection timeout in deployment configuration"
]
}Usage Examples
With Claude Desktop
1. Configure Claude Desktop:
Edit %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (Mac):
{
"mcpServers": {
"jenkins-optimizer": {
"url": "http://localhost:3008/sse"
}
}
}2. Restart Claude Desktop
3. Start conversations:
User: "List all my Jenkins jobs"
Claude: [Uses MCP to fetch and format job list]
User: "Why did Windows_Health_Check build #2 fail?"
Claude: [Calls diagnose_build_failure, analyzes logs, provides detailed diagnosis]
User: "Find all timeout errors in recent builds"
Claude: [Uses semantic_search to find relevant failures]
User: "Show me the sub-build tree for Main-Pipeline #15"
Claude: [Traverses pipeline hierarchy and displays tree structure]
Direct API Usage
import requests
# Health check
response = requests.get("http://localhost:3008/health")
print(response.text) # "OK"
# Call tools via MCP protocol (requires MCP client library)
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def diagnose_build():
server_params = StdioServerParameters(
command="python",
args=["-m", "jenkins_mcp_enterprise.server", "--transport", "stdio"]
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool(
"diagnose_build_failure",
arguments={
"job_name": "Deploy-Production",
"build_number": 47
}
)
print(result)Advanced Features
Semantic Log Search
Vector-powered search allows natural language queries:
# Enable in config/mcp-config.yml
vector:
disable_vector_search: false
host: "http://qdrant:6333"
collection_name: "jenkins-logs"
embedding_model: "all-MiniLM-L6-v2"
chunk_size: 50 # Lines per chunk
chunk_overlap: 5
top_k_default: 5Usage through AI:
"Find connection timeout errors"
"Show me database migration failures"
"What builds had out of memory issues?"
Custom Diagnostic Patterns
Add organization-specific error patterns:
# In diagnostic-parameters.yml
error_patterns:
custom_service:
- pattern: 'ServiceX: ERROR \[(?P<code>\d+)\]'
severity: high
category: "ServiceX Failure"
guidance: "Check ServiceX documentation for error code {code}"
extract_fields:
- error_code: '\[(\d+)\]'
- service_name: "(ServiceX)"Pipeline Sub-Build Analysis
Automatically discovers and maps complex pipeline structures:
# Through AI assistant
"Analyze the complete build tree for Main-Pipeline build #150,
including all sub-builds and their status"
# Returns hierarchical tree with:
# - Build status at each level
# - Failure points highlighted
# - Build durations
# - Artifact locationsIntelligent Caching
Automatic caching with compression:
cache:
cache_dir: "/tmp/mcp-jenkins"
max_size_mb: 1000 # 1GB total cache
retention_days: 7
compression: true # gzip compression for logsCache Benefits:
10x faster repeated log access
Reduced Jenkins server load
Offline analysis capability
Scheduled Cleanup
Automatic maintenance runs daily:
cleanup:
interval_hours: 24
retention_days: 7
max_concurrent: 5 # Parallel cleanup tasksDocumentation
Document | Description |
Detailed setup guide with examples | |
Architecture, development workflow, and contribution guidelines | |
Configuration file reference | |
Diagnostic pattern documentation | |
Docker deployment details | |
Operational monitoring guide |
Contributing
We welcome contributions! Please see our Code of Conduct and PROJECT.md for development workflow and coding standards.
Development Setup
# Clone and setup
git clone https://github.com/karadHub/jenkins-ai-optimizer.git
cd jenkins-ai-optimizer
# Create environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install with dev dependencies
pip install -e .[dev]
# Run tests
pytest
# Run linting
ruff check .
# Format code
ruff format .Pull Request Process
Fork the repository
Create a feature branch:
git checkout -b feature/your-featureMake changes with tests
Ensure all tests pass:
pytestLint your code:
ruff check .Commit with conventional commits:
feat(diagnostics): add new error patternPush and create Pull Request
Troubleshooting
Server Won't Start
# Check Docker containers
docker-compose ps
# View server logs
docker-compose logs jenkins_mcp_enterprise-server
# Common issues:
# 1. Port 3008 in use β Change in docker-compose.yml
# 2. Config file missing β Copy from config/mcp-config.example.yml
# 3. Invalid Jenkins credentials β Verify token in JenkinsVector Search Not Working
# Check Qdrant health
curl http://localhost:6333/health
# Verify Qdrant container
docker-compose logs qdrant
# Check configuration
# Ensure DISABLE_VECTOR_SEARCH=false in docker-compose.yml
# Verify QDRANT_HOST=http://qdrant:6333Connection to Jenkins Fails
# Test Jenkins API manually
curl -u "username:token" https://your-jenkins.com/api/json
# Common issues:
# 1. Incorrect URL β Verify in config/mcp-config.yml
# 2. Invalid token β Regenerate in Jenkins β User β Configure β API Token
# 3. SSL certificate issues β Set verify_ssl: false (staging only!)
# 4. Firewall blocking β Check network connectivityAI Assistant Not Connecting
Claude Desktop:
# Check server health
curl http://localhost:3008/health
# Verify Claude config file location:
# Windows: %APPDATA%\Claude\claude_desktop_config.json
# Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
# Check Claude Desktop logs
# Windows: %APPDATA%\Claude\logs\
# Mac: ~/Library/Logs/Claude/
# Ensure MCP server URL is correct: http://localhost:3008/ssePerformance Issues
# Monitor resource usage
docker stats jenkins_mcp_enterprise-server-1
# Check cache size
du -sh /tmp/mcp-jenkins # Linux/Mac
# Windows: Check Docker volume size
# Optimize:
# 1. Reduce cache retention: retention_days: 3
# 2. Lower max_log_size: max_log_size: 50000000 (50MB)
# 3. Disable vector search if unused: disable_vector_search: trueLicense
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Key Points:
β Free to use, modify, and distribute
β Must disclose source code when distributing
β Must use same GPL-3.0 license for derivatives
β No warranty provided
Acknowledgments
FastMCP - Modern MCP server framework
Qdrant - High-performance vector database
Anthropic - Model Context Protocol specification and Claude AI
Jenkins Community - Robust CI/CD platform
Special Thanks
This project was developed with assistance from Claude AI (Anthropic), demonstrating the power of AI-assisted development in creating production-ready tools.
Contributing
We welcome contributions! Here's how you can help:
Ways to Contribute
π Report bugs via GitHub Issues
π‘ Suggest features or improvements
π Improve documentation
π§ Submit pull requests with bug fixes or features
β Star the repository to show your support
π£ Share with others who might find it useful
Development Process
Fork the repository
Create a feature branch:
git checkout -b feature/your-featureMake your changes with tests
Ensure all tests pass:
pytestLint your code:
ruff check .Format code:
ruff format .Commit with conventional commits:
feat(diagnostics): add new error patternPush and create a Pull Request
See PROJECT.md for detailed development guidelines and CODE_OF_CONDUCT.md for community standards.
Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Code of Conduct: CODE_OF_CONDUCT.md
Documentation: See Documentation section above for detailed guides
Built with β€οΈ for DevOps engineers who deserve better debugging tools.
Stop spending hours hunting through Jenkins logs. Let AI do the heavy lifting.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/karadHub/jenkins-ai-optimizer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server