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
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to the .svelte component file |
Implementation Reference
- src/tools/svelte.ts:68-108 (handler)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)); } } );