Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

get_gdscript_dependencies

Extract dependencies from GDScript files to identify extends, preload, and import statements for code analysis.

Instructions

Extract dependencies from a GDScript file (extends, preload, import statements).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file

Implementation Reference

  • Registration of the 'get_gdscript_dependencies' tool, including name, description, and input schema.
    Tool(
        name="get_gdscript_dependencies",
        description="Extract dependencies from a GDScript file (extends, preload, import statements).",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the GDScript file",
                }
            },
            "required": ["file_path"],
        },
    ),
  • The main handler function for the tool that reads the GDScript file, parses it with tree-sitter, extracts dependencies via the parser, formats the result as JSON, and returns it.
    def _get_dependencies(self, file_path: str) -> CallToolResult:
        """Get dependencies from a GDScript file.
    
        Args:
            file_path: Path to the file
    
        Returns:
            CallToolResult with dependencies
        """
        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)
            dependencies = self.parser.get_dependencies(tree, code)
    
            result = {
                "file": file_path,
                "dependencies": dependencies,
            }
    
            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 getting dependencies: {str(e)}")],
                isError=True,
            )
  • Helper method in the parser that initializes the dependencies dict and calls the recursive extractor.
    def get_dependencies(self, tree: Tree, code: str) -> dict[str, list[str]]:
        """Extract dependencies (extends, preload) from the file.
    
        Args:
            tree: The parsed syntax tree
            code: The original source code
    
        Returns:
            Dictionary with lists of dependencies
        """
        dependencies = {
            "extends": [],
            "preload": [],
            "import": [],
        }
    
        self._extract_dependencies(tree.root_node, dependencies)
        return dependencies
  • Core recursive helper that traverses the parse tree to identify and extract extends, preload, and import dependencies.
    def _extract_dependencies(self, node: Node, deps: dict[str, list[str]]) -> None:
        """Recursively extract dependencies from tree nodes.
    
        Args:
            node: Current tree node
            deps: Dependencies dictionary to populate
        """
        node_type = node.type
    
        # Check for extends statement
        if node_type in ("extends_statement", "extend_statement"):
            # For extends, the type is in the "type" child node
            for child in node.children:
                if child.type == "type":
                    path = child.text.decode("utf-8") if isinstance(child.text, bytes) else str(child.text)
                    if path:
                        deps["extends"].append(path)
                elif child.type == "identifier":
                    path = child.text.decode("utf-8") if isinstance(child.text, bytes) else str(child.text)
                    if path and path != "extends":
                        deps["extends"].append(path)
    
        # Check for preload function calls (both function_call and call node types)
        elif node_type in ("function_call", "call"):
            if self._is_preload_call(node):
                path = self._extract_string_argument(node)
                if path:
                    deps["preload"].append(path)
    
        # Check for import statements
        elif node_type == "import_statement":
            path = self._extract_string_value(node)
            if path:
                deps["import"].append(path)
    
        # Recursively process child nodes
        for child in node.children:
            self._extract_dependencies(child, deps)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does (extract dependencies) but lacks details on behavioral traits such as error handling (e.g., what happens if the file path is invalid), output format, or performance considerations (e.g., whether it handles large files efficiently). This leaves gaps in understanding how the tool behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence earns its place by specifying the action, resource, and key details (e.g., types of dependencies), making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that performs extraction. It does not explain what the output looks like (e.g., list of dependencies, structured data), error conditions, or limitations (e.g., only works with specific GDScript versions). For a tool with no structured support, more contextual details are needed to ensure proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'file_path' parameter clearly documented in the schema. The description does not add any meaning beyond what the schema provides, as it does not elaborate on parameter usage, constraints, or examples. However, with high schema coverage, the baseline score of 3 is appropriate since the schema adequately covers the parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Extract dependencies') and resource ('from a GDScript file'), with explicit examples of what dependencies are targeted (extends, preload, import statements). It distinguishes itself from sibling tools like 'analyze_gdscript_code' or 'get_gdscript_structure' by focusing specifically on dependency extraction rather than broader analysis or structural examination.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when dependency extraction is needed from a GDScript file, but it does not explicitly state when to use this tool versus alternatives like 'analyze_gdscript_file' or 'find_gdscript_symbol'. There is no guidance on prerequisites, exclusions, or specific scenarios where this tool is preferred over others, leaving the context somewhat open-ended.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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