Skip to main content
Glama

getTaskById

Retrieve a specific task from Teamwork projects using its unique ID to access detailed information and manage project workflows.

Instructions

Get a specific task by ID from Teamwork

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYesThe ID of the task to retrieve

Implementation Reference

  • MCP tool handler function that validates input, calls the teamwork service to fetch the task, formats the response as text content, and handles errors.
    export async function handleGetTaskById(input: any) {
      logger.info('Calling teamworkService.getTaskById()');
      logger.info(`Task ID: ${input?.taskId}`);
      
      try {
        const taskId = String(input?.taskId);
        if (!taskId) {
          throw new Error("Task ID is required");
        }
        
        const task = await teamworkService.getTaskById(taskId);
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(task, null, 2)
          }]
        };
      } catch (error: any) {
        return createErrorResponse(error, 'Retrieving task');
      }
    } 
  • Tool definition including name, description, input schema (taskId as integer), and annotations for the MCP tool.
    export const getTaskByIdDefinition = {
      name: "getTaskById",
      description: "Get a specific task by ID from Teamwork",
      inputSchema: {
        type: "object",
        properties: {
          taskId: {
            type: "integer",
            description: "The ID of the task to retrieve"
          }
        },
        required: ["taskId"]
      },
      annotations: {
        title: "Get a Task by its ID",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false
      }
    };
  • Registration of the getTaskById tool in the toolPairs array, mapping definition to handler for MCP tool registry.
    { definition: getTaskById, handler: handleGetTaskById },
  • Service function that performs the actual API call to Teamwork to retrieve a task by ID, used by the tool handler.
    export const getTaskById = async (taskId: string) => {
      try {
        const api = ensureApiClient();
        const response = await api.get(`/tasks/${taskId}.json`);
        return response.data;
      } catch (error: any) {
        logger.error(`Error fetching task ${taskId}: ${error.message}`);
        throw new Error(`Failed to fetch task ${taskId}`);
      }
    };

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/Vizioz/Teamwork-MCP'

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