Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

analyze_gdscript_file

Extract GDScript file structure including classes, functions, signals, and variables to understand code organization without reading entire files.

Instructions

Analyze a GDScript file and extract its structure (classes, functions, signals, variables, enums). Returns a comprehensive overview without reading the entire file into context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file to analyze

Implementation Reference

  • The core handler function that executes the 'analyze_gdscript_file' tool logic. It validates the file path, reads the GDScript content, parses it using GDScriptParser, extracts symbols (classes, functions, signals, variables, enums), computes summary statistics, and returns a structured JSON result.
    def _analyze_file(self, file_path: str) -> CallToolResult:
        """Analyze a GDScript file.
    
        Args:
            file_path: Path to the file
    
        Returns:
            CallToolResult with analysis
        """
        try:
            path = Path(file_path)
            if not path.exists():
                return CallToolResult(
                    content=[TextContent(type="text", text=f"File not found: {file_path}")],
                    isError=True,
                )
    
            if not path.suffix.lower() in [".gd", ".gdscript"]:
                return CallToolResult(
                    content=[TextContent(type="text", text="File must be a .gd or .gdscript file")],
                    isError=True,
                )
    
            code = path.read_text(encoding="utf-8")
            tree = self.parser.parse(code)
            symbols = self.parser.get_symbols(tree)
    
            result = {
                "file": file_path,
                "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 file: {str(e)}")],
                isError=True,
            )
  • Tool registration definition in GDScriptTools.get_tools(), including the tool name, description, and input schema for MCP compatibility.
    Tool(
        name="analyze_gdscript_file",
        description="Analyze a GDScript file and extract its structure (classes, functions, signals, variables, enums). Returns a comprehensive overview without reading the entire file into context.",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the GDScript file to analyze",
                }
            },
            "required": ["file_path"],
        },
    ),
  • Input schema definition specifying an object with a required 'file_path' string property for the tool.
    inputSchema={
        "type": "object",
        "properties": {
            "file_path": {
                "type": "string",
                "description": "Path to the GDScript file to analyze",
            }
        },
        "required": ["file_path"],
    },
  • MCP server registration of the call_tool handler, which delegates to GDScriptTools.handle_tool_call(name, arguments), enabling execution of 'analyze_gdscript_file'.
    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 registration of list_tools, which returns tools from GDScriptTools.get_tools(), including 'analyze_gdscript_file'.
    @self.server.list_tools()
    async def list_tools() -> list[Tool]:
        """List available tools."""
        logger.info("Listing available tools")
        return self.tools.get_tools()
Behavior3/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. It discloses key behavioral traits: it performs analysis/extraction (implying read-only, non-destructive operation), specifies the scope of extraction (classes, functions, etc.), and mentions that it returns a comprehensive overview without full file context (hinting at efficiency or output format). However, it lacks details on error handling, rate limits, or authentication needs, which are important 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 appropriately sized and front-loaded, consisting of two concise sentences. The first sentence directly states the purpose and scope, and the second adds valuable behavioral context about the return and efficiency. Every sentence earns its place with no wasted words or redundancy.

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

Completeness3/5

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

Given the tool's complexity (structural analysis of code files), lack of annotations, and no output schema, the description is moderately complete. It covers the purpose, scope, and a hint about output behavior, but does not fully address what the 'comprehensive overview' includes in terms of format or structure. For a tool with no output schema, more detail on return values would improve completeness, but the description provides a basic viable level.

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?

The input schema has 100% description coverage, with the single parameter 'file_path' well-documented in the schema. The description does not add any meaning beyond the schema, as it does not elaborate on parameter usage, constraints, or examples. With high schema coverage, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract from the schema's clarity.

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 ('analyze'), resource ('GDScript file'), and outcome ('extract its structure (classes, functions, signals, variables, enums)'). It distinguishes from siblings like 'analyze_gdscript_code' by specifying file-based analysis rather than code snippet analysis, and from 'get_gdscript_structure' by mentioning the comprehensive extraction scope.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: for analyzing GDScript files to extract structural elements. It implies usage over 'analyze_gdscript_code' by specifying file-based analysis, but does not explicitly state when not to use it or name alternatives beyond the sibling context. The mention of 'without reading the entire file into context' suggests a performance consideration, but no explicit exclusions are provided.

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