firestore_delete_document
Remove a specific document from a Firestore collection by providing the collection name and document ID.
Instructions
Delete a document from a Firestore collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Collection name | |
| id | Yes | Document ID |
Implementation Reference
- The core handler function that deletes the specified Firestore document and handles errors or missing initialization.export async function deleteDocument(collection: string, id: string) { try { if (!db) { return { content: [{ type: 'text', text: 'Firebase is not initialized. SERVICE_ACCOUNT_KEY_PATH environment variable is required.' }], isError: true }; } await db.collection(collection).doc(id).delete(); return { content: [{ type: 'text', text: 'Document deleted successfully' }] }; } catch (error) { return { content: [{ type: 'text', text: `Error deleting document: ${(error as Error).message}` }], isError: true }; } }
- src/index.ts:163-180 (schema)Defines the input schema for the firestore_delete_document tool, specifying collection and id parameters.{ name: 'firestore_delete_document', description: 'Delete a document from a Firestore collection', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name' }, id: { type: 'string', description: 'Document ID' } }, required: ['collection', 'id'] } },
- src/index.ts:242-243 (registration)Registers the tool handler in the CallToolRequestSchema switch statement by calling the deleteDocument function.case 'firestore_delete_document': return deleteDocument(args.collection as string, args.id as string);
- src/index.ts:163-180 (registration)Registers the tool in the ListToolsRequestSchema response, including name, description, and schema.{ name: 'firestore_delete_document', description: 'Delete a document from a Firestore collection', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name' }, id: { type: 'string', description: 'Document ID' } }, required: ['collection', 'id'] } },