Skip to main content
Glama

get_workspace_hierarchy

Retrieve the complete workspace structure including spaces, folders, and lists to understand ClickUp organization and relationships.

Instructions

Get the complete workspace hierarchy including spaces, folders, and lists.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main tool handler that calls the workspace service to get the hierarchy and formats the response as a text tree.
    export async function handleGetWorkspaceHierarchy() { try { // Get workspace hierarchy from the workspace service const hierarchy = await workspaceService.getWorkspaceHierarchy(); const response = formatHierarchyResponse(hierarchy); return response; } catch (error: any) { return { content: [ { type: "text", text: `Error getting workspace hierarchy: ${error.message}` } ] }; } }
  • Tool schema defining the get_workspace_hierarchy tool with no input parameters.
    export const workspaceHierarchyTool: Tool = { name: 'get_workspace_hierarchy', description: 'Get the complete workspace hierarchy including spaces, folders, and lists.', inputSchema: { type: 'object', properties: {} } };
  • src/server.ts:100-101 (registration)
    Dispatch registration in the CallToolRequestHandler switch statement.
    case "get_workspace_hierarchy": return handleGetWorkspaceHierarchy();
  • src/server.ts:67-92 (registration)
    Tool list registration including get_workspace_hierarchy in ListToolsRequestHandler. Note: excerpt abbreviated.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ workspaceHierarchyTool, createTaskTool, getTaskTool, getTasksTool, updateTaskTool, moveTaskTool, duplicateTaskTool, deleteTaskTool, createBulkTasksTool, updateBulkTasksTool, moveBulkTasksTool, deleteBulkTasksTool, createListTool, createListInFolderTool, getListTool, updateListTool, deleteListTool, createFolderTool, getFolderTool, updateFolderTool, deleteFolderTool ] };
  • Core helper service method that retrieves and constructs the workspace hierarchy tree from ClickUp API endpoints.
    async getWorkspaceHierarchy(forceRefresh = false): Promise<WorkspaceTree> { try { // If we have the hierarchy in memory and not forcing refresh, return it if (this.workspaceHierarchy && !forceRefresh) { return this.workspaceHierarchy; } // Start building the workspace tree const workspaceTree: WorkspaceTree = { root: { id: this.teamId, name: 'Workspace', children: [] } }; // Get all spaces const spaces = await this.getSpaces(); // Process each space for (const space of spaces) { const spaceNode: WorkspaceNode = { id: space.id, name: space.name, type: 'space', children: [] }; // Get folders for the space const folders = await this.getFoldersInSpace(space.id); for (const folder of folders) { const folderNode: WorkspaceNode = { id: folder.id, name: folder.name, type: 'folder', parentId: space.id, children: [] }; // Get lists in the folder const listsInFolder = await this.getListsInFolder(folder.id); for (const list of listsInFolder) { folderNode.children?.push({ id: list.id, name: list.name, type: 'list', parentId: folder.id }); } spaceNode.children?.push(folderNode); } // Get lists directly in the space (not in any folder) const listsInSpace = await this.getListsInSpace(space.id); for (const list of listsInSpace) { spaceNode.children?.push({ id: list.id, name: list.name, type: 'list', parentId: space.id }); } workspaceTree.root.children.push(spaceNode); } // Store the hierarchy for later use this.workspaceHierarchy = workspaceTree; return workspaceTree; } catch (error) { throw this.handleError(error, 'Failed to get workspace hierarchy'); } }

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/windalfin/clickup-mcp-server'

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