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 …
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.
McpServerExtension interface.McpServerExtension, providing default tools for interacting with Jenkins jobs and builds.This MCP Server is based on the MCP Java SDK version 0.17.2, which implements the MCP specification version 2025-06-18.
The MCP Server plugin automatically sets up necessary endpoints and tools upon installation, requiring no additional configuration.
The following system properties can be used to configure the MCP Server plugin:
io.jenkins.plugins.mcp.server.extensions.BuildLogsExtension.limit.max=10000 (default 10000)io.jenkins.plugins.mcp.server.Endpoint.disableMcpStateless=true (default false)io.jenkins.plugins.mcp.server.Endpoint.disableMcpSse=true (default false)io.jenkins.plugins.mcp.server.Endpoint.disableMcpStreamable=true (default false)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).
Origin header, set
io.jenkins.plugins.mcp.server.Endpoint.requireOriginHeader=true.io.jenkins.plugins.mcp.server.Endpoint.requireOriginMatch=false.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.
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=30Set 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.
A lightweight MCP-specific health endpoint is available for connection monitoring at:
/mcp-healthThis endpoint:
Retry-After header during shutdownResponse format:
{
"mcpServerStatus": "ok",
"activeConnections": 5,
"shuttingDown": false,
"timestamp": "2025-01-28T10:30:00Z"
}Recommended client usage:
Retry-After header value when availableA metrics endpoint is available for monitoring connection statistics at:
/mcp-server/metricsThis endpoint requires authentication (standard Jenkins permissions) and provides:
{
"sseConnectionsTotal": 42,
"sseConnectionsActive": 3,
"streamableRequestsTotal": 150,
"connectionErrorsTotal": 2,
"uptimeSeconds": 3600,
"startTime": "2025-01-28T10:00:00Z"
}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.
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.
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=600000For Docker deployments, add to your docker-compose.yml:
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:
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 slowtriggerBuild) can exceed a short default and return504 Gateway Timeout. Raisingproxy_read_timeoutas shown above prevents that regardless of transport. ThehttpKeepAliveTimeoutrace condition above is SSE-only.
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=trueThe stateless endpoint (/mcp-server/stateless) is useful for:
MCP clients can connect to the server using:
/mcp-server/mcp/mcp-server/sse/mcp-server/message/mcp-server/statelessThe MCP Server Plugin requires the same credentials as the Jenkins instance it's running on. To authenticate your MCP queries:
To generate a personal access token:
Security.Add new token.Generate.[!WARNING] Once you leave the page, you cannot view or copy the token again.
Done to add the token.Save to save your changes.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
echo -n ":" | base64[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(":"))if successful, the Base64-encoded credential is output, similar to the following:
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.
{
"mcpServers": {
"jenkins": {
"autoApprove": [
],
"disabled": false,
"timeout": 60,
"type": "streamableHttp",
"url": "https://jenkins-host/mcp-server/mcp",
"headers": {
"Authorization": "Basic "
}
}
}
}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.
{
"mcp": {
"servers": {
"jenkins": {
"type": "sse",
"url": "https://jenkins-host/mcp-server/sse",
"headers": {
"Authorization": "Basic "
}
}
}
}
}Streamable example:
{
"servers": {
"jenkins": {
"type": "http",
"url": "http://jenkins-host/mcp-server/mcp",
"requestInit": {
"headers": {
"Authorization": "Basic "
}
}
}
}
}{
"servers": {
"jenkins": {
"command": "npx",
"args": [
"mcp-remote",
"http://jenkins-host/mcp-server/mcp",
"--header",
"Authorization: Bearer ${AUTH_TOKEN}"
],
"env": {
"AUTH_TOKEN": "Basic "
}
}
}
}{
"mcpServers": {No open issues yet, or sync has not completed.