Skip to main content
Glama

get_file_references

Find all files that reference or import a specific file in Svelte projects. Use this tool to track dependencies and understand file relationships during development.

Instructions

Find all files that reference/import the specified file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file

Implementation Reference

  • The tool "get_file_references" is registered and handled within the `registerSvelteTools` function in `src/tools/svelte.ts`. It takes a `filePath` input, converts it to a URI, and makes an LSP request to `$/getFileReferences`.
    server.registerTool(
      "get_file_references",
      {
        title: "Get File References",
        description:
          "Find all files that reference/import the specified file.",
        inputSchema: z.object({
          filePath: z.string().describe("Absolute path to the file"),
        }),
      },
      async ({ filePath }): Promise<ToolResult> => {
        try {
          const uri = pathToUri(filePath);
    
          const result = await lsp.request("$/getFileReferences", uri);
    
          if (!result || !Array.isArray(result) || result.length === 0) {
            return textResult(
              `No references found for ${basename(filePath)}.`
            );
          }
    
          return textResult(formatLocations(result, "file reference"));
        } catch (ex) {
          if (
            String(ex).includes("Unhandled method") ||
            String(ex).includes("not supported")
          ) {
            return textResult(
              "$/getFileReferences is not supported by this version of svelteserver."
            );
          }
          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