get_running_builds
Retrieve a list of all builds currently running in Jenkins to monitor active build processes.
Instructions
Get all running builds from Jenkins
Returns: A list of all running builds
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_jenkins/server/build.py:9-19 (handler)The MCP tool handler for 'get_running_builds'. Decorated with @mcp.tool, it fetches running builds via the Jenkins client and returns them as a list of dicts with only number, url, building, and timestamp fields.
@mcp.tool(tags=['read']) async def get_running_builds(ctx: Context) -> list[dict]: """Get all running builds from Jenkins Returns: A list of all running builds """ return [ item.model_dump(include={'number', 'url', 'building', 'timestamp'}) for item in jenkins(ctx).get_running_builds() ] - The helper method on the Jenkins REST client that actually queries all nodes (depth=2) and collects running builds from their executors.
def get_running_builds(self) -> list[Build]: """Get all running builds across all nodes. The build obtained through this method only includes the number, url and timestamp. Returns: A list of Build objects representing the running builds. """ builds = [] for node in self.get_nodes(depth=2): for executor in node.executors: if executor.currentExecutable and executor.currentExecutable.number: builds.append(Build.model_validate(executor.currentExecutable.model_dump(mode='json'))) return builds - The Build Pydantic model with fields: number, url, timestamp, duration, estimatedDuration, building, result, nextBuild, previousBuild.
class Build(BaseModel): number: int url: str timestamp: int = None duration: int = None estimatedDuration: int = None building: bool = None result: str | None = None nextBuild: Optional['Build'] = None previousBuild: Optional['Build'] = None - Models for Node, NodeExecutor, and NodeExecutorCurrentExecutable used by get_running_builds to iterate over executors.
class Node(BaseModel): displayName: str offline: bool executors: list['NodeExecutor'] class NodeExecutor(BaseModel): currentExecutable: Optional['NodeExecutorCurrentExecutable'] = None class NodeExecutorCurrentExecutable(BaseModel): url: str = None timestamp: int = None number: int = None fullDisplayName: str = None - src/mcp_jenkins/server/__init__.py:30-34 (registration)The MCP server instance (JenkinsMCP) created and then the build module is imported (line 34), which triggers the @mcp.tool decorator registration of get_running_builds.
mcp = JenkinsMCP('mcp-jenkins', lifespan=lifespan) # Import tool modules to register them with the MCP server # This must happen after mcp is created so the @mcp.tool() decorators can reference it from mcp_jenkins.server import build, item, node, plugin, queue, view # noqa: F401, E402