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()

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