Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesSearch query for the symbol name
pathFilterNoOptional path filter (case-insensitive substring match)
filterNoOptional regex filter on symbol names
limitNoMax results to return. Default: 50

Implementation Reference

  • 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"),
        }),
      },
  • 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}'`;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/adainrivers/SvelteLS.MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server