Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

get_gdscript_structure

Analyze GDScript file structure to view classes, functions, signals, and variables with line numbers for efficient code navigation.

Instructions

Get a high-level structure view of a GDScript file, showing all classes, functions, signals, and variables with their line numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file

Implementation Reference

  • Tool schema definition for 'get_gdscript_structure', including input validation for file_path.
    Tool( name="get_gdscript_structure", description="Get a high-level structure view of a GDScript file, showing all classes, functions, signals, and variables with their line numbers.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "description": "Path to the GDScript file", } }, "required": ["file_path"], }, ),
  • Tool dispatch registration in handle_tool_call method, mapping tool name to handler.
    elif tool_name == "get_gdscript_structure": return self._get_structure(tool_input["file_path"])
  • Primary handler for the get_gdscript_structure tool: reads file, parses with GDScriptParser, generates structure, returns CallToolResult.
    def _get_structure(self, file_path: str) -> CallToolResult: """Get structure view of a GDScript file. Args: file_path: Path to the file Returns: CallToolResult with structure """ try: path = Path(file_path) if not path.exists(): return CallToolResult( content=[TextContent(type="text", text=f"File not found: {file_path}")], isError=True, ) code = path.read_text(encoding="utf-8") tree = self.parser.parse(code) structure = self.parser.get_structure(tree, code) return CallToolResult( content=[TextContent(type="text", text=structure)], isError=False, ) except Exception as e: return CallToolResult( content=[TextContent(type="text", text=f"Error getting structure: {str(e)}")], isError=True, )
  • Core helper function that formats the high-level structure from extracted symbols (classes, functions, etc.) into a readable string.
    def get_structure(self, tree: Tree, code: str) -> str: """Get a high-level structure overview of the file. Args: tree: The parsed syntax tree code: The original source code Returns: Formatted structure string """ symbols = self.get_symbols(tree) structure_lines = ["=== GDScript File Structure ===\n"] if symbols["classes"]: structure_lines.append("Classes:") for cls in symbols["classes"]: structure_lines.append(f" - {cls['name']} (line {cls['line']})") if symbols["functions"]: structure_lines.append("\nFunctions:") for func in symbols["functions"]: structure_lines.append(f" - {func['name']} (line {func['line']})") if symbols["signals"]: structure_lines.append("\nSignals:") for sig in symbols["signals"]: structure_lines.append(f" - {sig['name']} (line {sig['line']})") if symbols["variables"]: structure_lines.append("\nVariables:") for var in symbols["variables"]: structure_lines.append(f" - {var['name']} (line {var['line']})") if symbols["enums"]: structure_lines.append("\nEnums:") for enum in symbols["enums"]: structure_lines.append(f" - {enum['name']} (line {enum['line']})") return "\n".join(structure_lines)

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