listProjects
Retrieve all projects for the authenticated user from the Clockify MCP server to manage and organize time tracking activities.
Instructions
List all projects for the authenticated user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers.ts:169-181 (handler)The switch case in callToolHandler that implements the 'listProjects' tool. It fetches the list of projects from the user's active workspace using the clockifyFetch helper and returns them as JSON text.case "listProjects": { const projects = await clockifyFetch( `/workspaces/${workspaceId}/projects`, ); return { content: [ { type: "text", text: JSON.stringify(projects, null, 2), }, ], }; }
- src/handlers.ts:38-42 (schema)The tool definition in listToolsHandler, including name, description, and empty input schema (no parameters required).{ name: "listProjects", description: "List all projects for the authenticated user.", inputSchema: { type: "object", properties: {}, required: [] }, },
- src/index.ts:43-43 (registration)Registers the listToolsHandler on the MCP server, which exposes the 'listProjects' tool schema to clients.server.setRequestHandler(ListToolsRequestSchema, listToolsHandler);
- src/index.ts:49-49 (registration)Registers the callToolHandler on the MCP server, which handles execution of the 'listProjects' tool via its switch case.server.setRequestHandler(CallToolRequestSchema, callToolHandler);
- src/handlers.ts:13-32 (helper)Helper function to make authenticated API calls to Clockify, used by the listProjects handler.async function clockifyFetch(endpoint: string, options: RequestInit = {}) { const apiKey = getApiKey(); const baseUrl = "https://api.clockify.me/api/v1"; const url = endpoint.startsWith("http") ? endpoint : `${baseUrl}${endpoint}`; const headers = { "X-Api-Key": apiKey, "Content-Type": "application/json", ...(options.headers || {}), }; const response = await fetch(url, { ...options, headers }); if (!response.ok) { const text = await response.text(); console.error( `[Error] Clockify API ${url} failed: ${response.status} ${text}`, ); throw new Error(`Clockify API error: ${response.status} ${text}`); } return response.json(); }