get_task_by_id
Retrieve detailed information about a specific server task using its unique ID to monitor deployment progress, health checks, or system maintenance operations in Octopus Deploy.
Instructions
Get details for a specific server task by its ID. Tasks represent background operations in Octopus Deploy, such as deployments, health checks, and system maintenance. Each task has a unique ID and can be monitored for status and progress.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spaceName | Yes | ||
| taskId | Yes |
Implementation Reference
- src/tools/getTaskById.ts:34-55 (handler)The asynchronous handler function that implements the get_task_by_id tool logic: validates input, creates Octopus client, fetches task by ID from the SpaceServerTaskRepository, and returns the response as JSON-formatted text content.async (args) => { const { spaceName, taskId } = args as GetTaskByIdParams; if (!taskId) { throw new Error("Task ID is required"); } const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const serverTaskRepository = new SpaceServerTaskRepository(client, spaceName); const response = await serverTaskRepository.getById(taskId); return { content: [ { type: "text", text: JSON.stringify(response), }, ], }; }
- src/tools/getTaskById.ts:8-11 (schema)TypeScript interface defining the input parameters for the get_task_by_id tool: spaceName and taskId.export interface GetTaskByIdParams { spaceName: string; taskId: string; }
- src/tools/getTaskById.ts:59-63 (registration)Registers the get_task_by_id tool definition in the TOOL_REGISTRY, enabling conditional registration in src/tools/index.ts based on configuration.registerToolDefinition({ toolName: "get_task_by_id", config: { toolset: "tasks", readOnly: true }, registerFn: registerGetTaskByIdTool, });
- src/tools/getTaskById.ts:25-57 (registration)The registerGetTaskByIdTool function that registers the tool with the MCP server, including name, description, Zod input schema, UI properties, and handler reference.export function registerGetTaskByIdTool(server: McpServer) { server.tool( 'get_task_by_id', `Get details for a specific server task by its ID. ${tasksDescription}`, { spaceName: z.string(), taskId: z.string() }, { title: 'Get details for a specific server task by its ID', readOnlyHint: true, }, async (args) => { const { spaceName, taskId } = args as GetTaskByIdParams; if (!taskId) { throw new Error("Task ID is required"); } const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const serverTaskRepository = new SpaceServerTaskRepository(client, spaceName); const response = await serverTaskRepository.getById(taskId); return { content: [ { type: "text", text: JSON.stringify(response), }, ], }; } ); }
- src/tools/getTaskById.ts:13-23 (helper)Reusable helper function to retrieve a server task by ID using a pre-configured Client instance.export async function getTaskById(client: Client, params: GetTaskByIdParams) { const { spaceName, taskId } = params; if (!taskId) { throw new Error("Task ID is required"); } const serverTaskRepository = new SpaceServerTaskRepository(client, spaceName); const response = await serverTaskRepository.getById(taskId); return response; }