A Model Context Protocol (MCP) server for GDScript code analysis. This server allows AI assistants to understand GDScript code structure without reading entire files, making it efficient for large codebases.
- File Structure Analysis: Extract classes, functions, signals, variables, and enums from GDScript files
- Symbol Search: Find specific symbols and get their location and type
- Dependency Extraction: Identify extends, preload, and import statements
- Direct Code Analysis: Analyze GDScript code snippets without file I/O
- Tree-Sitter Powered: Accurate parsing using the official GDScript tree-sitter grammar
The simplest way to use this server - no installation required:
{
"mcpServers": {
"gdscript": {
"command": "uvx",
"args": ["mcp-gdscript"]
}
}
}{
"mcpServers": {
"gdscript": {
"command": "npx",
"args": ["mcp-gdscript"]
}
}
}# Clone the repository
git clone https://github.com/minami110/mcp-gdscript
cd mcp-gdscript
# Install in development mode
pip install -e .
# Run the server
mcp-gdscriptAnalyze a GDScript file and extract its complete structure.
Input:
file_path(string): Path to the .gd or .gdscript file
Output: Returns JSON with:
symbols: Lists of classes, functions, signals, variables, and enums with line numberssummary: Total counts for each symbol type
Example:
{
"file": "scenes/player.gd",
"symbols": {
"classes": [],
"functions": [
{"name": "_ready", "line": 5, "column": 0},
{"name": "_process", "line": 10, "column": 0}
],
"signals": [
{"name": "health_changed", "line": 2, "column": 0}
],
"variables": [],
"enums": []
},
"summary": {
"total_classes": 0,
"total_functions": 2,
"total_signals": 1,
"total_variables": 0,
"total_enums": 0
}
}Get a human-readable structure view of a GDScript file.
Input:
file_path(string): Path to the .gd or .gdscript file
Output: A formatted text representation showing the file structure with line numbers.
Example output:
=== GDScript File Structure ===
Signals:
- health_changed (line 2)
Functions:
- _ready (line 5)
- _process (line 10)
Search for a specific symbol in a file.
Input:
file_path(string): Path to the .gd or .gdscript filesymbol_name(string): Name of the symbol to find
Output: Symbol information including type, name, and location.
Example:
{
"type": "function",
"name": "_ready",
"line": 5,
"column": 0
}Extract all dependencies from a GDScript file.
Input:
file_path(string): Path to the .gd or .gdscript file
Output: Lists of extends, preload, and import statements.
Example:
{
"file": "scenes/enemy.gd",
"dependencies": {
"extends": ["Character"],
"preload": ["res://scenes/explosion.tscn"],
"import": []
}
}Analyze GDScript code provided directly as a string.
Input:
code(string): GDScript source code
Output: Complete analysis including structure, symbols, and summary.
Set the project root directory to enable project-wide analysis.
Input:
project_root(string): Path to the project root directory
Output: Confirmation with indexed GDScript files count.
Example:
{
"project_root": "/home/user/godot_project",
"gdscript_files_count": 42,
"status": "success"
}Get the current project root directory and file count.
Input:
- None
Output: Current project root path and indexed file count.
Example:
{
"project_root": "/home/user/godot_project",
"gdscript_files_count": 42
}Find all references to a symbol across the project or in a specific file.
Input:
symbol_name(string): Name of the symbol to find references forfile_path(optional string): Limit search to a specific file. If not provided and project root is set, searches entire project.
Output: List of all locations where the symbol is referenced.
Example:
{
"symbol": "player_name",
"total_references": 5,
"references": [
{
"file": "scripts/player.gd",
"line": 15,
"column": 8,
"end_line": 15,
"end_column": 19
},
{
"file": "scripts/manager.gd",
"line": 42,
"column": 12,
"end_line": 42,
"end_column": 23
}
]
}Use Cases:
- Find all usages of a variable or function
- Understand dependencies between files
- Refactor safely by checking all references
- Trace data flow in your project
- Codebase Navigation: Quickly understand the structure of large GDScript files
- API Documentation: Generate documentation from code structure
- Dependency Analysis: Understand script relationships and dependencies
- Code Review: Get structure overview before detailed review
- Refactoring Aid: Understand what needs to be updated when refactoring
RUST_LOG: Set logging level (e.g.,debug,info,warn)
- For large files (>10MB), the server efficiently extracts structure without loading full content into context
- Symbol extraction is optimized for typical GDScript files (< 50MB)
- The tree-sitter parser uses cached grammar for performance
- Currently optimized for GDScript 4.x and later
- Complex macro expansions may not be fully analyzed
- Some edge cases in dynamic code patterns may not be captured
pip install -e ".[dev]"pytestblack .
ruff check .Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details
Make sure you're using Python 3.10 or later and have installed the server correctly.
This server is optimized for GDScript 4.x. For GDScript 3.x, some features may not work as expected.
If analyzing very large files, consider:
- Splitting large scripts into smaller modules
- Using the structure tool instead of full analysis
- Analyzing specific symbols instead of entire files