Skip to main content
Glama
task-list.ts2.8 kB
/** * task_list - List all tasks * * Retrieves project tasks for detailed time tracking. */ import { z } from 'zod'; import { BusinessIdSchema, PaginationSchema } from '../base-tool.js'; import { TaskListOutputSchema } from './schemas.js'; import { ErrorHandler } from '../../errors/error-handler.js'; import { ToolContext } from '../../errors/types.js'; import { FreshBooksClientWrapper } from '../../client/index.js'; const InputSchema = BusinessIdSchema.extend({ ...PaginationSchema.shape, }); /** * Tool definition for task_list */ export const taskListTool = { name: 'task_list', description: `List tasks from FreshBooks. WHEN TO USE: - User wants to see project tasks - Need to find a task ID for time entry - Browse available task categories - Review task organization REQUIRED INFO: - Business ID (FreshBooks business/account identifier) OPTIONAL PARAMETERS: - page: Page number for pagination (default: 1) - perPage: Results per page (default: 30, max: 100) RETURNS: Array of tasks with: - Task ID, name, description - Billable status and rate - Visibility state (active/archived) - Pagination metadata EXAMPLE PROMPTS: - "Show me all tasks" - "List project tasks" - "What tasks can I assign time to?" - "Get all billable tasks" NOTE: Tasks can have alternate field names (name/tname, description/tdesc) in the API.`, inputSchema: InputSchema, outputSchema: TaskListOutputSchema, async execute( input: z.infer<typeof InputSchema>, client: FreshBooksClientWrapper ): Promise<z.infer<typeof TaskListOutputSchema>> { const handler = ErrorHandler.wrapHandler( 'task_list', async (input: z.infer<typeof InputSchema>, _context: ToolContext) => { const { businessId, page, perPage } = input; const result = await client.executeWithRetry('task_list', async (fbClient) => { const { PaginationQueryBuilder } = await import( '@freshbooks/api/dist/models/builders/index.js' ); // Build pagination query const queryBuilders = []; if (page || perPage) { queryBuilders.push(new PaginationQueryBuilder().page(page ?? 1).perPage(perPage ?? 30)); } // Call FreshBooks API const response = await fbClient.tasks.list(String(businessId), queryBuilders); if (!response.ok) { throw response.error; } return response.data; }); return { tasks: (result as any).tasks || [], pagination: (result as any).pages || { page: 1, pages: 1, total: (result as any).tasks?.length || 0, perPage: perPage ?? 30, }, }; } ); return handler(input, { businessId: input.businessId }); }, };

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/Good-Samaritan-Software-LLC/freshbooks-mcp'

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