get_doc_pages
Retrieve pages from a ClickUp doc in markdown or plain text. Provide the doc and workspace IDs to get the content.
Instructions
Get the pages of a specific ClickUp doc. Returns page content in the requested format (markdown or plain text).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | The ID of the doc to get pages from | |
| workspace_id | Yes | The ID of the workspace containing the doc | |
| content_format | No | The format to return the content in |
Implementation Reference
- src/tools/doc-tools.ts:110-135 (handler)The get_doc_pages tool handler - calls docsClient.getDocPages() and returns JSON-stringified pages array.
// 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/index.ts:40-47 (registration)setupDocTools is called from the main server's setupTools() to register all doc tools including get_doc_pages.
private setupTools() { // Set up all tools setupTaskTools(this.server); setupDocTools(this.server); setupSpaceTools(this.server); setupChecklistTools(this.server); setupCommentTools(this.server); } - src/tools/doc-tools.ts:114-118 (schema)Zod schema for get_doc_pages input parameters: doc_id, workspace_id (required), and content_format (optional, enum).
{ 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') }, - src/clickup-client/docs.ts:80-109 (helper)Helper method DocsClient.getDocPages() that makes the actual ClickUp API v3 call to GET /workspaces/{workspaceId}/docs/{docId}/pages.
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; } }