get_spaces
Retrieve all spaces from a ClickUp workspace. Returns space details including name, settings, and features.
Instructions
Get spaces from a ClickUp workspace. Returns space details including name, settings, and features.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | Yes | The ID of the workspace to get spaces from |
Implementation Reference
- src/tools/space-tools.ts:11-33 (handler)The handler function for the 'get_spaces' tool. Registers the tool with name 'get_spaces', accepts workspace_id parameter, calls spacesClient.getSpacesFromWorkspace, and returns the spaces as JSON.
// Register get_spaces tool server.tool( 'get_spaces', 'Get spaces from a ClickUp workspace. Returns space details including name, settings, and features.', { workspace_id: z.string().describe('The ID of the workspace to get spaces from') }, async ({ workspace_id }) => { try { console.error(`[SpaceTools] Getting spaces for workspace ${workspace_id}...`); const spaces = await spacesClient.getSpacesFromWorkspace(workspace_id); console.error(`[SpaceTools] Got ${spaces.length} spaces`); return { content: [{ type: 'text', text: JSON.stringify(spaces, null, 2) }] }; } catch (error: any) { console.error('Error getting spaces:', error); return { content: [{ type: 'text', text: `Error getting spaces: ${error.message}` }], isError: true }; } } ); - src/tools/space-tools.ts:15-15 (schema)Input schema for get_spaces: workspace_id (string) required parameter.
{ workspace_id: z.string().describe('The ID of the workspace to get spaces from') }, - src/tools/space-tools.ts:11-33 (registration)Tool registration using server.tool() with name 'get_spaces'. The setupSpaceTools function is called from src/index.ts line 44.
// Register get_spaces tool server.tool( 'get_spaces', 'Get spaces from a ClickUp workspace. Returns space details including name, settings, and features.', { workspace_id: z.string().describe('The ID of the workspace to get spaces from') }, async ({ workspace_id }) => { try { console.error(`[SpaceTools] Getting spaces for workspace ${workspace_id}...`); const spaces = await spacesClient.getSpacesFromWorkspace(workspace_id); console.error(`[SpaceTools] Got ${spaces.length} spaces`); return { content: [{ type: 'text', text: JSON.stringify(spaces, null, 2) }] }; } catch (error: any) { console.error('Error getting spaces:', error); return { content: [{ type: 'text', text: `Error getting spaces: ${error.message}` }], isError: true }; } } ); - src/clickup-client/spaces.ts:57-61 (helper)Helper client method getSpacesFromWorkspace that makes the actual API call to GET /team/{workspaceId}/space and returns the spaces array.
async getSpacesFromWorkspace(workspaceId: string): Promise<Space[]> { // Use the v2 API endpoint for spaces const response = await this.client.get(`/team/${workspaceId}/space`); return response.spaces; } - src/clickup-client/auth.ts:67-118 (helper)AuthClient.getSpaces method - an alternate client method (unused by the tool directly) that also calls GET /team/{workspaceId}/space and includes a detailed response type definition for space objects.
async getSpaces(workspaceId: string): Promise<{ spaces: Array<{ id: string; name: string; private: boolean; statuses: Array<{ id: string; status: string; type: string; orderindex: number; color: string; }>; multiple_assignees: boolean; features: { due_dates: { enabled: boolean; start_date: boolean; remap_due_dates: boolean; remap_closed_due_date: boolean; }; time_tracking: { enabled: boolean; }; tags: { enabled: boolean; }; time_estimates: { enabled: boolean; }; checklists: { enabled: boolean; }; custom_fields: { enabled: boolean; }; remap_dependencies: { enabled: boolean; }; dependency_warning: { enabled: boolean; }; portfolios: { enabled: boolean; }; }; }> }> { try { return await this.client.get(`/team/${workspaceId}/space`); } catch (error) { console.error('Error getting spaces:', error); throw error; } }