Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

get_gdscript_structure

Analyze GDScript file structure to view classes, functions, signals, and variables with line numbers for efficient code navigation.

Instructions

Get a high-level structure view of a GDScript file, showing all classes, functions, signals, and variables with their line numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file

Implementation Reference

  • Tool schema definition for 'get_gdscript_structure', including input validation for file_path.
    Tool(
        name="get_gdscript_structure",
        description="Get a high-level structure view of a GDScript file, showing all classes, functions, signals, and variables with their line numbers.",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the GDScript file",
                }
            },
            "required": ["file_path"],
        },
    ),
  • Tool dispatch registration in handle_tool_call method, mapping tool name to handler.
    elif tool_name == "get_gdscript_structure":
        return self._get_structure(tool_input["file_path"])
  • Primary handler for the get_gdscript_structure tool: reads file, parses with GDScriptParser, generates structure, returns CallToolResult.
    def _get_structure(self, file_path: str) -> CallToolResult:
        """Get structure view of a GDScript file.
    
        Args:
            file_path: Path to the file
    
        Returns:
            CallToolResult with structure
        """
        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)
            structure = self.parser.get_structure(tree, code)
    
            return CallToolResult(
                content=[TextContent(type="text", text=structure)],
                isError=False,
            )
        except Exception as e:
            return CallToolResult(
                content=[TextContent(type="text", text=f"Error getting structure: {str(e)}")],
                isError=True,
            )
  • Core helper function that formats the high-level structure from extracted symbols (classes, functions, etc.) into a readable string.
    def get_structure(self, tree: Tree, code: str) -> str:
        """Get a high-level structure overview of the file.
    
        Args:
            tree: The parsed syntax tree
            code: The original source code
    
        Returns:
            Formatted structure string
        """
        symbols = self.get_symbols(tree)
        structure_lines = ["=== GDScript File Structure ===\n"]
    
        if symbols["classes"]:
            structure_lines.append("Classes:")
            for cls in symbols["classes"]:
                structure_lines.append(f"  - {cls['name']} (line {cls['line']})")
    
        if symbols["functions"]:
            structure_lines.append("\nFunctions:")
            for func in symbols["functions"]:
                structure_lines.append(f"  - {func['name']} (line {func['line']})")
    
        if symbols["signals"]:
            structure_lines.append("\nSignals:")
            for sig in symbols["signals"]:
                structure_lines.append(f"  - {sig['name']} (line {sig['line']})")
    
        if symbols["variables"]:
            structure_lines.append("\nVariables:")
            for var in symbols["variables"]:
                structure_lines.append(f"  - {var['name']} (line {var['line']})")
    
        if symbols["enums"]:
            structure_lines.append("\nEnums:")
            for enum in symbols["enums"]:
                structure_lines.append(f"  - {enum['name']} (line {enum['line']})")
    
        return "\n".join(structure_lines)
Behavior3/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 specifies the output content (classes, functions, signals, variables with line numbers) but does not mention performance aspects, error handling, or format details. It adequately describes the core behavior but lacks depth on operational traits.

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, well-structured sentence that efficiently conveys the tool's purpose and scope without unnecessary words. It is front-loaded with the main action and resource, making it easy to parse and understand quickly.

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 (single input, no output schema, no annotations), the description is reasonably complete. It explains what the tool does and the output content, but could benefit from more behavioral context or usage guidance to fully compensate for the lack of annotations and output schema.

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 'file_path' clearly documented in the schema. The description does not add any parameter-specific details beyond what the schema provides, such as file format requirements or path resolution rules, so it meets the baseline for high schema coverage.

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 specific action ('Get a high-level structure view') and resource ('of a GDScript file'), with detailed scope ('showing all classes, functions, signals, and variables with their line numbers'). It distinguishes from siblings like 'analyze_gdscript_code' or 'find_gdscript_symbol' by focusing on structural overview rather than code analysis or symbol lookup.

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 for extracting structural metadata from a GDScript file, but does not explicitly state when to use this tool versus alternatives such as 'analyze_gdscript_file' or 'find_gdscript_symbol'. No exclusions or prerequisites are mentioned, leaving the context somewhat open-ended.

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