Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

find_gdscript_symbol

Locate and retrieve details of specific symbols like classes, functions, or signals within GDScript files to analyze code structure and dependencies.

Instructions

Search for a specific symbol (class, function, signal, etc.) in a GDScript file and get its details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file
symbol_nameYesName of the symbol to find

Implementation Reference

  • The handler function '_find_symbol' that implements the core logic of the 'find_gdscript_symbol' tool: reads the file, parses it, finds the symbol via parser, and serializes to JSON.
    def _find_symbol(self, file_path: str, symbol_name: str) -> CallToolResult:
        """Find a symbol in a GDScript file.
    
        Args:
            file_path: Path to the file
            symbol_name: Name of the symbol to find
    
        Returns:
            CallToolResult with symbol info
        """
        try:
            path = Path(file_path)
            if not path.exists():
                return CallToolResult(
                    content=[TextContent(type="text", text=f"File not found: {file_path}")],
                    isError=True,
                )
    
            code = path.read_text(encoding="utf-8")
            tree = self.parser.parse(code)
            symbol = self.parser.find_symbol(tree, symbol_name)
    
            if symbol:
                return CallToolResult(
                    content=[TextContent(type="text", text=json.dumps(symbol, indent=2))],
                    isError=False,
                )
            else:
                return CallToolResult(
                    content=[TextContent(type="text", text=f"Symbol '{symbol_name}' not found")],
                    isError=True,
                )
        except Exception as e:
            return CallToolResult(
                content=[TextContent(type="text", text=f"Error finding symbol: {str(e)}")],
                isError=True,
            )
  • Registration of the tool in the 'get_tools' method, defining name, description, and input schema.
    Tool(
        name="find_gdscript_symbol",
        description="Search for a specific symbol (class, function, signal, etc.) in a GDScript file and get its details.",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the GDScript file",
                },
                "symbol_name": {
                    "type": "string",
                    "description": "Name of the symbol to find",
                },
            },
            "required": ["file_path", "symbol_name"],
        },
    ),
  • Dispatch/registration in the 'handle_tool_call' method that routes calls to the handler.
    elif tool_name == "find_gdscript_symbol":
        return self._find_symbol(tool_input["file_path"], tool_input["symbol_name"])
  • Helper method 'find_symbol' in GDScriptParser that searches extracted symbols for the matching name and returns details.
    def find_symbol(self, tree: Tree, symbol_name: str) -> Optional[dict[str, Any]]:
        """Find a symbol by name.
    
        Args:
            tree: The parsed syntax tree
            symbol_name: Name of the symbol to find
    
        Returns:
            Symbol information or None if not found
        """
        symbols = self.get_symbols(tree)
    
        for sym_type in ["classes", "functions", "signals", "variables", "enums"]:
            for sym in symbols[sym_type]:
                if sym["name"] == symbol_name:
                    return {
                        "type": sym_type[:-1],  # Remove trailing 's'
                        **sym,
                    }
    
        return None
  • Helper method 'get_symbols' that extracts all symbols from the parse tree by traversing nodes.
    def get_symbols(self, tree: Tree) -> dict[str, Any]:
        """Extract symbols (classes, functions, etc.) from the tree.
    
        Args:
            tree: The parsed syntax tree
    
        Returns:
            Dictionary with symbol information
        """
        symbols = {
            "classes": [],
            "functions": [],
            "variables": [],
            "signals": [],
            "enums": [],
        }
    
        self._extract_symbols(tree.root_node, symbols)
        return symbols
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 the tool searches and returns details but doesn't specify what details are included (e.g., line numbers, type information), error handling (e.g., if symbol not found), or performance aspects (e.g., case sensitivity). This leaves gaps for a tool with no annotation coverage.

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, efficient sentence that front-loads the purpose ('search for a specific symbol') and outcome ('get its details'), with no wasted words. It's appropriately sized for a simple tool and earns its place by clearly stating the action and resource.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what 'details' are returned, how errors are handled, or any behavioral traits. For a tool with two parameters and no structured output, more context is needed to fully guide an agent, making this inadequate.

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 both parameters ('file_path' and 'symbol_name') clearly documented in the schema. The description adds minimal value beyond this, mentioning 'symbol' types but not elaborating on parameter usage or constraints. Baseline 3 is appropriate as the schema does the heavy lifting.

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 'search' and the resource 'symbol in a GDScript file', specifying the types of symbols (class, function, signal, etc.) and the outcome 'get its details'. It distinguishes from siblings like 'analyze_gdscript_file' or 'get_gdscript_structure' by focusing on symbol lookup rather than broader analysis. However, it doesn't explicitly contrast with 'find_references', which might overlap in purpose, preventing a perfect score.

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. It doesn't mention prerequisites, such as needing the file path or symbol name, or compare it to siblings like 'find_references' for broader searches or 'get_gdscript_structure' for structural overview. Usage is implied by the action but lacks explicit context 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/minami110/mcp-gdscript'

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