search_nodes
Search Workflowy nodes using a query to identify matching items, helping locate relevant content within your list.
Instructions
Search nodes in Workflowy
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find matching nodes |
Implementation Reference
- src/tools/workflowy.ts:53-70 (handler)The handler function for the search_nodes tool. Accepts a query string and credentials, delegates to workflowyClient.search(), and returns the results as JSON text content.
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:43-45 (schema)Input schema for search_nodes: requires a 'query' string parameter.
inputSchema: { query: z.string().describe("Search query to find matching nodes") }, - src/tools/index.ts:12-21 (registration)The registerTools function iterates over toolRegistry (which includes search_nodes via spread from workflowyTools) and registers each with FastMCP server using its name, description, parameters, annotations, and execute handler.
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/workflowy/client.ts:78-96 (helper)The search helper method on WorkflowyClient. Authenticates, fetches the document, then performs a DFS traversal of all nodes, collecting those whose name (case-insensitive) includes the query string.
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 }