delete_document
Remove a collaborative document from the Tiptap Collaboration MCP Server by specifying its unique ID, streamlining document management and cleanup processes.
Instructions
Delete a collaborative document
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the document to delete |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "ID of the document to delete",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/delete-document.ts:15-70 (handler)The asynchronous handler function that executes the deletion of the document by making a DELETE HTTP request to the `/api/documents/${id}` endpoint, handling errors and returning markdown content responses.async ({ id }) => { try { const headers: Record<string, string> = { 'User-Agent': 'tiptap-collaboration-mcp', 'Content-Type': 'application/json', }; const token = getToken(); if (token) headers['Authorization'] = token; const response = await fetch(`${getBaseUrl()}/api/documents/${id}`, { method: 'DELETE', headers, }); if (!response.ok) { if (response.status === 404) { return { content: [ { type: 'text', text: `Document with ID ${id} not found.`, }, ], }; } return { content: [ { type: 'text', text: `Failed to delete document. HTTP error: ${response.status} ${response.statusText}`, }, ], }; } return { content: [ { type: 'text', text: `Document with ID ${id} deleted successfully.`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error deleting document: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; }
- src/tools/delete-document.ts:12-14 (schema)Zod input schema defining the required 'id' parameter as a string for the document to delete.{ id: z.string().describe('ID of the document to delete'), },
- src/tools/delete-document.ts:4-73 (registration)The registration function that adds the 'delete-document' tool to the MCP server, including name, description, schema, and handler.export default function registerDeleteDocument( server: McpServer, getBaseUrl: () => string, getToken: () => string | undefined ) { server.tool( 'delete-document', 'Delete a collaborative document', { id: z.string().describe('ID of the document to delete'), }, async ({ id }) => { try { const headers: Record<string, string> = { 'User-Agent': 'tiptap-collaboration-mcp', 'Content-Type': 'application/json', }; const token = getToken(); if (token) headers['Authorization'] = token; const response = await fetch(`${getBaseUrl()}/api/documents/${id}`, { method: 'DELETE', headers, }); if (!response.ok) { if (response.status === 404) { return { content: [ { type: 'text', text: `Document with ID ${id} not found.`, }, ], }; } return { content: [ { type: 'text', text: `Failed to delete document. HTTP error: ${response.status} ${response.statusText}`, }, ], }; } return { content: [ { type: 'text', text: `Document with ID ${id} deleted successfully.`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error deleting document: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } } ); }
- src/server.ts:48-48 (registration)Invocation of the registerDeleteDocument function to register the tool on the main MCP server instance.registerDeleteDocument(server, getBaseUrl, getToken);