Skip to main content
Glama
minami110

GDScript Code Analyzer

by minami110

find_gdscript_symbol

Locate specific symbols like classes or functions in GDScript files to analyze code structure and retrieve detailed information for Godot engine development.

Instructions

Search for a specific symbol (class, function, signal, etc.) in a GDScript file and get its details.

Input Schema

NameRequiredDescriptionDefault
file_pathYesPath to the GDScript file
symbol_nameYesName of the symbol to find

Input Schema (JSON Schema)

{ "properties": { "file_path": { "description": "Path to the GDScript file", "type": "string" }, "symbol_name": { "description": "Name of the symbol to find", "type": "string" } }, "required": [ "file_path", "symbol_name" ], "type": "object" }

Implementation Reference

  • Handler function that implements the core logic of the 'find_gdscript_symbol' tool: reads the file, parses it, calls parser.find_symbol, and returns JSON result or error.
    def _find_symbol(self, file_path: str, symbol_name: str) -> CallToolResult: """Find a symbol in a GDScript file. Args: file_path: Path to the file symbol_name: Name of the symbol to find Returns: CallToolResult with symbol info """ 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) symbol = self.parser.find_symbol(tree, symbol_name) if symbol: return CallToolResult( content=[TextContent(type="text", text=json.dumps(symbol, indent=2))], isError=False, ) else: return CallToolResult( content=[TextContent(type="text", text=f"Symbol '{symbol_name}' not found")], isError=True, ) except Exception as e: return CallToolResult( content=[TextContent(type="text", text=f"Error finding symbol: {str(e)}")], isError=True, )
  • Tool schema definition including name, description, and inputSchema with required parameters file_path and symbol_name.
    Tool( name="find_gdscript_symbol", description="Search for a specific symbol (class, function, signal, etc.) in a GDScript file and get its details.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "description": "Path to the GDScript file", }, "symbol_name": { "type": "string", "description": "Name of the symbol to find", }, }, "required": ["file_path", "symbol_name"], }, ),
  • Registration and dispatch of the tool in the handle_tool_call method, mapping tool_name to the handler.
    elif tool_name == "find_gdscript_symbol": return self._find_symbol(tool_input["file_path"], tool_input["symbol_name"])
  • Helper method in GDScriptParser that implements the symbol search logic by iterating over extracted symbols from the parse tree.
    def find_symbol(self, tree: Tree, symbol_name: str) -> Optional[dict[str, Any]]: """Find a symbol by name. Args: tree: The parsed syntax tree symbol_name: Name of the symbol to find Returns: Symbol information or None if not found """ symbols = self.get_symbols(tree) for sym_type in ["classes", "functions", "signals", "variables", "enums"]: for sym in symbols[sym_type]: if sym["name"] == symbol_name: return { "type": sym_type[:-1], # Remove trailing 's' **sym, } return None

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