Skip to main content
Glama

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
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file
symbolNameYesName of the symbol to find
symbolKindNoKind of symbol: class, method, property, field, interface, enum, function, variable, etc.

Implementation Reference

  • 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));
      }
    }
  • 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."
            ),
        }),
      },

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