Skip to content

t089/jenkins-mcp

Repository files navigation

Jenkins MCP Server

A Model Context Protocol (MCP) server for Jenkins automation, enabling AI assistants to interact with Jenkins instances.

Table of Contents

Overview

This project provides a stdio MCP server that exposes Jenkins functionality to AI assistants through the Model Context Protocol, enabling seamless automation and interaction with Jenkins instances.

The server includes efficient tools for working with large outputs, using grep patterns and pagination to explore logs progressively without overwhelming context windows. It also provides flexible test result analysis with filtering options to manage output size for large test suites.

Installation

From source

  1. Clone and build the project:
git clone https://github.com/your-org/jenkins-mcp.git
cd jenkins-mcp
swift build -c release
  1. Set up authentication (see Authentication section)

  2. Add to your MCP configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "jenkins": {
      "type": "stdio",
      "command": "/path/to/jenkins-mcp/.build/release/jenkins-mcp",
      "args": ["--jenkins-url", "https://your-jenkins.com"]
    }
  }
}

Using docker

  1. Store credential in a netrc file. See Authentication section.

  2. Add to your MCP configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "jenkins": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-v",
        "/path/to/.netrc:/var/jenkins/.netrc",
        "ghcr.io/t089/jenkins-mcp:0.2.1",
        "--jenkins-url",
        "https://your-jenkins.com",
        "--netrc-file",
        "/var/jenkins/.netrc"
      ]
    }
  }
}

Available Tools

Job Management:

  • get_overview - Jenkins server overview
  • list_jobs - List jobs in a folder
  • get_job / get_job_by_url - Get job details
  • trigger_build - Trigger builds with parameters

Build Operations:

  • get_build / get_build_by_url - Get build details
  • stop_build - Stop running builds
  • get_queue - View build queue
  • get_queue_item - Get specific queue item details
  • cancel_queue_item - Cancel queued builds

Log Analysis:

  • get_build_logs - Get console output with pagination
  • get_build_logs_offset - Read logs from specific offset
  • grep_build_logs - Search logs with regex patterns

Test Results:

  • get_build_test_report - Get test results with filtering options:
    • level: Control output detail (summary, suite, full)
    • status: Filter by test status (all, failed, passed, skipped)
    • namePattern: Filter tests by regex pattern
    • maxTests: Limit number of test cases returned (when using full level)
    • maxErrorLength: Maximum length for error details and stack traces (default: 1000, 0 = no truncation)
    • limit: Maximum number of test suites to return (default: 50)
    • offset: Number of test suites to skip for pagination (default: 0)

Authentication

The server supports two authentication methods:

Netrc File (Recommended):

Create ~/.netrc:

machine your-jenkins.com
login your-username
password your-api-token

Set permissions:

chmod 600 ~/.netrc

Environment Variables:

export JENKINS_USERNAME=your-username
export JENKINS_PASSWORD=your-api-token

Keychain (macOS - recommended):

Not yet implemented.

Building and Development

# Build all targets
swift build

# Run tests
swift test

# Build release version
swift build -c release

# Build Docker images
make docker

Copyright 2025 Tobias Haeberle

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages