Skip to main content
Glama

get_task

Retrieve detailed information for a specific task using its unique task number (e.g., 'CRD-1') to access task details and requirements.

Instructions

Retrieves detailed information for a specific task using its unique task number (e.g., 'CRD-1').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numberYes

Implementation Reference

  • The `execute` method in `GetTaskTool` class implements the core logic of the `get_task` tool. It validates input, calls the SecureApiClient to fetch task details by number from `/task/number/{number}`, handles empty responses gracefully, and returns structured task data or error response.
    async execute(input: GetTaskInput): Promise<unknown> {
      logger.info('Executing get-task tool', input);
    
      try {
        // Use the injected API client to get task by number
        if (!this.apiClient) {
          throw new Error('API client not available - tool not properly initialized');
        }
    
        const url = `/task/number/${input.number.toUpperCase()}`;
        logger.debug(`Making GET request to: ${url}`);
        
        const responseData = await this.apiClient.get<TaskApiResponse>(url) as unknown as TaskApiResponse;
    
        // If responseData is null, undefined, or an empty object,
        // optional chaining and fallbacks will produce an "empty task" structure.
        // This ensures that if the API call itself doesn't throw (e.g. 404, 500),
        // but returns no meaningful data, we provide a default empty structure.
        
        // Return only the specific properties requested, ensuring compact JSON
        return {
          number: responseData?.number || input.number || '', // Echo input number if API response is empty
          title: responseData?.title || '',
          description: responseData?.description || '',
          status: responseData?.status || '',
          priority: responseData?.priority || '',
          agent: responseData?.agent || '',
          agent_prompt: responseData?.agent_prompt || '',
          context: responseData?.context || '',
          instructions: responseData?.instructions || ''
        };
      } catch (error) {
        const errorMessage = (error instanceof Error) ? error.message : 'An unknown error occurred';
        logger.error(`Error in get-task tool: ${errorMessage}`, error instanceof Error ? error : undefined);
        
        return {
          isError: true,
          content: [{ type: "text", text: errorMessage }]
        };
      }
    }
  • Zod schema `GetTaskSchema` defines the input validation for `get_task` tool, requiring a `number` field matching the pattern `^[A-Za-z]{3}-\d+$` (e.g., 'CRD-1').
    const GetTaskSchema = z.object({
      // Task number (required)
      number: z.string()
        .regex(/^[A-Za-z]{3}-\d+$/, { message: "Task number must be in the format ABC-123 (e.g., CRD-1 or crd-1). Case insensitive." })
        .describe("Task number identifier (e.g., 'CRD-1')"),
    }).strict();
  • src/index.ts:315-330 (registration)
    In `createProductionServer`, `GetTaskTool` is instantiated with `secureApiClient` dependency (line 318) and added to the `tools` array. The array is then iterated to call `tool.register(server)` on the MCP `Server` instance, registering the `get_task` tool.
    const tools: any[] = [
      new StartProjectTool(secureApiClient),
      new GetPromptTool(secureApiClient),
      new GetTaskTool(secureApiClient),
      new GetProjectTool(secureApiClient),
      new UpdateTaskTool(secureApiClient),
      new UpdateProjectTool(secureApiClient),
      new ListProjectsTool(secureApiClient),
      new ListTasksTool(secureApiClient),
      new NextTaskTool(secureApiClient),
    ];
    
    // Register each tool with the server
    tools.forEach(tool => {
      tool.register(server);
    });

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/PixdataOrg/coderide-mcp'

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