toggle_complete
Mark a node as complete or incomplete in mcp-workflowy by specifying its ID and desired completion status.
Instructions
Toggle completion status of a node
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | ID of the node to toggle completion status | |
| completed | Yes | Whether the node should be marked as complete (true) or incomplete (false) |
Implementation Reference
- src/tools/workflowy.ts:172-198 (registration)Registration of the toggle_complete tool, including input schema (nodeId: string, completed: boolean) and handler that wraps the client call with error handling and response formatting.toggle_complete: { description: "Toggle completion status of a node", inputSchema: { nodeId: z.string().describe("ID of the node to toggle completion status"), completed: z.boolean().describe("Whether the node should be marked as complete (true) or incomplete (false)") }, handler: async ({ nodeId, completed, username, password }: { nodeId: string, completed: boolean, username?: string, password?: string }, client: typeof workflowyClient) => { try { await workflowyClient.toggleComplete(nodeId, completed, username, password); return { content: [{ type: "text", text: `Successfully ${completed ? "completed" : "uncompleted"} node ${nodeId}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error toggling completion status: ${error.message}` }] }; } } }
- src/workflowy/client.ts:141-159 (handler)Core implementation of toggleComplete in WorkflowyClient class: authenticates, finds the node by ID, sets completed status using Workflowy API, and saves changes if dirty.async toggleComplete(nodeId: string, completed: boolean, username?: string, password?: string) { const { wf } = await this.createAuthenticatedClient(username, password); const doc = await wf.getDocument(); const node = doc.root.items.find(item => item.id === nodeId); if (!node) { throw new Error(`Node with ID ${nodeId} not found.`); } if (completed) { await node.setCompleted(); } else { await node.setCompleted(false); } if (doc.isDirty()) { // Saves the changes if there are any await doc.save(); } }