Skip to main content
Glama

get_user_projects

Retrieve your assigned projects from MoCo time tracking system, with optional search by name or description to find specific work items.

Instructions

Get all projects assigned to the current user or search within assigned projects by name/description. If no query is provided, returns all assigned projects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoOptional search query to find projects by name or description (case-insensitive)

Implementation Reference

  • The main handler for the get_user_projects tool. It uses MocoApiService to fetch user projects or search by query, formats results, and handles errors.
    export const getUserProjectsTool = { name: 'get_user_projects', description: 'Get all projects assigned to the current user or search within assigned projects by name/description. If no query is provided, returns all assigned projects.', inputSchema: zodToJsonSchema(GetProjectsSchema), handler: async (params: z.infer<typeof GetProjectsSchema>): Promise<string> => { const { query } = params; try { const apiService = new MocoApiService(); // If query is provided and not empty, search; otherwise list all if (query && query.trim()) { const projects = await apiService.searchProjects(query.trim()); if (projects.length === 0) { return createEmptyResultMessage({ type: 'projects', query: query.trim() }); } return formatProjectsSearchResults(projects, query.trim()); } else { const projects = await apiService.getProjects(); if (projects.length === 0) { return createEmptyResultMessage({ type: 'projects' }); } return formatProjectsList(projects); } } catch (error) { return `Error retrieving projects: ${error instanceof Error ? error.message : 'Unknown error'}`; } } };
  • Zod schema defining the input for get_user_projects tool: optional query string.
    const GetProjectsSchema = z.object({ query: z.string().optional().describe('Optional search query to find projects by name or description (case-insensitive)') });
  • src/index.ts:34-42 (registration)
    Registration of getUserProjectsTool in the AVAILABLE_TOOLS array used by the MCP server for tool listing and execution.
    const AVAILABLE_TOOLS = [ getActivitiesTool, getUserProjectsTool, getUserProjectTasksTool, getUserHolidaysTool, getUserPresencesTool, getUserSickDaysTool, getPublicHolidaysTool ];
  • Helper function to format the list of user projects into a readable string format.
    function formatProjectsList(projects: Project[]): string { const lines: string[] = []; lines.push(`Assigned projects (${projects.length}):\n`); projects.forEach(project => { lines.push(`ID: ${project.id}`); lines.push(`Name: ${project.name}`); if (project.description) { lines.push(`Description: ${project.description}`); } lines.push(`Status: ${project.active ? 'Active' : 'Inactive'}`); if (project.customer) { lines.push(`Customer: ${project.customer.name}`); } if (project.leader) { lines.push(`Leader: ${project.leader.firstname} ${project.leader.lastname}`); } if (project.budget) { lines.push(`Budget: ${project.budget} ${project.currency}`); } lines.push(''); // Empty line between projects }); return lines.join('\\n'); }
  • Helper function to format search results for projects with search term highlighting.
    function formatProjectsSearchResults(projects: Project[], query: string): string { const lines: string[] = []; lines.push(`Search results for "${query}" (${projects.length} found):\n`); projects.forEach(project => { lines.push(`ID: ${project.id}`); lines.push(`Name: ${highlightSearchTerm(project.name, query)}`); if (project.description) { lines.push(`Description: ${highlightSearchTerm(project.description, query)}`); } lines.push(`Status: ${project.active ? 'Active' : 'Inactive'}`); if (project.customer) { lines.push(`Customer: ${project.customer.name}`); } lines.push(''); // Empty line between projects }); 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