GDScript Code Analyzer
Enables AI assistants to analyze GDScript code structure, extract symbols, functions, and dependencies without reading entire files. Supports efficient navigation and understanding of Godot game engine codebases through tree-sitter parsing.
README
mcp-gdscript
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.
Features
- 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
Installation & Usage
With uvx (Recommended)
The simplest way to use this server - no installation required:
{
"mcpServers": {
"gdscript": {
"command": "uvx",
"args": ["mcp-gdscript"]
}
}
}
With npm/npx
{
"mcpServers": {
"gdscript": {
"command": "npx",
"args": ["mcp-gdscript"]
}
}
}
Local Installation
# Clone the repository
git clone https://github.com/yourusername/mcp-gdscript
cd mcp-gdscript
# Install in development mode
pip install -e .
# Run the server
mcp-gdscript
Available Tools
1. analyze_gdscript_file
Analyze 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
}
}
2. get_gdscript_structure
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)
3. find_gdscript_symbol
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
}
4. get_gdscript_dependencies
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": []
}
}
5. analyze_gdscript_code
Analyze GDScript code provided directly as a string.
Input:
code(string): GDScript source code
Output: Complete analysis including structure, symbols, and summary.
Use Cases
- 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
Configuration
Environment Variables
RUST_LOG: Set logging level (e.g.,debug,info,warn)
Performance Tips
- 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
Limitations
- 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
Development
Setup
pip install -e ".[dev]"
Testing
pytest
Code Style
black .
ruff check .
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT License - see LICENSE file for details
References
Troubleshooting
"Module not found" errors
Make sure you're using Python 3.10 or later and have installed the server correctly.
Parse errors for GDScript 3.x
This server is optimized for GDScript 4.x. For GDScript 3.x, some features may not work as expected.
Performance issues
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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。