Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ When enforcing the validation, the header value must match the configured Jenkin
If receiving the header is mandatory the system property `io.jenkins.plugins.mcp.server.Endpoint.requireOriginHeader=true`
will make it mandatory as well.

#### Jenkins Root URL Configuration

MCP tools rely on the Jenkins root URL being correctly configured. This is required for generating accurate links within tool responses and for the proper functioning of certain features (for example, origin header validation).

If the Jenkins root URL is not configured, MCP tool invocations will fail immediately with a clear error message explaining how to resolve the issue.

To configure the Jenkins root URL:

1. Navigate to **Manage Jenkins** in your Jenkins instance.
2. Go to **Configure System**.
3. Locate the **Jenkins URL** field and enter the full URL of your Jenkins instance (for example, `http://your-jenkins.example.com/`).
4. Click **Save**.


#### Transport Endpoints

The MCP Server plugin provides three transport endpoints, all enabled by default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,14 @@ String getToolDescription() {
return getToolName();
}

McpSchema.CallToolResult toMcpResult(Object result, String tree) {
private static void ensureRootUrlConfigured() {
if (Jenkins.get().getRootUrl() == null) {
throw new IllegalStateException(
"The Jenkins root URL is not configured. Please set it in 'Manage Jenkins -> Configure System' to use MCP tools.");
}
}

McpSchema.CallToolResult toMcpResult(Object result) {
var builder = new ToolResponse.ToolResponseBuilder().status(ToolResponse.Status.COMPLETED);

if (result == null) {
Expand Down Expand Up @@ -310,6 +316,7 @@ private McpSchema.CallToolResult call(McpTransportContext mcpTransportContext, M
var jenkinsMcpContext = JenkinsMcpContext.get()) {
// need Jenkins.READ at least
Jenkins.get().checkPermission(Jenkins.READ);
ensureRootUrlConfigured();
if (log.isTraceEnabled()) {
log.trace(
"Tool call: {} as user '{}', arguments: {}",
Expand Down