get_queue_item
Retrieve a specific Jenkins queue item by its ID to inspect the details or status of a queued job.
Instructions
Get a specific item in Jenkins queue by id
Args: id: The id of the queue item
Returns: The queue item
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_jenkins/server/queue.py:17-28 (handler)The actual MCP tool handler for 'get_queue_item'. It is decorated with @mcp.tool(tags=['read']), fetches a queue item using the Jenkins rest client, and returns it as a dict via model_dump.
@mcp.tool(tags=['read']) async def get_queue_item(ctx: Context, id: int) -> dict: """Get a specific item in Jenkins queue by id Args: id: The id of the queue item Returns: The queue item """ item = jenkins(ctx).get_queue_item(id=id, depth=1) return item.model_dump(exclude_none=True) - Pydantic model (schema) for QueueItem, defining fields: id, inQueueSince, url, why, task (QueueItemTask). Used to validate/parse the API response.
class QueueItem(BaseModel): id: int inQueueSince: int url: str why: str | None task: 'QueueItemTask' class QueueItemTask(BaseModel): fullDisplayName: str = None name: str = None url: str = None - Jenkins REST client method get_queue_item() that calls the Jenkins API endpoint (QUEUE_ITEM) and parses the response into a QueueItem model.
def get_queue_item(self, *, id: int, depth: int = 0) -> 'QueueItem': """Get a queue item by its ID. Args: id: The ID of the queue item. depth: The depth of the information to retrieve. Returns: The QueueItem object. """ response = self.request('GET', rest_endpoint.QUEUE_ITEM(id=id, depth=depth)) return QueueItem.model_validate(response.json()) - REST endpoint definition for QUEUE_ITEM used to construct the URL: 'queue/item/{id}/api/json?depth={depth}'
QUEUE_ITEM = RestEndpoint('queue/item/{id}/api/json?depth={depth}') - src/mcp_jenkins/server/__init__.py:30-34 (registration)The MCP server instance 'mcp' is created here, and the queue module is imported (line 34) so that the @mcp.tool decorator on get_queue_item registers it with the server.
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