Skip to main content
Glama
niondigital

MoCo MCP Server

by niondigital

get_user_project_tasks

Retrieve all tasks for a specific project assigned to you using the project ID. This tool helps you view and manage your project workload within the MoCo time tracking system.

Instructions

Get all tasks for a specific assigned project by project ID. Only works for projects assigned to the current user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID to retrieve tasks for

Implementation Reference

  • The main handler function for the get_user_project_tasks tool. Validates projectId, fetches tasks using MocoApiService, handles empty results and errors, and formats output using formatProjectTasks.
    handler: async (params: z.infer<typeof GetProjectTasksSchema>): Promise<string> => {
      const { projectId } = params;
    
      if (!Number.isInteger(projectId) || projectId <= 0) {
        return createValidationErrorMessage({
          field: 'projectId',
          value: projectId,
          reason: 'invalid_project_id'
        });
      }
    
      try {
        const apiService = new MocoApiService();
        const tasks = await apiService.getProjectTasks(projectId);
    
        if (tasks.length === 0) {
          return createEmptyResultMessage({ 
            type: 'tasks',
            projectId 
          });
        }
    
        return formatProjectTasks(tasks, projectId);
    
      } catch (error) {
        return `Error retrieving tasks for project ${projectId}: ${error instanceof Error ? error.message : 'Unknown error'}`;
      }
    }
  • Zod schema defining the input for the tool: requires a positive projectId number.
    const GetProjectTasksSchema = z.object({
      projectId: z.number().positive().describe('Project ID to retrieve tasks for')
    });
  • src/index.ts:34-42 (registration)
    The tool is imported and registered in the AVAILABLE_TOOLS array, which is used by the MCP server for tool listing and execution dispatching.
    const AVAILABLE_TOOLS = [
      getActivitiesTool,
      getUserProjectsTool,
      getUserProjectTasksTool,
      getUserHolidaysTool,
      getUserPresencesTool,
      getUserSickDaysTool,
      getPublicHolidaysTool
    ];
  • Helper function to format the list of tasks into a readable string output, used by the tool handler.
    function formatProjectTasks(tasks: Task[], projectId: number): string {
      const lines: string[] = [];
      
      lines.push(`Tasks for project ${projectId} (${tasks.length} found):\n`);
    
      tasks.forEach(task => {
        lines.push(`ID: ${task.id}`);
        lines.push(`Name: ${task.name}`);
        lines.push(`Status: ${task.active ? 'Active' : 'Inactive'}`);
        lines.push(`Billable: ${task.billable ? 'Yes' : 'No'}`);
        lines.push(''); // Empty line between tasks
      });
    
      return lines.join('\\n');
    }

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/niondigital/moco-mcp'

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