toggl_list_projects
Retrieve all projects from a Toggl Track workspace to manage and organize time tracking activities efficiently.
Instructions
List projects for a workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | No | Workspace ID (uses default if not provided) |
Implementation Reference
- src/index.ts:722-747 (handler)Handler for the 'toggl_list_projects' tool. Validates workspace ID, calls TogglAPI.getProjects, and formats the response as JSON with project details.case 'toggl_list_projects': { const workspaceId = args?.workspace_id || defaultWorkspaceId; if (!workspaceId) { throw new Error('Workspace ID required (set TOGGL_DEFAULT_WORKSPACE_ID or provide workspace_id)'); } const projects = await api.getProjects(workspaceId as number); return { content: [{ type: 'text', text: JSON.stringify({ workspace_id: workspaceId, count: projects.length, projects: projects.map(p => ({ id: p.id, name: p.name, active: p.active, billable: p.billable, color: p.color, client_id: p.client_id })) }, null, 2) }] }; }
- src/index.ts:324-336 (schema)Schema definition for the 'toggl_list_projects' tool, including input schema for optional workspace_id.{ name: 'toggl_list_projects', description: 'List projects for a workspace', inputSchema: { type: 'object', properties: { workspace_id: { type: 'number', description: 'Workspace ID (uses default if not provided)' } } }, },
- src/toggl-api.ts:106-108 (helper)Helper method in TogglAPI that performs the HTTP GET request to retrieve projects for the specified workspace.async getProjects(workspaceId: number): Promise<Project[]> { return this.request<Project[]>('GET', `/workspaces/${workspaceId}/projects`); }
- src/index.ts:386-388 (registration)Registration handler for listing all tools, including 'toggl_list_projects' via the tools array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });