Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mcp-server-plugin

> 编程语言
Open source

MCP Server Plugin for Jenkins The MCP (Model Context Protocol) Server Plugin for Jenkins implements the server-side component of the Model …

100 stars0 likes2 views
WebsiteGitHub

About

MCP Server Plugin for Jenkins The MCP (Model Context Protocol) Server Plugin for Jenkins implements the server-side component of the Model …

MCP Server Plugin for Jenkins

The MCP (Model Context Protocol) Server Plugin for Jenkins implements the server-side component of the Model Context Protocol. This plugin enables Jenkins to act as an MCP server, providing context, tools, and capabilities to MCP clients, such as LLM-powered applications or IDEs.

Features

  • MCP Server Implementation: Implements the server-side of the Model Context Protocol.
  • Jenkins Integration: Exposes Jenkins functionalities as MCP tools and resources.
  • Extensible Architecture: Allows easy extension of MCP capabilities through the McpServerExtension interface.

Key Components

  1. Endpoint: The main entry point for MCP communication, handling MCP transport connections and message routing.
  2. DefaultMcpServer: Implements McpServerExtension, providing default tools for interacting with Jenkins jobs and builds.
  3. McpToolWrapper: Wraps Java methods as MCP tools, handling parameter parsing and result formatting.
  4. McpServerExtension: Interface for extending MCP server capabilities.

MCP SDK Version

This MCP Server is based on the MCP Java SDK version 0.17.2, which implements the MCP specification version 2025-06-18.

Getting Started

Configuration

The MCP Server plugin automatically sets up necessary endpoints and tools upon installation, requiring no additional configuration.

System properties

The following system properties can be used to configure the MCP Server plugin:

  • hard limit on max number of log lines to return with io.jenkins.plugins.mcp.server.extensions.BuildLogsExtension.limit.max=10000 (default 10000)
  • disable stateless endpoint with io.jenkins.plugins.mcp.server.Endpoint.disableMcpStateless=true (default false)
  • disable SSE endpoint with io.jenkins.plugins.mcp.server.Endpoint.disableMcpSse=true (default false)
  • disable streamable HTTP endpoint with io.jenkins.plugins.mcp.server.Endpoint.disableMcpStreamable=true (default false)

Origin header validation

The MCP specification marks validating the Origin header of incoming requests as a MUST.

By default, when an Origin header is present it is validated against the configured Jenkins root URL (io.jenkins.plugins.mcp.server.Endpoint.requireOriginMatch defaults to true). Requests that do not send an Origin header are still allowed, so AI agents that omit it keep working (io.jenkins.plugins.mcp.server.Endpoint.requireOriginHeader defaults to false).

  • To also reject requests that omit the Origin header, set io.jenkins.plugins.mcp.server.Endpoint.requireOriginHeader=true.
  • To disable Origin matching entirely (not recommended), set io.jenkins.plugins.mcp.server.Endpoint.requireOriginMatch=false.

Connection Resilience

The MCP Server plugin includes several features to improve connection reliability.

The keep-alive and timeout tuning described below primarily concern the SSE transport (/mcp-server/sse), which holds a single long-lived server→client connection open and is therefore sensitive to idle timeouts in Jenkins, proxies, and load balancers. If you use Streamable HTTP (/mcp-server/mcp) with the usual request/response pattern, you are unlikely to need any of it (see Transport Recommendation). The health, metrics, and graceful-shutdown features apply to all transports.

Keep-Alive Messages

For the SSE transport, the server sends periodic keep-alive pings over the open connection to detect broken connections and to stop idle timeouts (in Jenkins, proxies, or load balancers) from closing it. By default, pings are sent every 30 seconds.

You can configure this interval with the system property:

io.jenkins.plugins.mcp.server.Endpoint.keepAliveInterval=30

Set to 0 to disable keep-alive messages (not recommended for SSE).

[!NOTE] A ping is only delivered when there is an open server→client stream. SSE always has one. Streamable HTTP only has one while the client keeps a long-lived GET stream open; for a plain POST request/response client there is no stream to ping, so this setting has no effect.

Health Endpoint

A lightweight MCP-specific health endpoint is available for connection monitoring at:

/mcp-health

This endpoint:

  • Returns MCP server status and active connection counts
  • Requires no authentication for maximum accessibility
  • Returns immediately without MCP protocol overhead
  • Returns HTTP 200 when healthy, HTTP 503 during shutdown
  • Includes Retry-After header during shutdown

Response format:

json
{
  "mcpServerStatus": "ok",
  "activeConnections": 5,
  "shuttingDown": false,
  "timestamp": "2025-01-28T10:30:00Z"
}

Recommended client usage:

  • Poll the health endpoint periodically (e.g., every 10-30 seconds)
  • When the endpoint returns 503 or becomes unreachable, prepare for reconnection
  • Use the Retry-After header value when available

Metrics Endpoint

A metrics endpoint is available for monitoring connection statistics at:

/mcp-server/metrics

This endpoint requires authentication (standard Jenkins permissions) and provides:

json
{
  "sseConnectionsTotal": 42,
  "sseConnectionsActive": 3,
  "streamableRequestsTotal": 150,
  "connectionErrorsTotal": 2,
  "uptimeSeconds": 3600,
  "startTime": "2025-01-28T10:00:00Z"
}

Graceful Shutdown

When Jenkins shuts down, the health endpoint will return 503 Service Unavailable with a brief grace period before full termination. This allows clients to detect the shutdown and prepare for reconnection.

Transport Recommendation

For better connection reliability, we recommend using Streamable HTTP (/mcp-server/mcp) instead of SSE (/mcp-server/sse). Streamable HTTP handles connection issues more gracefully and is the preferred transport for most MCP clients.

