Skip to main content
Glama

find_references

Locate all instances of a Svelte symbol across your project workspace to track usage and support refactoring tasks.

Instructions

Find all references to a symbol across the workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file
symbolNameYesName of the symbol to find
symbolKindNoKind of symbol
includeDeclarationNoInclude the declaration itself

Implementation Reference

  • The "find_references" tool registration and handler implementation.
    server.registerTool(
      "find_references",
      {
        title: "Find References",
        description: "Find all references to a symbol across the workspace.",
        inputSchema: z.object({
          filePath: z.string().describe("Absolute path to the file"),
          symbolName: z.string().describe("Name of the symbol to find"),
          symbolKind: z.string().optional().describe("Kind of symbol"),
          includeDeclaration: z
            .boolean()
            .default(true)
            .describe("Include the declaration itself"),
        }),
      },
      async ({
        filePath,
        symbolName,
        symbolKind,
        includeDeclaration,
      }): Promise<ToolResult> => {
        try {
          const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind);
          if ("error" in prep) return textResult(prep.error);
    
          const params = {
            ...makePositionParams(prep.ctx),
            context: { includeDeclaration },
          };
          const result = await lsp.request("textDocument/references", params);
          return textResult(formatLocations(result, "reference"));
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );

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