find_definition
Locate symbol definitions in Svelte files to navigate code structure and understand component relationships during development.
Instructions
Find the definition of a symbol by name in a file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to the file | |
| symbolName | Yes | Name of the symbol to find | |
| symbolKind | No | Kind of symbol: class, method, property, field, interface, enum, function, variable, etc. |
Implementation Reference
- src/tools/navigation.ts:35-48 (handler)Handler for the "find_definition" tool. It uses prepareSymbolRequest to locate the symbol and then makes an LSP request for "textDocument/definition".
async ({ filePath, symbolName, symbolKind }): Promise<ToolResult> => { try { const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind); if ("error" in prep) return textResult(prep.error); const result = await lsp.request( "textDocument/definition", makePositionParams(prep.ctx) ); return textResult(formatLocations(result, "definition")); } catch (ex) { return textResult(formatError(ex)); } } - src/tools/navigation.ts:19-34 (registration)Registration of the "find_definition" tool, including its title, description, and input schema.
server.registerTool( "find_definition", { title: "Find Definition", description: "Find the definition of a symbol by name in a file.", 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: class, method, property, field, interface, enum, function, variable, etc." ), }), },