Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

analyze_gdscript_code

Analyze GDScript code structure to extract symbols, functions, and dependencies for understanding Godot game engine codebases.

Instructions

Analyze GDScript code provided directly and extract its structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesGDScript source code to analyze

Implementation Reference

  • The main handler function for the 'analyze_gdscript_code' tool. It parses the provided GDScript code using the GDScriptParser, extracts symbols and structure, computes a summary, and returns a JSON-formatted result.
    def _analyze_code(self, code: str) -> CallToolResult:
        """Analyze GDScript code provided directly.
    
        Args:
            code: GDScript source code
    
        Returns:
            CallToolResult with analysis
        """
        try:
            tree = self.parser.parse(code)
            symbols = self.parser.get_symbols(tree)
            structure = self.parser.get_structure(tree, code)
    
            result = {
                "structure": structure,
                "symbols": symbols,
                "summary": {
                    "total_classes": len(symbols["classes"]),
                    "total_functions": len(symbols["functions"]),
                    "total_signals": len(symbols["signals"]),
                    "total_variables": len(symbols["variables"]),
                    "total_enums": len(symbols["enums"]),
                },
            }
    
            return CallToolResult(
                content=[TextContent(type="text", text=json.dumps(result, indent=2))],
                isError=False,
            )
        except Exception as e:
            return CallToolResult(
                content=[TextContent(type="text", text=f"Error analyzing code: {str(e)}")],
                isError=True,
            )
  • The schema definition for the 'analyze_gdscript_code' tool, specifying the input as a string 'code' parameter.
    Tool(
        name="analyze_gdscript_code",
        description="Analyze GDScript code provided directly and extract its structure.",
        inputSchema={
            "type": "object",
            "properties": {
                "code": {
                    "type": "string",
                    "description": "GDScript source code to analyze",
                }
            },
            "required": ["code"],
        },
    ),
  • Registration dispatch in handle_tool_call method that routes calls to the _analyze_code handler.
    elif tool_name == "analyze_gdscript_code":
        return self._analyze_code(tool_input["code"])
  • MCP server handler for tool calls, which delegates to GDScriptTools.handle_tool_call including for analyze_gdscript_code.
    async def call_tool(name: str, arguments: dict[str, Any]) -> CallToolResult:
        """Handle tool calls."""
        logger.info(f"Calling tool: {name} with arguments: {arguments}")
    
        result = self.tools.handle_tool_call(name, arguments)
    
        return CallToolResult(content=result.content, isError=result.isError)
  • MCP server handler for listing tools, which returns the list from GDScriptTools.get_tools() including the analyze_gdscript_code tool.
    @self.server.list_tools()
    async def list_tools() -> list[Tool]:
        """List available tools."""
        logger.info("Listing available tools")
        return self.tools.get_tools()
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool analyzes and extracts structure, but doesn't disclose behavioral traits such as what 'extract its structure' entails (e.g., returns AST, symbols, dependencies), performance characteristics, error handling, or any limitations. This leaves significant gaps for an agent to understand how the tool behaves beyond its basic purpose.

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 key action and resource. It wastes no words and clearly communicates the core functionality, making it easy for an agent to parse quickly.

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, no output schema, and a single parameter with full schema coverage, the description is incomplete. It doesn't explain what 'extract its structure' means in terms of return values or behavior, which is critical for an analysis tool. With no structured data to compensate, the description should provide more context about outputs and operational details.

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 parameter 'code' well-documented in the schema as 'GDScript source code to analyze.' The description adds no additional meaning beyond this, as it doesn't elaborate on code format, size limits, or examples. Baseline 3 is appropriate since the schema does the heavy lifting, but no extra value is added.

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 action ('analyze') and resource ('GDScript code provided directly'), specifying it extracts structure. It distinguishes from sibling 'analyze_gdscript_file' by specifying 'provided directly' (inline code vs. file). However, it doesn't fully differentiate from 'get_gdscript_structure' which may have overlapping functionality.

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 context through 'provided directly,' suggesting this tool is for analyzing inline code rather than files (contrasting with 'analyze_gdscript_file'). However, it lacks explicit guidance on when to use this vs. other structure-related siblings like 'get_gdscript_structure' or 'find_gdscript_symbol,' and no 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/minami110/mcp-gdscript'

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