analyze_gdscript_code
Analyze GDScript code to extract its structure, functions, symbols, and dependencies for understanding Godot game engine codebases.
Instructions
Analyze GDScript code provided directly and extract its structure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | GDScript source code to analyze |
Input Schema (JSON Schema)
{
"properties": {
"code": {
"description": "GDScript source code to analyze",
"type": "string"
}
},
"required": [
"code"
],
"type": "object"
}
Implementation Reference
- src/mcp_gdscript/tools.py:337-371 (handler)The main handler function for the 'analyze_gdscript_code' tool. It parses the input code using GDScriptParser, extracts symbols and structure, computes a summary, and returns the result as JSON.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, )
- src/mcp_gdscript/tools.py:88-101 (schema)The Tool schema definition including name, description, and input schema requiring a 'code' string 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"], }, ),
- src/mcp_gdscript/tools.py:164-165 (registration)The dispatch registration in handle_tool_call that routes calls to the _analyze_code handler.elif tool_name == "analyze_gdscript_code": return self._analyze_code(tool_input["code"])