Skip to main content
Glama

get_component_references

Find all files that import or use a specific Svelte component to track dependencies and analyze component usage across your project.

Instructions

Find all files that use/import a Svelte component.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the .svelte component file

Implementation Reference

  • The implementation and registration of the 'get_component_references' tool. The handler function calls the LSP server method '$/getComponentReferences'.
    server.registerTool(
      "get_component_references",
      {
        title: "Get Component References",
        description:
          "Find all files that use/import a Svelte component.",
        inputSchema: z.object({
          filePath: z
            .string()
            .describe("Absolute path to the .svelte component file"),
        }),
      },
      async ({ filePath }): Promise<ToolResult> => {
        try {
          const uri = pathToUri(filePath);
    
          const result = await lsp.request("$/getComponentReferences", uri);
    
          if (!result || !Array.isArray(result) || result.length === 0) {
            return textResult(
              `No references found for component ${basename(filePath)}.`
            );
          }
    
          return textResult(
            formatLocations(result, "component reference")
          );
        } catch (ex) {
          // This endpoint may not be available
          if (
            String(ex).includes("Unhandled method") ||
            String(ex).includes("not supported")
          ) {
            return textResult(
              "$/getComponentReferences 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