find_workspace_symbols
Search for Svelte symbols across your entire workspace to quickly locate components, functions, and variables. Filter results by path or regex to find specific code elements.
Instructions
Search for symbols across the entire workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for the symbol name | |
| pathFilter | No | Optional path filter (case-insensitive substring match) | |
| filter | No | Optional regex filter on symbol names | |
| limit | No | Max results to return. Default: 50 |
Implementation Reference
- src/tools/navigation.ts:233-256 (registration)Tool registration for "find_workspace_symbols" in src/tools/navigation.ts.
server.registerTool( "find_workspace_symbols", { title: "Find Workspace Symbols", description: "Search for symbols across the entire workspace.", inputSchema: z.object({ query: z.string().describe("Search query for the symbol name"), pathFilter: z .string() .optional() .describe( "Optional path filter (case-insensitive substring match)" ), filter: z .string() .optional() .describe("Optional regex filter on symbol names"), limit: z .number() .default(50) .describe("Max results to return. Default: 50"), }), }, - src/tools/navigation.ts:257-310 (handler)Handler implementation for "find_workspace_symbols" in src/tools/navigation.ts.
async ({ query, pathFilter, filter, limit }): Promise<ToolResult> => { try { const result = await lsp.request("workspace/symbol", { query }); if (!Array.isArray(result) || result.length === 0) { return textResult(`No symbols matching '${query}' found.`); } const filterRegex = filter ? new RegExp(filter, "i") : null; const lines: string[] = []; let shown = 0; let matched = 0; let total = 0; for (const sym of result) { const name = sym.name ?? "?"; const kind = symbolKindName(sym.kind ?? 0); const container = sym.containerName ?? ""; const loc = sym.location; const path = loc?.uri ? uriToPath(loc.uri) : "?"; const line = (loc?.range?.start?.line ?? 0) + 1; if ( pathFilter && !path.toLowerCase().includes(pathFilter.toLowerCase()) ) continue; total++; if (filterRegex && !filterRegex.test(name)) continue; matched++; if (shown >= limit) continue; const containerSuffix = container.length > 0 ? ` [${container}]` : ""; lines.push(` ${name} (${kind})${containerSuffix} - ${path}:${line}`); shown++; } if (shown === 0) { return textResult( `No symbols matching '${query}' found` + (filter ? ` with filter '${filter}'` : "") + (pathFilter ? ` in paths matching '${pathFilter}'` : "") + "." ); } let header = "Found "; if (filter) { header += shown < matched ? `${shown} of ${matched} symbol(s) matching '${filter}'` : `${matched} symbol(s) matching '${filter}'`;