quip_replace_content
Replace markdown content in an existing Quip document by specifying the thread ID and providing new content. Facilitates efficient document updates via the Quip MCP Server.
Instructions
Replace content in an existing Quip document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | New markdown content to replace the document content | |
| threadId | Yes | The Quip document thread ID |
Implementation Reference
- src/index.ts:173-179 (handler)Dispatches the quip_replace_content tool call by validating input parameters (threadId and content) and invoking the shared editDocument method with 'REPLACE' operation.case 'quip_replace_content': { const typedArgs = args as any; if (!typedArgs.threadId || !typedArgs.content) { throw new McpError(ErrorCode.InvalidParams, 'threadId and content are required'); } return await this.editDocument(String(typedArgs.threadId), String(typedArgs.content), 'REPLACE'); }
- src/index.ts:104-117 (schema)Defines the input schema for the quip_replace_content tool, specifying threadId and content as required string parameters.inputSchema: { type: 'object', properties: { threadId: { type: 'string', description: 'The Quip document thread ID' }, content: { type: 'string', description: 'New markdown content to replace the document content' } }, required: ['threadId', 'content'], },
- src/index.ts:101-118 (registration)Registers the quip_replace_content tool in the ListTools response, including its name, description, and input schema.{ name: 'quip_replace_content', description: 'Replace content in an existing Quip document', inputSchema: { type: 'object', properties: { threadId: { type: 'string', description: 'The Quip document thread ID' }, content: { type: 'string', description: 'New markdown content to replace the document content' } }, required: ['threadId', 'content'], }, },
- src/index.ts:235-268 (helper)Shared helper method that performs the actual document editing (including REPLACE operation) by writing content to a temp file and executing the quip_edit.py Python script with the specified operation.private async editDocument(threadId: string, content: string, operation: string) { try { console.log(`Editing document ${threadId} with operation ${operation}...`); // Create a temporary file to store the content const tempFilePath = `/tmp/quip_content_${Date.now()}.md`; const writeCommand = `echo "${content.replace(/"/g, '\\"')}" > ${tempFilePath}`; await execAsync(writeCommand); // Execute the Python script to edit the document const command = `python -u ${path.join(SCRIPTS_DIR, 'quip_edit.py')} ${threadId} ${operation.toLowerCase()} ${tempFilePath}`; const { stdout, stderr } = await execAsync(command); // Clean up the temporary file await execAsync(`rm ${tempFilePath}`); if (stderr) { console.error(`Error editing document: ${stderr}`); throw new Error(stderr); } return { content: [ { type: 'text', text: stdout || `Successfully ${operation.toLowerCase()}ed content to document ${threadId}`, }, ], }; } catch (error) { console.error(`Error ${operation.toLowerCase()}ing document:`, error); throw error; } }