search_nodes
Find specific nodes in Workflowy by entering search queries to locate relevant content quickly.
Instructions
Search nodes in Workflowy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find matching nodes |
Implementation Reference
- src/tools/workflowy.ts:51-68 (handler)MCP tool handler for 'search_nodes'. Calls workflowyClient.search and returns JSON results or error message.handler: async ({ query, username, password }: { query: string, username?: string, password?: string }, client: typeof workflowyClient) => { try { const items = await workflowyClient.search(query, username, password); return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error searching nodes: ${error.message}` }] }; } }
- src/tools/workflowy.ts:41-43 (schema)Input schema for search_nodes tool defining the 'query' parameter.inputSchema: { query: z.string().describe("Search query to find matching nodes") },
- src/workflowy/client.ts:55-73 (helper)Core implementation of node search using stack-based traversal of the Workflowy document tree to find matching node names.async search(query: string, username?: string, password?: string) { const { wf } = await this.createAuthenticatedClient(username, password); const t = await wf.getDocument(); const items = t.root.items; let results = []; let stack = [...t.root.items]; while (stack.length > 0) { const current = stack.pop(); if (current!.name.toLowerCase().includes(query.toLowerCase())) { results.push(current!.toJson()); } if (current!.items) { stack.push(...current!.items); } } // need to traverse the tree to find all items return results }
- src/tools/index.ts:12-22 (registration)Function that registers all tools from toolRegistry (including search_nodes) with the MCP server.export function registerTools(server: FastMCP): void { Object.entries(toolRegistry).forEach(([name, tool]) => { server.addTool({ name, description: tool.description, parameters: z.object(tool.inputSchema), annotations: tool.annotations, execute: tool.handler }); }); }
- src/index.ts:14-14 (registration)Invokes tool registration for the MCP server startup.registerTools(server);