Skip to main content
Glama

find_symbol

Search for symbols by name across Godot projects using LSP for accuracy or regex as fallback, filtering by type and limiting results.

Instructions

Find symbols by name across the project. Uses LSP when available, regex parser as fallback. Results include a metadata.source field indicating whether LSP or regex was used. Report whether results came from LSP or regex fallback, as LSP provides more accurate signatures and locations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSymbol name to search for (substring match)
typeNoSymbol type to filter byany
maxResultsNoMaximum results to return

Implementation Reference

  • The handler for the `find_symbol` tool, which attempts an LSP workspace symbol search first and falls back to a script index search if LSP is unavailable.
    handler: async (ctx) => {
      const { name, type = "any", maxResults = 50 } = ctx.args;
      const lsp = getLspClient();
    
      // Try LSP workspace symbol search first
      if (lsp?.connected) {
        try {
          const symbols = await lsp.workspaceSymbol(name);
          let filtered = symbols;
          if (type !== "any") {
            filtered = symbols.filter((s) => matchesTypeFilter(s.kind, type));
          }
    
          const data = filtered.slice(0, maxResults).map((s) => ({
            name: s.name,
            kind: symbolKindName(s.kind),
            file: s.location.uri.replace("file://", ""),
            line: s.location.range.start.line + 1,
            container: s.containerName,
          }));
    
          return makeTextResponse({
            data,
            truncated: filtered.length > maxResults,
            totalCount: filtered.length,
            metadata: { source: "lsp" },
          });
        } catch {
          // Fall through to fallback
        }
      }
    
      // Fallback: search script index
      const results: Array<{
        name: string;
        kind: string;
        file: string;
        line: number;
      }> = [];
    
      const matchesFilter = (kind: string): boolean => type === "any" || type === kind;
    
      for (const [path, script] of await index.scriptIndex.all()) {
        // Collect symbol arrays with their kinds for uniform iteration
        const symbolSources: Array<{
          kind: string;
          items: Array<{ name: string; line: number }>;
        }> = [];
        if (matchesFilter("function"))
          symbolSources.push({ kind: "function", items: script.functions });
        if (matchesFilter("signal"))
          symbolSources.push({ kind: "signal", items: script.signals });
        if (matchesFilter("variable"))
          symbolSources.push({ kind: "variable", items: script.exports });
        if (matchesFilter("enum")) symbolSources.push({ kind: "enum", items: script.enums });
        if (matchesFilter("constant"))
          symbolSources.push({ kind: "constant", items: script.constants });
    
        for (const { kind, items } of symbolSources) {
          for (const item of items) {
            if (item.name.includes(name)) {
              results.push({ name: item.name, kind, file: path, line: item.line });
            }
          }
        }
    
        // Classes need special handling (className + innerClasses)
        if (matchesFilter("class")) {
          if (script.className?.includes(name)) {
            results.push({ name: script.className, kind: "class", file: path, line: 1 });
          }
          for (const ic of script.innerClasses) {
            if (ic.name.includes(name)) {
              results.push({ name: ic.name, kind: "class", file: path, line: ic.line });
            }
          }
        }
      }
    
      const truncated = results.length > maxResults;
      return makeTextResponse({
        data: results.slice(0, maxResults),
        truncated,
        totalCount: results.length,
        metadata: { source: "fallback" },
      });
    },
  • Zod schema defining the input arguments for the `find_symbol` tool (name, type, maxResults).
    schema: {
      name: z.string().describe("Symbol name to search for (substring match)"),
      type: z
        .enum(["function", "signal", "variable", "class", "enum", "constant", "any"])
        .optional()
        .default("any")
        .describe("Symbol type to filter by"),
      maxResults: z
        .number()
        .int()
        .min(1)
        .max(500)
        .optional()
        .default(50)
        .describe("Maximum results to return"),
    },
  • Registration of the `find_symbol` tool within the `createSymbolTools` function.
    {
      name: "find_symbol",
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the dual implementation (LSP and regex fallback), the inclusion of a metadata.source field to indicate the method used, and the accuracy difference (LSP provides more accurate signatures and locations). This covers important operational details beyond basic functionality.

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

Conciseness4/5

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

The description is front-loaded with the core purpose, followed by implementation details and result metadata. Both sentences earn their place by adding value (fallback mechanism and accuracy context). It's efficient but could be slightly more structured, e.g., by separating usage notes.

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

Completeness4/5

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

Given the tool's moderate complexity (search with fallback), no annotations, and no output schema, the description does well by explaining the dual implementation and result metadata. However, it lacks details on output format (e.g., what fields are returned beyond metadata.source) and potential limitations (e.g., performance with large projects), leaving minor gaps.

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%, so the schema already documents all parameters (name, type, maxResults) with descriptions. The description doesn't add any parameter-specific semantics beyond what's in the schema, such as explaining substring match behavior or type filtering implications. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Find symbols by name across the project.' It specifies the verb ('Find'), resource ('symbols'), and scope ('across the project'), and distinguishes itself from siblings like 'find_node' (specific to nodes) or 'find_references' (different search target).

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

Usage Guidelines3/5

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

The description implies usage by mentioning 'Uses LSP when available, regex parser as fallback,' suggesting it's for symbol searching with fallback mechanisms. However, it doesn't explicitly state when to use this tool versus alternatives like 'find_symbols_overview' (if that provides a different view) or 'find_references' (for references rather than symbols), nor does it mention prerequisites or exclusions.

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/woohq/godette-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server