plsreadme_delete
Permanently delete a plsreadme document by providing its document ID or original file path. The admin token is automatically retrieved from your local .plsreadme record.
Instructions
Delete a plsreadme document permanently.
Requires either the document ID or the original file path. Looks up the admin token from the local .plsreadme record file.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "plsreadme_delete"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Document ID to delete. | |
| file_path | No | Original file path (looks up the linked doc). |
Implementation Reference
- packages/mcp/src/index.ts:506-526 (handler)The async handler function that executes the plsreadme_delete tool logic. It looks up a DocRecord by id or file_path, calls apiDelete to delete remotely, and removeRecord to delete locally.
async ({ id, file_path }) => { let record: DocRecord | undefined; if (id) record = getRecordById(id); else if (file_path) record = getRecordBySource(file_path) || getRecordBySource(resolve(process.cwd(), file_path)); if (!record) return formatError('Document not found in .plsreadme records. Provide the correct ID or file path.'); try { await apiDelete(record.id, record.admin_token); removeRecord(record.id); return { content: [{ type: 'text' as const, text: `🗑️ Deleted: ${record.title || record.id}\n\nThe link ${record.url} is no longer accessible.`, }], }; } catch (err) { return formatError((err as Error).message); } } ); - packages/mcp/src/index.ts:495-498 (schema)Input schema for plsreadme_delete: two optional fields (id and file_path) defined using Zod.
{ id: z.string().optional().describe('Document ID to delete.'), file_path: z.string().optional().describe('Original file path (looks up the linked doc).'), }, - packages/mcp/src/index.ts:489-526 (registration)Registration of the 'plsreadme_delete' tool on the McpServer instance via server.tool().
// Tool: Delete a doc server.tool( 'plsreadme_delete', `Delete a plsreadme document permanently. Requires either the document ID or the original file path. Looks up the admin token from the local .plsreadme record file.`, { id: z.string().optional().describe('Document ID to delete.'), file_path: z.string().optional().describe('Original file path (looks up the linked doc).'), }, { title: 'Delete Document', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true, }, async ({ id, file_path }) => { let record: DocRecord | undefined; if (id) record = getRecordById(id); else if (file_path) record = getRecordBySource(file_path) || getRecordBySource(resolve(process.cwd(), file_path)); if (!record) return formatError('Document not found in .plsreadme records. Provide the correct ID or file path.'); try { await apiDelete(record.id, record.admin_token); removeRecord(record.id); return { content: [{ type: 'text' as const, text: `🗑️ Deleted: ${record.title || record.id}\n\nThe link ${record.url} is no longer accessible.`, }], }; } catch (err) { return formatError((err as Error).message); } } ); - packages/mcp/src/index.ts:217-227 (helper)apiDelete helper: sends a DELETE request to the PLSREADME API with the document ID and admin token.
async function apiDelete(id: string, token: string): Promise<void> { const response = await fetch(`${PLSREADME_VIEW}/${id}`, { method: 'DELETE', headers: { Authorization: `Bearer ${token}` }, }); if (!response.ok) { const body = await response.text().catch(() => response.statusText); throw new Error(`Delete failed (HTTP ${response.status}): ${body}`); } } - packages/mcp/src/index.ts:111-115 (helper)removeRecord helper: removes a DocRecord from the local .plsreadme file by filtering out the given ID.
function removeRecord(id: string): void { const filePath = findRecordFile(); const records = loadRecords(filePath).filter((r) => r.id !== id); writeFileSync(filePath, JSON.stringify(records, null, 2) + '\n'); }