get_doc_content
Retrieve the full content of a ClickUp document by specifying the document ID and workspace. Returns combined text from all pages.
Instructions
Get the content of a specific ClickUp doc. Returns combined content from all pages in the doc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | The ID of the doc to get | |
| workspace_id | Yes | The ID of the workspace containing the doc |
Implementation Reference
- src/tools/doc-tools.ts:21-46 (handler)The main handler function for the get_doc_content tool. Calls docsClient.getDocPages() to retrieve pages, then combines their content into a single text output.
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 }; } } - src/tools/doc-tools.ts:13-47 (registration)Registration of the get_doc_content tool using server.tool() with Zod schema for doc_id and workspace_id parameters.
// 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 }; } } ); - src/tools/doc-tools.ts:17-20 (schema)Input schema for get_doc_content tool: doc_id (string) and workspace_id (string) using Zod validation.
{ 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') }, - src/clickup-client/docs.ts:80-109 (helper)The getDocPages() method on DocsClient that makes the actual v3 API call to fetch doc pages from ClickUp.
async getDocPages(workspaceId: string, docId: string, contentFormat: string = 'text/md'): Promise<any> { // 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/${docId}/pages`; // Use the exact same parameters that worked in the successful request const params = { max_page_depth: -1, content_format: contentFormat }; // 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 doc pages:', error); throw error; } }