Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

set_project_root

Set the project root directory to enable project-wide GDScript analysis, indexing all .gd files for efficient code navigation and understanding in Godot projects.

Instructions

Set the project root directory to enable project-wide analysis. This will index all .gd files in the project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_rootYesPath to the project root directory

Implementation Reference

  • Core handler function implementing the 'set_project_root' tool logic: validates path, sets project root, indexes .gd files, returns JSON result.
    def _set_project_root(self, project_root: str) -> CallToolResult:
        """Set the project root directory.
    
        Args:
            project_root: Path to the project root
    
        Returns:
            CallToolResult with status
        """
        try:
            root_path = Path(project_root).resolve()
            if not root_path.exists():
                return CallToolResult(
                    content=[TextContent(type="text", text=f"Project root does not exist: {project_root}")],
                    isError=True,
                )
    
            if not root_path.is_dir():
                return CallToolResult(
                    content=[TextContent(type="text", text=f"Project root is not a directory: {project_root}")],
                    isError=True,
                )
    
            self.project_root = root_path
            self._load_gdscript_files()
    
            result = {
                "project_root": str(self.project_root),
                "gdscript_files_count": len(self._gdscript_files),
                "status": "success",
            }
    
            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 setting project root: {str(e)}")],
                isError=True,
            )
  • Input schema definition for the 'set_project_root' tool, specifying the required 'project_root' string parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "project_root": {
                "type": "string",
                "description": "Path to the project root directory",
            }
        },
        "required": ["project_root"],
    },
  • Registration of the 'set_project_root' tool in the get_tools() method's return list, including name, description, and schema.
    Tool(
        name="set_project_root",
        description="Set the project root directory to enable project-wide analysis. This will index all .gd files in the project.",
        inputSchema={
            "type": "object",
            "properties": {
                "project_root": {
                    "type": "string",
                    "description": "Path to the project root directory",
                }
            },
            "required": ["project_root"],
        },
    ),
  • Dispatch/registration in handle_tool_call method that routes 'set_project_root' calls to the _set_project_root handler.
    elif tool_name == "set_project_root":
        return self._set_project_root(tool_input["project_root"])
  • Helper utility called by the handler to index all GDScript (.gd) files recursively from the project root.
    def _load_gdscript_files(self) -> None:
        """Load all .gd files from the project root."""
        if not self.project_root:
            self._gdscript_files = []
            return
    
        self._gdscript_files = []
        for file_path in self.project_root.rglob("*.gd"):
            self._gdscript_files.append(file_path)

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