get_docs_from_workspace
Retrieve all documents from a ClickUp workspace with support for pagination and filtering by deleted or archived status.
Instructions
Get all docs from a ClickUp workspace. Supports pagination and filtering for deleted/archived docs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | Yes | The ID of the workspace to get docs from | |
| cursor | No | Cursor for pagination | |
| deleted | No | Whether to include deleted docs | |
| archived | No | Whether to include archived docs | |
| limit | No | The maximum number of docs to return |
Implementation Reference
- src/tools/doc-tools.ts:76-108 (handler)The tool handler for 'get_docs_from_workspace'. Registers an MCP tool with zod schema for workspace_id (required), and optional cursor, deleted, archived, limit parameters. Calls docsClient.getDocsFromWorkspace() and returns JSON.stringify'd docs.
// Register get_docs_from_workspace tool server.tool( 'get_docs_from_workspace', 'Get all docs from a ClickUp workspace. Supports pagination and filtering for deleted/archived docs.', { workspace_id: z.string().describe('The ID of the workspace to get docs from'), cursor: z.string().optional().describe('Cursor for pagination'), deleted: z.boolean().optional().describe('Whether to include deleted docs'), archived: z.boolean().optional().describe('Whether to include archived docs'), limit: z.number().optional().describe('The maximum number of docs to return') }, async ({ workspace_id, cursor, deleted, archived, limit }) => { try { // Get docs from the workspace const result = await docsClient.getDocsFromWorkspace(workspace_id, { cursor, deleted: deleted !== undefined ? deleted : false, archived: archived !== undefined ? archived : false, limit: limit || 50 }); return { content: [{ type: 'text', text: JSON.stringify(result.docs, null, 2) }] }; } catch (error: any) { console.error('Error getting docs from workspace:', error); return { content: [{ type: 'text', text: `Error getting docs from workspace: ${error.message}` }], isError: true }; } } ); - src/tools/doc-tools.ts:77-86 (schema)Input validation schema for get_docs_from_workspace using zod: workspace_id (string, required), cursor (optional string), deleted (optional boolean), archived (optional boolean), limit (optional number).
server.tool( 'get_docs_from_workspace', 'Get all docs from a ClickUp workspace. Supports pagination and filtering for deleted/archived docs.', { workspace_id: z.string().describe('The ID of the workspace to get docs from'), cursor: z.string().optional().describe('Cursor for pagination'), deleted: z.boolean().optional().describe('Whether to include deleted docs'), archived: z.boolean().optional().describe('Whether to include archived docs'), limit: z.number().optional().describe('The maximum number of docs to return') }, - src/tools/doc-tools.ts:12-136 (registration)The setupDocTools() function that registers all doc tools (including get_docs_from_workspace) on the MCP server via server.tool(). Called from src/index.ts line 43.
export function setupDocTools(server: McpServer): void { // Register get_doc_content tool server.tool( 'get_doc_content', 'Get the content of a specific ClickUp doc. Returns combined content from all pages in the doc.', { doc_id: z.string().describe('The ID of the doc to get'), workspace_id: z.string().describe('The ID of the workspace containing the doc') }, async ({ doc_id, workspace_id }) => { try { // Get the pages of the doc const pages = await docsClient.getDocPages(workspace_id, doc_id); // Combine the content of all pages let combinedContent = ''; if (Array.isArray(pages)) { for (const page of pages) { if (page.content) { combinedContent += page.content + '\n\n'; } } } return { content: [{ type: 'text', text: combinedContent || 'No content found in this doc.' }] }; } catch (error: any) { console.error('Error getting doc content:', error); return { content: [{ type: 'text', text: `Error getting doc content: ${error.message}` }], isError: true }; } } ); // Register search_docs tool server.tool( 'search_docs', 'Search for docs in a ClickUp workspace using a query string. Returns matching docs with their metadata.', { workspace_id: z.string().describe('The ID of the workspace to search in'), query: z.string().describe('The search query'), cursor: z.string().optional().describe('Cursor for pagination') }, async ({ workspace_id, query, cursor }) => { try { // Search for docs in the workspace const result = await docsClient.searchDocs(workspace_id, { query, cursor }); return { content: [{ type: 'text', text: JSON.stringify(result.docs, null, 2) }] }; } catch (error: any) { console.error('Error searching docs:', error); return { content: [{ type: 'text', text: `Error searching docs: ${error.message}` }], isError: true }; } } ); // Register get_docs_from_workspace tool server.tool( 'get_docs_from_workspace', 'Get all docs from a ClickUp workspace. Supports pagination and filtering for deleted/archived docs.', { workspace_id: z.string().describe('The ID of the workspace to get docs from'), cursor: z.string().optional().describe('Cursor for pagination'), deleted: z.boolean().optional().describe('Whether to include deleted docs'), archived: z.boolean().optional().describe('Whether to include archived docs'), limit: z.number().optional().describe('The maximum number of docs to return') }, async ({ workspace_id, cursor, deleted, archived, limit }) => { try { // Get docs from the workspace const result = await docsClient.getDocsFromWorkspace(workspace_id, { cursor, deleted: deleted !== undefined ? deleted : false, archived: archived !== undefined ? archived : false, limit: limit || 50 }); return { content: [{ type: 'text', text: JSON.stringify(result.docs, null, 2) }] }; } catch (error: any) { console.error('Error getting docs from workspace:', error); return { content: [{ type: 'text', text: `Error getting docs from workspace: ${error.message}` }], isError: true }; } } ); // Register get_doc_pages tool server.tool( 'get_doc_pages', 'Get the pages of a specific ClickUp doc. Returns page content in the requested format (markdown or plain text).', { doc_id: z.string().describe('The ID of the doc to get pages from'), workspace_id: z.string().describe('The ID of the workspace containing the doc'), content_format: z.enum(['text/md', 'text/plain']).optional().describe('The format to return the content in') }, async ({ doc_id, workspace_id, content_format }) => { try { // Get the pages of the doc const pages = await docsClient.getDocPages(workspace_id, doc_id, content_format); return { content: [{ type: 'text', text: JSON.stringify(pages, null, 2) }] }; } catch (error: any) { console.error('Error getting doc pages:', error); return { content: [{ type: 'text', text: `Error getting doc pages: ${error.message}` }], isError: true }; } } ); } - src/clickup-client/docs.ts:47-70 (helper)The DocsClient.getDocsFromWorkspace() method that makes the actual HTTP GET request to the ClickUp API v3 endpoint (workspaces/{workspaceId}/docs) with optional query parameters (cursor, deleted, archived, limit).
async getDocsFromWorkspace(workspaceId: string, params?: GetDocsParams): Promise<{ docs: Doc[], next_cursor: string }> { // Get the API token directly from the environment variable const apiToken = process.env.CLICKUP_API_TOKEN; try { const url = `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`; // Use the exact same headers that worked in the successful request const headers = { 'Authorization': apiToken, 'Accept': 'application/json' }; const response = await axios.get(url, { headers, params }); return response.data; } catch (error) { console.error('Error getting docs:', error); throw error; } } - src/clickup-client/docs.ts:22-27 (schema)The GetDocsParams interface defining optional parameters: cursor (string), deleted (boolean), archived (boolean), limit (number).
export interface GetDocsParams { cursor?: string; deleted?: boolean; archived?: boolean; limit?: number; }