quip_read_document
Retrieve the content of a Quip document using its thread ID, enabling direct access to data for analysis or integration via the Quip MCP Server.
Instructions
Read the content of a Quip document by its thread ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| threadId | Yes | The Quip document thread ID |
Implementation Reference
- src/index.ts:51-64 (registration)Registration of the 'quip_read_document' tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'quip_read_document', description: 'Read the content of a Quip document by its thread ID', inputSchema: { type: 'object', properties: { threadId: { type: 'string', description: 'The Quip document thread ID' } }, required: ['threadId'], }, },
- src/index.ts:152-158 (handler)Dispatch handler in CallToolRequestSchema switch statement that validates input and delegates to readDocument method.case 'quip_read_document': { const typedArgs = args as any; if (!typedArgs.threadId) { throw new McpError(ErrorCode.InvalidParams, 'threadId is required'); } return await this.readDocument(String(typedArgs.threadId)); }
- src/index.ts:208-233 (handler)Core handler function for quip_read_document tool. Executes the quip_edit.py Python script with 'read' operation to fetch and return the document content.private async readDocument(threadId: string) { try { console.log(`Reading document ${threadId}...`); // Execute the Python script to read the document const command = `python -u ${path.join(SCRIPTS_DIR, 'quip_edit.py')} ${threadId} read`; const { stdout, stderr } = await execAsync(command); if (stderr) { console.error(`Error reading document: ${stderr}`); throw new Error(stderr); } return { content: [ { type: 'text', text: stdout || 'Document read successfully, but no content was returned', }, ], }; } catch (error) { console.error('Error reading document:', error); throw error; } }
- scripts/quip_edit.py:48-73 (helper)Python helper function implementing the actual Quip document reading logic using QuipClient.get_thread() to retrieve HTML content.def read_document(client, thread_id): """Read the content of an existing Quip document""" logger.info(f"Attempting to read document with thread_id: {thread_id}") try: # Get thread data thread = client.get_thread(thread_id) logger.debug(f"Thread data: {thread}") # Extract HTML content if 'html' in thread: html_content = thread['html'] logger.info(f"Successfully retrieved HTML content ({len(html_content)} characters)") return thread else: # Try alternative approach - get_blob logger.info("HTML not found in thread data, trying get_blob...") blob = client.get_blob(thread_id) logger.debug(f"Blob data: {blob}") return {"blob": blob} except Exception as e: logger.error(f"Error reading document: {str(e)}") logger.error("Traceback:", exc_info=True) raise
- src/index.ts:54-63 (schema)Input schema definition for the quip_read_document tool, specifying the required threadId parameter.inputSchema: { type: 'object', properties: { threadId: { type: 'string', description: 'The Quip document thread ID' } }, required: ['threadId'], },