使用说明
FiveM MCP服务器
一个用于FiveM(GTA5)开发的综合模型上下文协议(MCP)服务器,使用Laravel构建。该服务器为AI助手提供了强大的工具和资源,以帮助更有效地开发FiveM资源。
概述
FiveM MCP服务器能够与AI编码助手(Claude、ChatGPT等)无缝集成,以提供:
- 本机函数查找 客户端/服务器分离
- 事件文档 适用于所有框架
- 框架支持 适用于独立脚本、ESX脚本、QBCore脚本、COX脚本和Prodigy脚本(prp-bridge)
- 资源生成 带有可定制的样板
- 文档搜索 跨FiveM、QBCore和COX MySQL
- 代码片段和最佳实践 常见模式
Live网站
实时实例可在以下网址获得: https://fivem-mcp.kingsoflossantos.com
该网站包括交互式文档、工具说明和集成指南。
快速开始
安装
# Clone the repository
git clone https://github.com/yourusername/fivem-mcp.git
cd fivem-mcp
# Install dependencies
composer install
npm install
# Copy environment file and generate key
cp .env.example .env
php artisan key:generate
# Run database migrations
php artisan migrate
# Build frontend assets
npm run build
运行服务器
实时人工智能助理(Claude/Client):
{
"servers": {
"fivem": {
"url": "https://fivem-mcp.kingsoflossantos.com/fivem",
"type": "http"
}
}
}
本地测试:
php artisan mcp:inspector fivem
启动MCP服务器:
php artisan mcp:start fivem
对于人工智能助理(Claude/Cline): 在AI客户端设置中配置:
{
"servers": {
"fivem": {
"command": "php",
"args": ["/path/to/fivem-mcp/artisan", "mcp:start", "fivem"]
}
}
}
工具
MCP服务器包括30个按框架和执行端组织的强大工具:
FiveM Core(7个工具)
- 搜索FiveMDocs -搜索FiveM、QBCore和COX文档
- GetNativeClient函数 -查找客户端本机函数(10个本机函数)
- GetNativeServer函数 -查找服务器端本机函数(12个本机函数)
- GetEventClientReference -客户端事件参考(5个事件)
- GetEventServerReference -服务器端事件参考(4+个事件)
- 生成Nifest -生成支持框架的fxmanifest.lua
- 生成资源锅炉板 -完整的资源脚手架
QBCore框架(9个工具)
- GetQBCoreServer函数 -QBCore服务器功能(13+功能)
- GetQBCoreClient函数 -QBCore客户端功能(6个功能)
- GetQBCoreServer事件参考 -QBCore服务器事件(6个事件)
- GetQBCoreClientEventReference -QBCore客户端事件(6个事件)
- GetQBCoreConfig -QBCore配置参考
- GetQBCorePlayers -玩家管理功能
- GetQBCore资源列表 -可用QBCore资源
- GetQBCore资源参考 -特定资源文件
- 获取QBCoreSharedData -共享数据(工作、物品、车辆)
COX/ox_libs(10个工具)
- Getcox函数 -OxMySQL数据库函数(8个函数)
- GetCOXEventReference -COX特定事件
- GetInventoryServer函数 -ox_inventory服务器功能(21个功能)
- GetInventoryClient函数 -ox_inventory客户端函数(8个函数)
- GetOx门锁客户端功能 -ox_doorlock客户端API
- GetOx门锁服务器功能 -ox_doorlock服务器API
- GetOxDoorlock服务器事件 -ox_doorlock服务器事件
- GetOxFuelClient功能 -ox_fuel客户端API
- Getoxfordshire -ox_fuel服务器API
- GetOxTargetClient函数 -ox_target客户端API
Prodigy脚本/prp桥(4个工具)
- GetProdigyClientEventReference -prp桥接客户端事件(通知、回调、允许列表、医疗中的11个事件)
- GetProdigyServerEventReference -prp桥服务器端事件(跨框架、组、医疗、UniQueue的8个事件)
- 获取digyClientExport -prp桥接客户端导出(允许列表、放置器、ped交互)
- 获取数字服务器导出 -prp网桥服务器导出(24个导出:冷却、分配列表、组、UniQueue、销售商店、案例)
项目结构
app/Mcp/
├── Tools/
│ ├── COX/
│ │ ├── Doorlock/
│ │ │ ├── Client/GetOxDoorlockClientFunction.php
│ │ │ └── Server/
│ │ │ ├── GetOxDoorlockServerFunction.php
│ │ │ └── GetOxDoorlockServerEvent.php
│ │ ├── Fuel/
│ │ │ ├── Client/GetOxFuelClientFunction.php
│ │ │ └── Server/GetOxFuelServerFunction.php
│ │ ├── Inventory/
│ │ │ ├── Server/GetInventoryServerFunction.php
│ │ │ └── Client/GetInventoryClientFunction.php
│ │ ├── MySQL/
│ │ │ ├── GetCOXFunction.php
│ │ │ └── GetCOXEventReference.php
│ │ └── Target/
│ │ └── Client/GetOxTargetClientFunction.php
│ ├── FiveM/
│ │ ├── Client/
│ │ │ ├── GetNativeClientFunction.php
│ │ │ └── GetEventClientReference.php
│ │ ├── Server/
│ │ │ ├── GetNativeServerFunction.php
│ │ │ └── GetEventServerReference.php
│ │ ├── GenerateManifest.php
│ │ ├── GenerateResourceBoilerplate.php
│ │ └── SearchFiveMDocs.php
│ ├── Prodigy/
│ │ ├── Client/
│ │ │ ├── GetProdigyClientEventReference.php
│ │ │ └── GetProdigyClientExport.php
│ │ └── Server/
│ │ ├── GetProdigyServerEventReference.php
│ │ └── GetProdigyServerExport.php
│ └── QBCore/
│ ├── Client/
│ │ ├── GetQBCoreClientFunction.php
│ │ └── GetQBCoreClientEventReference.php
│ ├── Server/
│ │ ├── GetQBCoreServerFunction.php
│ │ └── GetQBCoreServerEventReference.php
│ ├── GetQBCoreConfig.php
│ ├── GetQBCorePlayers.php
│ ├── GetQBCoreResourceList.php
│ ├── GetQBCoreResourceReference.php
│ └── GetQBCoreSharedData.php
├── Resources/
│ ├── CodeSnippets.php
│ ├── BestPractices.php
│ ├── FrameworkComparison.php
│ └── DatabaseQueries.php
├── Prompts/
│ ├── CreateNewResource.php
│ ├── DebugIssues.php
│ ├── OptimizePerformance.php
│ ├── ConvertLanguage.php
│ └── AddFrameworkIntegration.php
└── Servers/
└── FiveMServer.php
资源
MCP资源提供只读参考文档:
- 代码片段 -Lua和JavaScript中常见的FiveM模式
- 最佳实践 -性能优化和安全指南
- 框架比较 -独立与ESX与QBCore的差异
- 数据库查询 -COX MySQL示例和模式
提示
引导AI助手的交互式提示:
- 创建新资源 -构建完整的FiveM资源
- 调试问题 -分析并修复FiveM错误
- 优化性能 -提高资源效率
- 转换语言 -Lua和JavaScript之间的翻译
- 添加框架集成 -在框架之间迁移
测试
运行测试套件以确保一切正常:
# Run all tests
php artisan test
# Run specific test file
php artisan test tests/Feature/GetNativeClientFunctionToolTest.php
# Run with coverage report
php artisan test --coverage
当前测试状态: 181项测试通过✅
代码质量
该项目遵循PSR-12编码标准,并使用Laravel Pint进行自动格式化:
# Format all code
vendor/bin/pint
# Check formatting without fixing
vendor/bin/pint --test
文档
架构说明
客户端/服务器分离
所有工具均按以下方式组织 执行方 (客户端或服务器),以确保AI助手提供适当的代码示例。例如:
GetNativeClientFunction仅包含客户端本机GetNativeServerFunction仅包含服务器端本机- 事件以类似的方式分开,以避免混淆
框架组织
工具按框架(FiveM、QBCore、COX)分组,使发现直观并保持文档重点。
响应格式
所有工具响应都使用与以下内容一致的格式:
- 功能/事件签名
- 参数说明
- 返回类型
- Lua和JavaScript代码示例
- 完整的使用模式
贡献
要添加新工具或改进现有工具:
- 在中创建新的工具类
app/Mcp/Tools/{Framework}/{Side}/ - 实施
Tool接口 - 在中添加相应的测试文件
tests/Feature/ - 注册于
app/Mcp/Servers/FiveMServer.php - 运行测试:
php artisan test - 格式代码:
vendor/bin/pint - 提交带有描述的PR
许可证
MIT许可证-有关详细信息,请参阅许可证文件
支持
对于问题或疑问:
- 审查 FiveM文档
- 在GitHub上打开一个问题