Delete Organize Link
delete_organize_linkDelete an organize doc, tag, or collection link in an AFFiNE workspace by providing the node ID. Use to remove unwanted connections.
Instructions
Experimental: delete an AFFiNE organize doc/tag/collection link.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspaceId | No | ||
| nodeId | Yes |
Implementation Reference
- src/tools/organize.ts:1454-1477 (handler)The handler function for delete_organize_link. It resolves the workspace, loads the folders doc, looks up the node by ID, ensures it's not a folder (i.e., it's a link), marks it as deleted via deleteRecord, saves the doc, and returns success.
const deleteOrganizeLinkHandler = async ({ workspaceId, nodeId, }: { workspaceId?: string; nodeId: string; }) => { const resolvedWorkspaceId = requireWorkspaceId(workspaceId); const { socket } = await getSocketContext(); try { await joinWorkspace(socket, resolvedWorkspaceId); const { docId, doc } = await loadFoldersDoc(socket, resolvedWorkspaceId); const nodeMap = organizeNodeMap(readOrganizeNodes(doc)); const node = nodeMap.get(nodeId); if (!node || node.type === "folder") { throw new Error(`Organize link '${nodeId}' was not found.`); } deleteRecord(ensureRecord(doc, nodeId)); await saveFoldersDoc(socket, resolvedWorkspaceId, docId, doc); return text({ success: true, nodeId }); } finally { socket.disconnect(); } }; - src/tools/organize.ts:1479-1490 (registration)Registration of the 'delete_organize_link' tool on the MCP server with its title, description, and input schema (workspaceId optional, nodeId required).
server.registerTool( "delete_organize_link", { title: "Delete Organize Link", description: "Experimental: delete an AFFiNE organize doc/tag/collection link.", inputSchema: { workspaceId: WorkspaceId.optional(), nodeId: OrganizeNodeId, }, }, deleteOrganizeLinkHandler as any ); - src/tools/organize.ts:1484-1487 (schema)Input schema for delete_organize_link: workspaceId (optional) and nodeId (OrganizeNodeId).
inputSchema: { workspaceId: WorkspaceId.optional(), nodeId: OrganizeNodeId, }, - src/tools/organize.ts:196-205 (helper)The deleteRecord helper function used by deleteOrganizeLinkHandler to mark a Y.Map record as deleted (sets $$DELETED flag, removes keys except 'id').
function deleteRecord(record: Y.Map<any>, keepId = true): void { const keys = Array.from(record.keys()); for (const key of keys) { if (keepId && key === "id") { continue; } record.delete(key); } record.set("$$DELETED", true); } - src/toolSurface.ts:31-32 (registration)Listing of delete_organize_link in the tool surface authority list, and its associated scopes/capabilities.
"delete_organize_link", "delete_surface_element",