Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

analyze_gdscript_file

Extract structure from GDScript files to identify classes, functions, signals, variables, and enums 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

NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file to analyze

Input Schema (JSON Schema)

{ "properties": { "file_path": { "description": "Path to the GDScript file to analyze", "type": "string" } }, "required": [ "file_path" ], "type": "object" }

Implementation Reference

  • The primary handler function '_analyze_file' that implements the tool's core logic: reads and validates the GDScript file, parses it using GDScriptParser, extracts symbols (classes, functions, signals, variables, enums), computes summary statistics, and returns a JSON-formatted result via CallToolResult.
    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, )
  • Defines the input schema for the 'analyze_gdscript_file' tool, including name, description, and required 'file_path' parameter.
    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"], }, ),
  • Dispatch logic within GDScriptTools.handle_tool_call that routes calls to 'analyze_gdscript_file' to the _analyze_file handler.
    if tool_name == "analyze_gdscript_file": return self._analyze_file(tool_input["file_path"])
  • MCP server handler for listing tools, which includes 'analyze_gdscript_file' via GDScriptTools.get_tools().
    @self.server.list_tools() async def list_tools() -> list[Tool]: """List available tools.""" logger.info("Listing available tools") return self.tools.get_tools()
  • MCP server handler for tool calls that delegates execution to GDScriptTools.handle_tool_call, enabling the 'analyze_gdscript_file' tool.
    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)

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