Production Deployment

When deploying the SSE transport behind a reverse proxy or in production environments, configure the timeout settings below so the long-lived connection is not dropped prematurely. Streamable HTTP users generally don't need this (see the note at the end of this section).

Jenkins/Jetty Configuration (SSE)

Jenkins uses Winstone (embedded Jetty) which defaults httpKeepAliveTimeout to 30 seconds. Since MCP keep-alive pings are also sent every 30 seconds, this creates a race condition where Jetty may close the SSE connection before the next ping arrives.

Add this argument to your Jenkins startup command:

--httpKeepAliveTimeout=600000

For Docker deployments, add to your docker-compose.yml:

yaml
services:
  jenkins:
    image: jenkins/jenkins:lts
    command: ["--httpKeepAliveTimeout=600000"]

Reverse Proxy Configuration (Nginx)

For Nginx, extend timeouts for the MCP endpoints. This keeps SSE connections from being closed while idle:

nginx
location ~ ^/(mcp-server|mcp-health)/ {
    proxy_pass http://jenkins;
    proxy_http_version 1.1;
    proxy_request_buffering off;
    proxy_buffering off;
    proxy_set_header Connection "";
    proxy_read_timeout 600s;
    proxy_send_timeout 600s;
}

[!NOTE] The one timeout that can also affect Streamable HTTP is proxy_read_timeout: a single long-running tool call (for example a slow triggerBuild) can exceed a short default and return 504 Gateway Timeout. Raising proxy_read_timeout as shown above prevents that regardless of transport. The httpKeepAliveTimeout race condition above is SSE-only.

Transport Endpoints

The MCP Server plugin provides three transport endpoints, all enabled by default:

Transport Endpoint Description
SSE /mcp-server/sse + /mcp-server/message Server-Sent Events transport with session management
Streamable HTTP /mcp-server/mcp Streamable HTTP transport with session management
Stateless /mcp-server/stateless Stateless HTTP transport without session management

Each transport can be disabled independently using system properties:

-Dio.jenkins.plugins.mcp.server.Endpoint.disableMcpSse=true
-Dio.jenkins.plugins.mcp.server.Endpoint.disableMcpStreamable=true
-Dio.jenkins.plugins.mcp.server.Endpoint.disableMcpStateless=true
When to use Stateless transport

The stateless endpoint (/mcp-server/stateless) is useful for:

  • Simple deployments where session management overhead is not needed
  • Environments where clients make independent requests without maintaining a persistent connection
  • Testing and debugging scenarios
  • Clients that don't support session-based protocols

Usage

Connecting to the MCP Server

MCP clients can connect to the server using:

  • Streamable HTTP Endpoint: /mcp-server/mcp
  • SSE Endpoint: /mcp-server/sse
  • Message Endpoint: /mcp-server/message
  • Stateless Endpoint: /mcp-server/stateless

Authentication and Credentials

The MCP Server Plugin requires the same credentials as the Jenkins instance it's running on. To authenticate your MCP queries:

  1. Jenkins API Token: Generate an API token from your Jenkins user account.
  2. Basic Authentication: Use the API token in the HTTP Basic Authentication header.

Generate a personal access token

To generate a personal access token:

  • Sign in to Jenkins.
  • Select your user icon in the upper-right corner, and then select Security.
  • Select Add new token.
  • Enter a name to distinguish the token, and then select Generate.
  • Copy the token and store it in a secure location for later use.

[!WARNING] Once you leave the page, you cannot view or copy the token again.

  • Select Done to add the token.
  • Select Save to save your changes.

Encode credentials for HTTP basic authentication

Use basic HTTP authentication with the MCP agent by encoding it with the personal access token.

To encode credentials on Linux, macOS, or Windows:

Open a terminal and run the following command, replacing and with your actual username and the personal access token you generated in Jenkins

  • Linux or macOS
bash
echo -n ":" | base64
  • Windows (PowerShell)
powershell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(":"))

if successful, the Base64-encoded credential is output, similar to the following:

bash
dXNlcm5hbWU6dG9rZW4=

Store the encoded credential in a secure location for later use.

[!NOTE] Base64 encoding is not encryption. Anyone with access to the encoded string can decode it and obtain your credentials. Always protect the encoded credentials as if they are the original username and token.

Example Client Configurations

Cline Configuration

json
{
  "mcpServers": {
    "jenkins": {
      "autoApprove": [
        
      ],
      "disabled": false,
      "timeout": 60,
      "type": "streamableHttp",
      "url": "https://jenkins-host/mcp-server/mcp",
      "headers": {
        "Authorization": "Basic "
      }
    }
  }
}

Copilot Configuration

Copilot doesn't work well with the Streamable transport as of now, and I'm still investigating the issues. Please continue to use the SSE endpoint.

json
{
  "mcp": {
    "servers": {
      "jenkins": {
        "type": "sse",
        "url": "https://jenkins-host/mcp-server/sse",
        "headers": {
          "Authorization": "Basic "
        }
      }
    }
  }
}

Streamable example:

json
{
  "servers": {
    "jenkins": {
      "type": "http",
      "url": "http://jenkins-host/mcp-server/mcp",
      "requestInit": {
        "headers": {
          "Authorization": "Basic "
        }
      }
    }
  }
}

Windsurf Configuration

json
{
  "servers": {
    "jenkins": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://jenkins-host/mcp-server/mcp",
        "--header",
        "Authorization: Bearer ${AUTH_TOKEN}"
      ],
      "env": {
        "AUTH_TOKEN": "Basic "
      }
    }
  }
}

Cursor Configuration

json
{
  "mcpServers": {

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaaimcp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言