Skip to main content
Glama

Find Document Symbols

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"),
        }),
      },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'List all symbols' but doesn't specify what constitutes a 'symbol' (e.g., functions, variables, classes), the format or structure of the output, whether it's paginated, or any error conditions (e.g., invalid file paths). This leaves significant gaps for a tool that likely interacts with code analysis.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It front-loads the core action ('List all symbols') and resource ('in a file'), making it easy to parse quickly. Every part of the sentence earns its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of code analysis tools and the lack of annotations or output schema, the description is incomplete. It doesn't explain what 'symbols' include, the output format, or error handling, which are critical for an AI agent to use this tool effectively. The schema covers the input, but behavioral and output details are missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'filePath' clearly documented as an 'Absolute path to the file'. The description adds no additional meaning beyond this, such as examples of valid paths or file type constraints. This meets the baseline of 3 since the schema adequately covers the parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and the resource 'all symbols defined in a file', which is specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'find_workspace_symbols' (which likely searches across multiple files) or 'find_definition' (which likely finds a specific symbol's definition), leaving some ambiguity about when this exact tool is preferred.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'find_workspace_symbols' (for broader searches) and 'find_definition' (for specific symbols), the agent must infer usage based on the name alone. No explicit context, exclusions, or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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