get_task_by_id
Retrieve details for a specific Octopus Deploy server task using its unique ID to monitor deployment, health check, or maintenance operation status and progress.
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 core handler function for the 'get_task_by_id' tool. It extracts parameters, validates taskId, creates an Octopus Deploy client, fetches the task using SpaceServerTaskRepository.getById, and returns the JSON response as MCP 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), used for type casting in the handler.export interface GetTaskByIdParams { spaceName: string; taskId: string; }
- src/tools/getTaskById.ts:25-57 (registration)Registers the 'get_task_by_id' tool on the MCP server using server.tool, including name, description, Zod input schema, properties, and handler function.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:59-63 (registration)Self-registration of the tool into the TOOL_REGISTRY, specifying tool name, config (toolset 'tasks', read-only), and the registration function.registerToolDefinition({ toolName: "get_task_by_id", config: { toolset: "tasks", readOnly: true }, registerFn: registerGetTaskByIdTool, });
- src/tools/getTaskById.ts:13-23 (helper)Helper function to get a task by ID using a provided client, reusable logic similar to the handler but without MCP wrapper or client creation.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; }