jankins
Provides tools for interacting with Jenkins, allowing AI agents to manage jobs, builds, logs, and perform failure triage.
Click on "Deploy 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., "@jankins get the last build log for my-pipeline"
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.
jankins
Token-optimized Jenkins MCP server with smart log handling and failure triage
jankins provides MCP-compliant access to Jenkins with features designed for AI coding assistants:
🎯 Token-aware formatting: Summary/full/diff output modes minimize context usage
📊 Smart log truncation: Progressive retrieval with byte offsets, regex filtering, and ANSI cleanup
🔍 Failure triage: Automated root cause analysis with hypotheses and next steps
⚡ Efficient by default: Returns compact summaries unless full detail is requested
🛡️ Better error handling: Structured errors with remediation hints and correlation IDs
📝 Built-in prompts: Pre-built workflows for common CI/CD tasks
Quick Start
Installation
pip install -e .Basic Usage
# Set environment variables
export JENKINS_URL=https://jenkins.example.com
export JENKINS_USER=myuser
export JENKINS_API_TOKEN=11234567890abcdef1234567890abcdef
# Start the server
jankins
# Or use CLI flags
jankins --jenkins-url https://jenkins.example.com \
--jenkins-user myuser \
--jenkins-token $TOKEN \
--bind 0.0.0.0:8080Generate Jenkins API Token
Log in to Jenkins
Click your username (top right) → Configure
Scroll to "API Token" section
Click "Add new Token"
Give it a name and click "Generate"
Copy the token (you won't see it again!)
Related MCP server: Jenkins AI Optimizer
Configuration
Configuration via environment variables or CLI flags. CLI flags take precedence.
CLI Flag | Env Variable | Default | Description |
|
| required | Jenkins server URL |
|
| required | Jenkins username |
|
| required | Jenkins API token |
|
|
| MCP transport ( |
|
|
| Server bind address (http/sse only) |
|
|
| Enforce Origin header validation |
|
|
| Expected Origin value |
|
|
| Log level (DEBUG/INFO/WARNING/ERROR) |
|
|
| Use JSON structured logging |
|
|
| Log Jenkins HTTP requests |
|
|
| Default max log lines |
|
|
| Default max log bytes (256KB) |
|
|
| Jenkins request timeout (seconds) |
MCP Tools
jankins provides 25+ MCP tools organized by category:
Jobs
list_jobs: List jobs with prefix filtering and paginationget_job: Get detailed job informationtrigger_build: Trigger a new build with parametersenable_job/disable_job: Enable or disable a job
Builds
get_build: Get build information (supportsnumberor"last")get_build_changes: Get SCM changes/commits for a buildget_build_artifacts: List build artifacts
Logs
get_build_log: Get logs with smart truncation and filteringSupports:
filter_regex,redact,startbyte offset,max_bytesReturns summary by default with error counts and failing stages
search_log: Search logs for pattern with context window
SCM & Pipeline
get_job_scm: Get job SCM configurationget_build_scm: Get SCM info (commit, branch) for a build
Health & System
whoami: Get current user info and permissionsget_status: Jenkins version and queue depthsummarize_queue: Compact build queue summary
Advanced Analysis
triage_failure: Analyze failed builds with:Root cause hypotheses
Top error messages
Failing stages
Suspect commits
Recommended next steps
compare_runs: Compare two builds for:Duration differences
Result changes
Stage-level diffs (with Blue Ocean)
get_pipeline_graph: Get pipeline visualization with stages, parallel execution, and timing (Blue Ocean)analyze_build_log: Analyze logs with build tool-specific parsers (Maven, Gradle, NPM) for detailed error analysis and recommendationsretry_flaky_build: Retry flaky builds with configurable attempts and delays
Test Results
get_test_report: Get test results summary (JUnit, pytest, etc.)get_failed_tests: List failed tests with error details and stack tracescompare_test_results: Compare test results between builds for regression detectiondetect_flaky_tests: Identify flaky tests across multiple builds
Logs (Enhanced)
tail_log_live: Poll-based live log tailing with progressive byte offsets
Output Formats
All tools support format parameter:
summary(default): Compact, token-efficient viewfull: Complete data with all fieldsdiff: Differences only (for comparisons)ids: IDs and URLs only
Example:
{
"name": "list_jobs",
"arguments": {
"format": "summary",
"page_size": 20
}
}Built-in Prompts
jankins includes pre-built prompts for common workflows:
investigate_failure: Full failure investigation workflowtail_errors: Show only warnings and errors from a buildcompare_builds: Compare two builds to find differencescheck_job_health: Check overall job health and stabilitytrigger_with_params: Trigger parameterized build with guidancesearch_logs: Search logs for specific patterns
Client Examples
Claude Desktop (stdio mode - recommended)
Add to your MCP settings:
{
"mcpServers": {
"jankins": {
"command": "jankins",
"env": {
"JENKINS_URL": "https://jenkins.example.com",
"JENKINS_USER": "myuser",
"JENKINS_API_TOKEN": "your-token-here"
}
}
}
}The default stdio transport communicates via stdin/stdout, which is the standard for MCP clients like Claude Desktop.
HTTP Mode (for HTTP-based MCP clients)
If your client requires HTTP transport:
{
"mcp": {
"servers": {
"jankins": {
"url": "http://localhost:8080/mcp",
"headers": {
"Content-Type": "application/json"
}
}
}
}
}Direct HTTP Request
Start in HTTP mode:
jankins --transport httpThen make requests:
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_build",
"arguments": {
"name": "my-job",
"number": "last",
"format": "summary"
}
}
}'Example Workflows
Investigate a Failing Build
Use the "investigate_failure" prompt with job "backend-api"This will:
Get build status
Retrieve error summary from logs
Perform failure triage
Show suspect commits
Provide recommended next steps
Compare Two Builds
{
"name": "compare_runs",
"arguments": {
"name": "backend-api",
"base": "100",
"head": "101"
}
}Search Logs for Error Pattern
{
"name": "search_log",
"arguments": {
"name": "backend-api",
"pattern": "OutOfMemoryError",
"window_lines": 10
}
}Get Only Errors from Last Build
{
"name": "get_build_log",
"arguments": {
"name": "backend-api",
"number": "last",
"filter_regex": "ERROR|FATAL",
"redact": true,
"format": "summary"
}
}Error Handling
jankins provides structured errors with:
Error code: JSON-RPC compliant error codes
Correlation ID: Track requests across logs
Hint: Human-readable remediation hint
Next actions: Specific steps to resolve the issue
Docs URL: Link to troubleshooting guide
Error taxonomy:
InvalidParams(-32602): Invalid tool parametersUnauthorized(-32001): Authentication failedForbidden(-32002): Insufficient permissionsNotFound(-32003): Resource not foundTimeout(-32007): Request timed outUpstreamError(-32006): Jenkins server error
Token Optimization
jankins minimizes token usage through:
Default summaries: Summary format by default, full on request
Field limiting: Only essential fields in summary mode
Smart truncation: Progressive log retrieval with byte limits
Token estimation: Responses include estimated token count
Structured data: Compact tables and lists over verbose text
Metadata separation: Performance data in
_metasection
Example response structure:
{
"build_number": 42,
"result": "FAILURE",
"duration": "2m 15s",
"_meta": {
"correlation_id": "abc-123",
"took_ms": 250,
"format": "summary",
"token_estimate": 180
}
}Security
Explicit configuration: Uses env vars or CLI flags (ignores .env files in working directory)
Basic auth: Uses Jenkins API tokens (never passwords)
Optional Origin validation: Enforce allowed origins
No secret logging: Credentials are redacted in logs
Secret masking: Jenkins secret masks are preserved/redacted
Note: jankins ignores any .env files in your working directory and only reads the specific environment variables it needs (JENKINS_*, MCP_*, etc.). This prevents conflicts with project .env files.
Generate API tokens:
Jenkins → User → Configure → API Token → Add new TokenHealth Checks
GET /_health: Basic health checkGET /_ready: Readiness check (verifies Jenkins connectivity)GET /_metrics: Placeholder for Prometheus metrics
Development
Run from Source
# Install with dev dependencies
pip install -e ".[dev]"
# Run server
python -m jankins --jenkins-url $URL --jenkins-user $USER --jenkins-token $TOKEN
# With debug logging
python -m jankins --log-level DEBUG --debug-httpTesting
pytest tests/Docker
See docker-compose.yml for local Jenkins + jankins setup.
docker-compose upThis starts:
Jenkins LTS on port 8081
jankins MCP server on port 8080
Feature Comparison
Feature | jankins | Official Plugin | Community Servers |
MCP Protocol | ✅ 2025-06-18 | ✅ | ⚠️ Varies |
Token optimization | ✅ | ❌ | ❌ |
Progressive logs | ✅ | ⚠️ Limited | ❌ |
Failure triage | ✅ | ❌ | ❌ |
Build comparison | ✅ | ❌ | ❌ |
Structured errors | ✅ | ⚠️ Basic | ❌ |
Built-in prompts | ✅ | ❌ | ❌ |
Format modes | ✅ | ❌ | ❌ |
Origin validation | ✅ | ✅ | ⚠️ Varies |
Troubleshooting
"Unauthorized" Error
Verify
JENKINS_USERandJENKINS_API_TOKENare correctRegenerate API token from Jenkins user settings
Check Jenkins server is accessible
"Timeout" Error
Increase
--timeoutvalueCheck Jenkins server responsiveness
Verify network connectivity
"Tool not found" Error
Ensure server started successfully
Check MCP client configuration
Verify tool name spelling
Large Logs Timing Out
Use
max_bytesparameter to limit retrievalUse
filter_regexto reduce log sizeUse
format=summaryfor overview first
License
MIT
Contributing
Contributions welcome! Please:
Add tests for new features
Follow existing code style
Update documentation
Add type hints
Acknowledgments
Built on:
python-jenkins for Jenkins API
Starlette for transport layer
Available Tools
25 toolsanalyze_build_logB
Analyze build logs with build tool-specific parsers (Maven, Gradle, NPM) for detailed error analysis
Inputs: name (required), number, build_tool, max_bytes, +1 more.
compare_runsA
Compare two builds to identify differences in duration, stages, and results
Inputs: name (required), base (required), head (required), format.
compare_test_resultsB
Compare test results between two builds to identify new failures and regressions
Inputs: name (required), base (required), head (required), format.
detect_flaky_testsB
Identify flaky tests (inconsistent pass/fail) across recent builds
Inputs: name (required), build_count, format.
disable_jobB
Disable a Jenkins job to prevent builds
Inputs: name (required).
enable_jobB
Enable a Jenkins job to allow builds
Inputs: name (required).
get_buildC
Get information about a specific build or the last build
Inputs: name (required), number, format.
get_build_artifactsC
Get artifacts produced by a build
Inputs: name (required), number, format.
get_build_changesB
Get SCM changes (commits) for a build
Inputs: name (required), number, format.
get_build_logA
Get build log with smart truncation and filtering. Returns summary by default, full text on request.
Inputs: name (required), number, start, max_bytes, +3 more.
get_build_scmA
Get SCM information (git commit, branch, etc.) for a build
Inputs: name (required), number.
get_failed_testsC
Get list of failed tests from a build with error details
Inputs: name (required), number, limit, format.
get_jobB
Get detailed information about a specific Jenkins job
Inputs: name (required), format.
get_job_scmB
Get SCM configuration for a job
Inputs: name (required), format.
get_pipeline_graphA
Get pipeline execution graph with stages, parallel branches, and timing (requires Blue Ocean plugin)
Inputs: name (required), number, format.
get_statusA
Get Jenkins server status and queue depth
Inputs: no named parameters.
get_test_reportB
Get test results summary from a build (JUnit, pytest, etc.)
Inputs: name (required), number, detailed, format.
list_jobsA
List Jenkins jobs with optional prefix filtering and pagination
Inputs: prefix, page, page_size, format.
retry_flaky_buildB
Retry a flaky build multiple times until it succeeds or max retries reached
Inputs: name (required), max_retries, delay_seconds, parameters, +1 more.
search_logB
Search build log for pattern and return matching lines with context
Inputs: name (required), pattern (required), number, window_lines, +1 more.
summarize_queueC
Get compact summary of Jenkins build queue
Inputs: no named parameters.
tail_log_liveA
Get log chunk for live tailing (poll repeatedly with next_byte for streaming effect)
Inputs: name (required), build_number (required), start_byte, max_bytes.
triage_failureC
Analyze a failed build and provide root cause hypotheses and next steps
Inputs: name (required), number, max_bytes, format.
trigger_buildC
Trigger a new build for a Jenkins job with optional parameters
Inputs: name (required), parameters.
whoamiA
Get current authenticated user information
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Most tools have distinct purposes (job management, build inspection, test analysis, pipeline, queue, user info). Some overlap exists between log-related tools (analyze_build_log vs search_log vs tail_log_live) but descriptions clarify their unique functions. SCM tools (get_build_scm vs get_build_changes) are also clearly separated.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., analyze_build_log, compare_runs, disable_job). No mixed conventions or inconsistent naming styles are observed.
25 tools is slightly above the ideal range (3-15) but is reasonable for a comprehensive Jenkins integration covering jobs, builds, tests, pipelines, queue, and user info. The count is earned given the breadth of functionality.
The tool set covers major CI/CD workflows: job management (list, get, enable/disable, trigger), build inspection (logs, artifacts, SCM, comparisons), test analysis, pipeline visualization, queue, and user info. Missing: job creation/deletion, build cancellation, and configuration editing, but core troubleshooting and monitoring are well-represented.
Maintenance
Related MCP Connectors
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants to interact with Jenkins CI/CD servers, providing tools to check build statuses, trigger builds, and retrieve build logs.315MIT
- AlicenseNot gradedqualityDmaintenanceEnterprise-grade MCP server for Jenkins CI/CD integration that enables AI assistants to diagnose build failures, analyze pipelines, and search logs through natural conversation.10 PyPI6GPL 3.0
- AlicenseNot gradedqualityDmaintenanceA Jenkins MCP server for multi-instance build management, log inspection, failure diagnostics, and optional vector search.30GPL 3.0
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server for Jenkins CI, enabling AI agents to securely query job/build status, logs, artifacts, and generate verification reports for loop workflows.17 npmISC