Skip to main content
Glama

find_document_symbols

Lists all symbols defined in a Svelte file to enable quick navigation and analysis of components, functions, and variables.

Instructions

List all symbols defined in a file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file

Implementation Reference

  • The handler function that retrieves document symbols using the LSP client.
      async ({ filePath }): Promise<ToolResult> => {
        try {
          const prep = await prepareDocumentRequest(lsp, filePath);
          if ("error" in prep) return textResult(prep.error);
    
          const result = await lsp.request("textDocument/documentSymbol", {
            textDocument: { uri: prep.uri },
          });
    
          if (!Array.isArray(result) || result.length === 0) {
            return textResult("No symbols found.");
          }
    
          return textResult(formatSymbolTree(result));
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );
  • Registration of the 'find_document_symbols' tool within the navigation tools module.
    server.registerTool(
      "find_document_symbols",
      {
        title: "Find Document Symbols",
        description: "List all symbols defined in a file.",
        inputSchema: z.object({
          filePath: z.string().describe("Absolute path to the file"),
        }),
      },

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