Files
fivem-mcp/app/Mcp/Prompts/OptimizePerformance.php
T
Adrian Mejias d3d1f5fdb3 Add FiveM resources and templates for documentation and code snippets
- Introduced a new code snippets resource for common FiveM patterns in Lua and JavaScript.
- Added a framework comparison document outlining Standalone, ESX, and QBCore features.
- Created search results view for FiveM documentation queries.
- Developed client and server template scripts for ESX and QBCore frameworks.
- Implemented NUI templates including HTML, CSS, and JavaScript for user interfaces.
- Established routes for documentation and console commands.
- Added tests for various features including documentation routes and tool functionalities.
- Configured Vite for asset management with Laravel.
- Updated .gitignore files for storage and framework directories.
2026-02-28 21:53:04 -06:00

57 lines
1.9 KiB
PHP

<?php
namespace App\Mcp\Prompts;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Prompt;
#[Description('Optimize FiveM script performance')]
class OptimizePerformance extends Prompt
{
public function handle(Request $request): Response
{
$code = $request->get('code', '');
$scriptType = $request->get('script_type', 'client');
$parts = ["Review and optimize this FiveM script for better performance:\n\n"];
if ($code) {
$parts[] = sprintf("```\n%s\n```\n\n", $code);
}
$parts[] = sprintf(
"Script Type: %s\n\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s",
$scriptType,
"Please analyze the code and:",
"1. Identify performance issues (unnecessary loops, missing waits, etc.)",
"2. Suggest optimizations with code examples",
"3. Explain why each optimization improves performance",
"4. Provide the optimized version of the code",
"5. Reference FiveM best practices for performance",
"Focus on:",
"- Proper Citizen.Wait() usage",
"- Distance checks before expensive operations",
"- Caching frequently accessed values",
"- Reducing server-client communication",
"- Efficient event handling"
);
return Response::prompt(implode('', $parts));
}
public function schema(JsonSchema $schema): array
{
return [
'code' => $schema->string()
->description('The code to optimize')
->default(''),
'script_type' => $schema->enum(['client', 'server', 'shared'])
->description('Type of script')
->default('client'),
];
}
}