Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

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
NameRequiredDescriptionDefault
spaceNameYes
taskIdYes

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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;
    }
  • 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),
              },
            ],
          };
        }
      );
    }
  • 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,
    });
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OctopusDeploy/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server