Add COX tools for doorlock, fuel, and target functionalities
- Implemented GetOxDoorlockServerFunction and GetOxDoorlockClientFunction for server-side and client-side door management, respectively. - Created GetOxFuelServerFunction and GetOxFuelClientFunction for handling fuel management on server and client sides. - Developed GetOxTargetClientFunction to manage targeting interactions, including global options and zone management. - Added feature tests for all new tools to ensure functionality and error handling for unknown functions.
This commit is contained in:
13 files changed
+1095
No files matched your search
@@ -11,10 +11,16 @@ use App\Mcp\Resources\BestPractices;
|
||||
use App\Mcp\Resources\CodeSnippets;
|
||||
use App\Mcp\Resources\DatabaseQueries;
|
||||
use App\Mcp\Resources\FrameworkComparison;
|
||||
use App\Mcp\Tools\COX\Doorlock\Client\GetOxDoorlockClientFunction;
|
||||
use App\Mcp\Tools\COX\Doorlock\Server\GetOxDoorlockServerEvent;
|
||||
use App\Mcp\Tools\COX\Doorlock\Server\GetOxDoorlockServerFunction;
|
||||
use App\Mcp\Tools\COX\Fuel\Client\GetOxFuelClientFunction;
|
||||
use App\Mcp\Tools\COX\Fuel\Server\GetOxFuelServerFunction;
|
||||
use App\Mcp\Tools\COX\Inventory\Client\GetInventoryClientFunction;
|
||||
use App\Mcp\Tools\COX\Inventory\Server\GetInventoryServerFunction;
|
||||
use App\Mcp\Tools\COX\MySQL\GetCOXEventReference;
|
||||
use App\Mcp\Tools\COX\MySQL\GetCOXFunction;
|
||||
use App\Mcp\Tools\COX\Target\Client\GetOxTargetClientFunction;
|
||||
use App\Mcp\Tools\FiveM\Client\GetEventClientReference;
|
||||
use App\Mcp\Tools\FiveM\Client\GetNativeClientFunction;
|
||||
use App\Mcp\Tools\FiveM\GenerateManifest;
|
||||
@@ -74,6 +80,12 @@ class FiveMServer extends Server
|
||||
GetCOXFunction::class,
|
||||
GetInventoryServerFunction::class,
|
||||
GetInventoryClientFunction::class,
|
||||
GetOxTargetClientFunction::class,
|
||||
GetOxFuelClientFunction::class,
|
||||
GetOxFuelServerFunction::class,
|
||||
GetOxDoorlockClientFunction::class,
|
||||
GetOxDoorlockServerFunction::class,
|
||||
GetOxDoorlockServerEvent::class,
|
||||
];
|
||||
|
||||
protected array $resources = [
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Doorlock\Client;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_doorlock client functions by name. Returns function signature, parameters, return type, and usage examples for client-side door management.')]
|
||||
class GetOxDoorlockClientFunction extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$functionName = $request->get('function_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$function = $this->findFunction($functionName);
|
||||
|
||||
if (! $function) {
|
||||
return Response::text(sprintf("ox_doorlock client function '%s' not found. Check ox_doorlock documentation at https://coxdocs.dev/ox_doorlock", $functionName));
|
||||
}
|
||||
|
||||
$output = $this->formatFunctionInfo($function, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_doorlock client function.
|
||||
*/
|
||||
protected function findFunction(string $name): ?array
|
||||
{
|
||||
$functions = [
|
||||
'pickClosestDoor' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Attempt to lockpick the closest door',
|
||||
'side' => 'client',
|
||||
'parameters' => [],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => 'exports.ox_doorlock:pickClosestDoor()',
|
||||
'js_example' => 'exports.ox_doorlock.pickClosestDoor();',
|
||||
],
|
||||
'useClosestDoor' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Toggle the lock state of the closest door',
|
||||
'side' => 'client',
|
||||
'parameters' => [],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => 'exports.ox_doorlock:useClosestDoor()',
|
||||
'js_example' => 'exports.ox_doorlock.useClosestDoor();',
|
||||
],
|
||||
'getClosestDoor' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Get data for the closest door',
|
||||
'side' => 'client',
|
||||
'parameters' => [],
|
||||
'returns' => ['type' => 'table|nil', 'description' => 'Door data or nil if no door nearby'],
|
||||
'lua_example' => "local door = exports.ox_doorlock:getClosestDoor()\nif door then\n print('Closest door ID: '..door.id)\n print('Door is locked: '..tostring(door.state == 1))\nend",
|
||||
'js_example' => "const door = exports.ox_doorlock.getClosestDoor();\nif (door) {\n console.log('Closest door ID: ' + door.id);\n console.log('Door is locked: ' + (door.state === 1));\n}",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($functions as $functionName => $functionData) {
|
||||
if (strtolower($functionName) === $nameLower) {
|
||||
return array_merge(['name' => $functionName], $functionData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format function info.
|
||||
*/
|
||||
protected function formatFunctionInfo(array $function, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-function', [
|
||||
'function' => $function,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'function_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_doorlock client function to look up (e.g., "pickClosestDoor", "useClosestDoor", "getClosestDoor")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Doorlock\Server;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_doorlock server events by name. Returns event signature, parameters, and usage examples for server-side door events.')]
|
||||
class GetOxDoorlockServerEvent extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$eventName = $request->get('event_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$event = $this->findEvent($eventName);
|
||||
|
||||
if (! $event) {
|
||||
return Response::text(sprintf("ox_doorlock server event '%s' not found. Check ox_doorlock documentation at https://coxdocs.dev/ox_doorlock", $eventName));
|
||||
}
|
||||
|
||||
$output = $this->formatEventInfo($event, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_doorlock server event.
|
||||
*/
|
||||
protected function findEvent(string $name): ?array
|
||||
{
|
||||
$events = [
|
||||
'ox_doorlock:stateChanged' => [
|
||||
'type' => 'doorlock',
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Triggered when a door lock state changes',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'doorId', 'type' => 'number', 'description' => 'The door ID'],
|
||||
['name' => 'state', 'type' => 'number', 'description' => 'New door state (0 = unlocked, 1 = locked)'],
|
||||
],
|
||||
'lua_example' => "AddEventHandler('ox_doorlock:stateChanged', function(doorId, state)\n local doorName = exports.ox_doorlock:getDoor(doorId)?.name or 'Unknown'\n local stateText = state == 1 and 'locked' or 'unlocked'\n print(('Door %s (ID: %s) is now %s'):format(doorName, doorId, stateText))\nend)",
|
||||
'js_example' => "on('ox_doorlock:stateChanged', (doorId, state) => {\n const door = exports.ox_doorlock.getDoor(doorId);\n const doorName = door?.name || 'Unknown';\n const stateText = state === 1 ? 'locked' : 'unlocked';\n console.log(`Door \${doorName} (ID: \${doorId}) is now \${stateText}`);\n});",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($events as $eventName => $eventData) {
|
||||
if (strtolower($eventName) === $nameLower) {
|
||||
return array_merge(['name' => $eventName], $eventData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format event info.
|
||||
*/
|
||||
protected function formatEventInfo(array $event, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-event-reference', [
|
||||
'event' => $event,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'event_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_doorlock server event to look up (e.g., "ox_doorlock:stateChanged")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Doorlock\Server;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_doorlock server functions by name. Returns function signature, parameters, return type, and usage examples for server-side door management.')]
|
||||
class GetOxDoorlockServerFunction extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$functionName = $request->get('function_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$function = $this->findFunction($functionName);
|
||||
|
||||
if (! $function) {
|
||||
return Response::text(sprintf("ox_doorlock server function '%s' not found. Check ox_doorlock documentation at https://coxdocs.dev/ox_doorlock", $functionName));
|
||||
}
|
||||
|
||||
$output = $this->formatFunctionInfo($function, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_doorlock server function.
|
||||
*/
|
||||
protected function findFunction(string $name): ?array
|
||||
{
|
||||
$functions = [
|
||||
'getDoor' => [
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Get door data by door ID',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'doorId', 'type' => 'number', 'description' => 'The door ID'],
|
||||
],
|
||||
'returns' => ['type' => 'table|nil', 'description' => 'Door data or nil if not found'],
|
||||
'lua_example' => "local door = exports.ox_doorlock:getDoor(1)\nif door then\n print('Door name: '..door.name)\n print('Door state: '..door.state)\nend",
|
||||
'js_example' => "const door = exports.ox_doorlock.getDoor(1);\nif (door) {\n console.log('Door name: ' + door.name);\n console.log('Door state: ' + door.state);\n}",
|
||||
],
|
||||
'getDoorFromName' => [
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Get door data by door name',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'doorName', 'type' => 'string', 'description' => 'The door name'],
|
||||
],
|
||||
'returns' => ['type' => 'table|nil', 'description' => 'Door data or nil if not found'],
|
||||
'lua_example' => "local door = exports.ox_doorlock:getDoorFromName('mrpd_main')\nif door then\n print('Door ID: '..door.id)\n print('Door is locked: '..tostring(door.state == 1))\nend",
|
||||
'js_example' => "const door = exports.ox_doorlock.getDoorFromName('mrpd_main');\nif (door) {\n console.log('Door ID: ' + door.id);\n console.log('Door is locked: ' + (door.state === 1));\n}",
|
||||
],
|
||||
'editDoor' => [
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Edit door properties by door ID',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'doorId', 'type' => 'number', 'description' => 'The door ID'],
|
||||
['name' => 'data', 'type' => 'table', 'description' => 'Table with properties to update (state, groups, etc.)'],
|
||||
['name' => 'playerId', 'type' => 'number|nil', 'description' => 'Optional player ID who triggered the edit'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'True if door was successfully edited'],
|
||||
'lua_example' => "local success = exports.ox_doorlock:editDoor(1, {\n state = 0, -- Unlocked\n groups = {police = 0} -- Police can use\n})\nif success then\n print('Door edited successfully')\nend",
|
||||
'js_example' => "const success = exports.ox_doorlock.editDoor(1, {\n state: 0, // Unlocked\n groups: {police: 0} // Police can use\n});\nif (success) {\n console.log('Door edited successfully');\n}",
|
||||
],
|
||||
'setDoorState' => [
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Set the lock state of a door',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'doorId', 'type' => 'number', 'description' => 'The door ID'],
|
||||
['name' => 'state', 'type' => 'number', 'description' => '0 = unlocked, 1 = locked'],
|
||||
['name' => 'playerId', 'type' => 'number|nil', 'description' => 'Optional player ID who triggered the state change'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'True if state was successfully changed'],
|
||||
'lua_example' => "local success = exports.ox_doorlock:setDoorState(1, 1) -- Lock door ID 1\nif success then\n print('Door locked successfully')\nend",
|
||||
'js_example' => "const success = exports.ox_doorlock.setDoorState(1, 1); // Lock door ID 1\nif (success) {\n console.log('Door locked successfully');\n}",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($functions as $functionName => $functionData) {
|
||||
if (strtolower($functionName) === $nameLower) {
|
||||
return array_merge(['name' => $functionName], $functionData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format function info.
|
||||
*/
|
||||
protected function formatFunctionInfo(array $function, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-function', [
|
||||
'function' => $function,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'function_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_doorlock server function to look up (e.g., "getDoor", "getDoorFromName", "editDoor", "setDoorState")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Fuel\Client;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_fuel client functions by name. Returns function signature, parameters, return type, and usage examples for vehicle fuel management.')]
|
||||
class GetOxFuelClientFunction extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$functionName = $request->get('function_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$function = $this->findFunction($functionName);
|
||||
|
||||
if (! $function) {
|
||||
return Response::text(sprintf("ox_fuel client function '%s' not found. Check ox_fuel documentation at https://coxdocs.dev/ox_fuel", $functionName));
|
||||
}
|
||||
|
||||
$output = $this->formatFunctionInfo($function, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_fuel client function.
|
||||
*/
|
||||
protected function findFunction(string $name): ?array
|
||||
{
|
||||
$functions = [
|
||||
'setMoneyCheck' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Set a custom function to check if a player has enough money to pay for fuel',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'callback', 'type' => 'function', 'description' => 'Function(amount: number) -> boolean that returns true if player can afford fuel'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => "exports.ox_fuel:setMoneyCheck(function(amount)\n local playerMoney = exports.framework:GetPlayerMoney()\n return playerMoney >= amount\nend)",
|
||||
'js_example' => "exports.ox_fuel.setMoneyCheck((amount) => {\n const playerMoney = exports.framework.GetPlayerMoney();\n return playerMoney >= amount;\n});",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($functions as $functionName => $functionData) {
|
||||
if (strtolower($functionName) === $nameLower) {
|
||||
return array_merge(['name' => $functionName], $functionData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format function info.
|
||||
*/
|
||||
protected function formatFunctionInfo(array $function, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-function', [
|
||||
'function' => $function,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'function_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_fuel client function to look up (e.g., "setMoneyCheck")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Fuel\Server;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_fuel server functions by name. Returns function signature, parameters, return type, and usage examples for server-side fuel management.')]
|
||||
class GetOxFuelServerFunction extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$functionName = $request->get('function_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$function = $this->findFunction($functionName);
|
||||
|
||||
if (! $function) {
|
||||
return Response::text(sprintf("ox_fuel server function '%s' not found. Check ox_fuel documentation at https://coxdocs.dev/ox_fuel", $functionName));
|
||||
}
|
||||
|
||||
$output = $this->formatFunctionInfo($function, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_fuel server function.
|
||||
*/
|
||||
protected function findFunction(string $name): ?array
|
||||
{
|
||||
$functions = [
|
||||
'setPaymentMethod' => [
|
||||
'namespace' => 'Server',
|
||||
'description' => 'Set a custom payment method for fuel purchases',
|
||||
'side' => 'server',
|
||||
'parameters' => [
|
||||
['name' => 'callback', 'type' => 'function', 'description' => 'Function(source: number, amount: number) -> boolean that handles payment and returns true if successful'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => "exports.ox_fuel:setPaymentMethod(function(source, amount)\n local success = exports.framework:RemovePlayerMoney(source, amount)\n if success then\n print('Player '..source..' paid $'..amount..' for fuel')\n end\n return success\nend)",
|
||||
'js_example' => "exports.ox_fuel.setPaymentMethod((source, amount) => {\n const success = exports.framework.RemovePlayerMoney(source, amount);\n if (success) {\n console.log(`Player \${source} paid $\${amount} for fuel`);\n }\n return success;\n});",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($functions as $functionName => $functionData) {
|
||||
if (strtolower($functionName) === $nameLower) {
|
||||
return array_merge(['name' => $functionName], $functionData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format function info.
|
||||
*/
|
||||
protected function formatFunctionInfo(array $function, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-function', [
|
||||
'function' => $function,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'function_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_fuel server function to look up (e.g., "setPaymentMethod")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\COX\Target\Client;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('Look up ox_target client functions by name. Returns function signature, parameters, return type, and usage examples for targeting/third-eye interaction system.')]
|
||||
class GetOxTargetClientFunction extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$functionName = $request->get('function_name');
|
||||
$language = $request->get('language', 'lua');
|
||||
|
||||
$function = $this->findFunction($functionName);
|
||||
|
||||
if (! $function) {
|
||||
return Response::text(sprintf("ox_target client function '%s' not found. Check ox_target documentation at https://coxdocs.dev/ox_target", $functionName));
|
||||
}
|
||||
|
||||
$output = $this->formatFunctionInfo($function, $language);
|
||||
|
||||
return Response::text($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an ox_target client function.
|
||||
*/
|
||||
protected function findFunction(string $name): ?array
|
||||
{
|
||||
$functions = [
|
||||
'disableTargeting' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Disables or enables the targeting system',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'disabled', 'type' => 'boolean', 'description' => 'true to disable, false to enable'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => 'exports.ox_target:disableTargeting(true) -- Disable targeting',
|
||||
'js_example' => 'exports.ox_target.disableTargeting(true); // Disable targeting',
|
||||
],
|
||||
'isActive' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Check if the targeting system is currently active',
|
||||
'side' => 'client',
|
||||
'parameters' => [],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'true if targeting is active'],
|
||||
'lua_example' => "local active = exports.ox_target:isActive()\nif active then\n print('Targeting is active')\nend",
|
||||
'js_example' => "const active = exports.ox_target.isActive();\nif (active) {\n console.log('Targeting is active');\n}",
|
||||
],
|
||||
'addGlobalOption' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add a global target option that appears on all entities',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Target option configuration'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => "exports.ox_target:addGlobalOption({\n name = 'greet',\n icon = 'fas fa-hand-wave',\n label = 'Wave',\n onSelect = function()\n print('You waved!')\n end\n})",
|
||||
'js_example' => "exports.ox_target.addGlobalOption({\n name: 'greet',\n icon: 'fas fa-hand-wave',\n label: 'Wave',\n onSelect: () => {\n console.log('You waved!');\n }\n});",
|
||||
],
|
||||
'addGlobalPed' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to all peds',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Option ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addGlobalPed({\n {\n name = 'talk',\n icon = 'fas fa-comment',\n label = 'Talk',\n onSelect = function(data)\n print('Talking to ped: '..data.entity)\n end\n }\n})",
|
||||
'js_example' => "const id = exports.ox_target.addGlobalPed([\n {\n name: 'talk',\n icon: 'fas fa-comment',\n label: 'Talk',\n onSelect: (data) => {\n console.log('Talking to ped: ' + data.entity);\n }\n }\n]);",
|
||||
],
|
||||
'addGlobalVehicle' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to all vehicles',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Option ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addGlobalVehicle({\n {\n name = 'lockpick',\n icon = 'fas fa-lock',\n label = 'Lockpick Vehicle',\n canInteract = function(entity)\n return GetVehicleDoorLockStatus(entity) == 2\n end,\n onSelect = function(data)\n -- Lockpick logic\n end\n }\n})",
|
||||
'js_example' => "const id = exports.ox_target.addGlobalVehicle([\n {\n name: 'lockpick',\n icon: 'fas fa-lock',\n label: 'Lockpick Vehicle',\n canInteract: (entity) => {\n return GetVehicleDoorLockStatus(entity) === 2;\n },\n onSelect: (data) => {\n // Lockpick logic\n }\n }\n]);",
|
||||
],
|
||||
'addGlobalObject' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to all objects',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Option ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addGlobalObject({\n {\n name = 'examine',\n icon = 'fas fa-search',\n label = 'Examine',\n onSelect = function(data)\n print('Examining object')\n end\n }\n})",
|
||||
'js_example' => "const id = exports.ox_target.addGlobalObject([\n {\n name: 'examine',\n icon: 'fas fa-search',\n label: 'Examine',\n onSelect: (data) => {\n console.log('Examining object');\n }\n }\n]);",
|
||||
],
|
||||
'addGlobalPlayer' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to all players',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Option ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addGlobalPlayer({\n {\n name = 'givemoney',\n icon = 'fas fa-dollar-sign',\n label = 'Give Money',\n onSelect = function(data)\n -- Give money logic\n end\n }\n})",
|
||||
'js_example' => "const id = exports.ox_target.addGlobalPlayer([\n {\n name: 'givemoney',\n icon: 'fas fa-dollar-sign',\n label: 'Give Money',\n onSelect: (data) => {\n // Give money logic\n }\n }\n]);",
|
||||
],
|
||||
'addModel' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to specific entity models',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'models', 'type' => 'string|table', 'description' => 'Model hash or array of model hashes'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Option ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addModel('prop_atm_01', {\n {\n name = 'atm',\n icon = 'fas fa-credit-card',\n label = 'Use ATM',\n onSelect = function()\n -- Open ATM interface\n end\n }\n})",
|
||||
'js_example' => "const id = exports.ox_target.addModel('prop_atm_01', [\n {\n name: 'atm',\n icon: 'fas fa-credit-card',\n label: 'Use ATM',\n onSelect: () => {\n // Open ATM interface\n }\n }\n]);",
|
||||
],
|
||||
'addEntity' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to a specific entity',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'entity', 'type' => 'number', 'description' => 'Entity handle'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => "local ped = PlayerPedId()\nexports.ox_target:addEntity(ped, {\n {\n name = 'selfie',\n icon = 'fas fa-camera',\n label = 'Take Selfie',\n onSelect = function()\n print('Taking selfie')\n end\n }\n})",
|
||||
'js_example' => "const ped = PlayerPedId();\nexports.ox_target.addEntity(ped, [\n {\n name: 'selfie',\n icon: 'fas fa-camera',\n label: 'Take Selfie',\n onSelect: () => {\n console.log('Taking selfie');\n }\n }\n]);",
|
||||
],
|
||||
'addLocalEntity' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add target options to a networked entity (client-side only)',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'netId', 'type' => 'number', 'description' => 'Network ID'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => "local netId = NetworkGetNetworkIdFromEntity(entity)\nexports.ox_target:addLocalEntity(netId, {\n {\n name = 'interact',\n icon = 'fas fa-hand',\n label = 'Interact',\n onSelect = function()\n print('Interacting')\n end\n }\n})",
|
||||
'js_example' => "const netId = NetworkGetNetworkIdFromEntity(entity);\nexports.ox_target.addLocalEntity(netId, [\n {\n name: 'interact',\n icon: 'fas fa-hand',\n label: 'Interact',\n onSelect: () => {\n console.log('Interacting');\n }\n }\n]);",
|
||||
],
|
||||
'addSphereZone' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add a sphere zone with target options',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'name', 'type' => 'string', 'description' => 'Unique zone name'],
|
||||
['name' => 'coords', 'type' => 'vector3', 'description' => 'Zone center coordinates'],
|
||||
['name' => 'radius', 'type' => 'number', 'description' => 'Zone radius'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
['name' => 'zoneOptions', 'type' => 'table', 'description' => 'Zone configuration'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Zone ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addSphereZone('bank_atm', vector3(150.0, -1040.0, 29.5), 2.0, {\n {\n name = 'atm',\n icon = 'fas fa-credit-card',\n label = 'Use ATM',\n onSelect = function()\n print('Opening ATM')\n end\n }\n}, {})",
|
||||
'js_example' => "const id = exports.ox_target.addSphereZone('bank_atm', [150.0, -1040.0, 29.5], 2.0, [\n {\n name: 'atm',\n icon: 'fas fa-credit-card',\n label: 'Use ATM',\n onSelect: () => {\n console.log('Opening ATM');\n }\n }\n], {});",
|
||||
],
|
||||
'addBoxZone' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add a box zone with target options',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'name', 'type' => 'string', 'description' => 'Unique zone name'],
|
||||
['name' => 'coords', 'type' => 'vector3', 'description' => 'Zone center coordinates'],
|
||||
['name' => 'size', 'type' => 'vector3', 'description' => 'Zone size (length, width, height)'],
|
||||
['name' => 'rotation', 'type' => 'number', 'description' => 'Zone rotation'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
['name' => 'zoneOptions', 'type' => 'table', 'description' => 'Zone configuration'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Zone ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addBoxZone('garage', vector3(215.0, -809.0, 30.7), vector3(5.0, 10.0, 3.0), 0, {\n {\n name = 'vehicles',\n icon = 'fas fa-car',\n label = 'Garage',\n onSelect = function()\n print('Opening garage')\n end\n }\n}, {})",
|
||||
'js_example' => "const id = exports.ox_target.addBoxZone('garage', [215.0, -809.0, 30.7], [5.0, 10.0, 3.0], 0, [\n {\n name: 'vehicles',\n icon: 'fas fa-car',\n label: 'Garage',\n onSelect: () => {\n console.log('Opening garage');\n }\n }\n], {});",
|
||||
],
|
||||
'addPolyZone' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Add a polygon zone with target options',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'name', 'type' => 'string', 'description' => 'Unique zone name'],
|
||||
['name' => 'points', 'type' => 'table', 'description' => 'Array of vector2 points'],
|
||||
['name' => 'options', 'type' => 'table', 'description' => 'Array of target options'],
|
||||
['name' => 'zoneOptions', 'type' => 'table', 'description' => 'Zone configuration'],
|
||||
],
|
||||
'returns' => ['type' => 'number', 'description' => 'Zone ID'],
|
||||
'lua_example' => "local id = exports.ox_target:addPolyZone('parking', {\n vector2(200.0, -800.0),\n vector2(220.0, -800.0),\n vector2(220.0, -820.0),\n vector2(200.0, -820.0)\n}, {\n {\n name = 'park',\n icon = 'fas fa-parking',\n label = 'Park Vehicle',\n onSelect = function()\n print('Parking vehicle')\n end\n }\n}, {})",
|
||||
'js_example' => "const id = exports.ox_target.addPolyZone('parking', [\n [200.0, -800.0],\n [220.0, -800.0],\n [220.0, -820.0],\n [200.0, -820.0]\n], [\n {\n name: 'park',\n icon: 'fas fa-parking',\n label: 'Park Vehicle',\n onSelect: () => {\n console.log('Parking vehicle');\n }\n }\n], {});",
|
||||
],
|
||||
'removeZone' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Remove a zone by ID',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'id', 'type' => 'number', 'description' => 'Zone ID to remove'],
|
||||
],
|
||||
'returns' => ['type' => 'void', 'description' => 'No return value'],
|
||||
'lua_example' => 'exports.ox_target:removeZone(zoneId)',
|
||||
'js_example' => 'exports.ox_target.removeZone(zoneId);',
|
||||
],
|
||||
'zoneExists' => [
|
||||
'namespace' => 'Client',
|
||||
'description' => 'Check if a zone exists by name',
|
||||
'side' => 'client',
|
||||
'parameters' => [
|
||||
['name' => 'name', 'type' => 'string', 'description' => 'Zone name'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'true if zone exists'],
|
||||
'lua_example' => "local exists = exports.ox_target:zoneExists('bank_atm')\nif exists then\n print('Zone exists')\nend",
|
||||
'js_example' => "const exists = exports.ox_target.zoneExists('bank_atm');\nif (exists) {\n console.log('Zone exists');\n}",
|
||||
],
|
||||
];
|
||||
|
||||
$nameLower = strtolower($name);
|
||||
|
||||
foreach ($functions as $functionName => $functionData) {
|
||||
if (strtolower($functionName) === $nameLower) {
|
||||
return array_merge(['name' => $functionName], $functionData);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format function info.
|
||||
*/
|
||||
protected function formatFunctionInfo(array $function, string $language): string
|
||||
{
|
||||
return view('mcp.cox.cox-function', [
|
||||
'function' => $function,
|
||||
'language' => $language,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\JsonSchema\JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'function_name' => $schema
|
||||
->string()
|
||||
->description('The name of the ox_target client function to look up (e.g., "addSphereZone", "addGlobalVehicle", "addModel")')
|
||||
->required(),
|
||||
'language' => $schema
|
||||
->string()
|
||||
->enum(['lua', 'js'])
|
||||
->description('The scripting language for code examples')
|
||||
->default('lua'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Doorlock\Client\GetOxDoorlockClientFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_doorlock client function returns response with content', function () {
|
||||
$tool = new GetOxDoorlockClientFunction;
|
||||
$request = new Request(['function_name' => 'getClosestDoor']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock client function handles unknown function', function () {
|
||||
$tool = new GetOxDoorlockClientFunction;
|
||||
$request = new Request(['function_name' => 'NonExistentFunction123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_doorlock client function works with pickClosestDoor', function () {
|
||||
$tool = new GetOxDoorlockClientFunction;
|
||||
$request = new Request(['function_name' => 'pickClosestDoor']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock client function works with useClosestDoor', function () {
|
||||
$tool = new GetOxDoorlockClientFunction;
|
||||
$request = new Request(['function_name' => 'useClosestDoor']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock client function supports javascript examples', function () {
|
||||
$tool = new GetOxDoorlockClientFunction;
|
||||
$request = new Request(['function_name' => 'getClosestDoor', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Doorlock\Server\GetOxDoorlockServerEvent;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_doorlock server event returns response with content', function () {
|
||||
$tool = new GetOxDoorlockServerEvent;
|
||||
$request = new Request(['event_name' => 'ox_doorlock:stateChanged']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock server event handles unknown event', function () {
|
||||
$tool = new GetOxDoorlockServerEvent;
|
||||
$request = new Request(['event_name' => 'NonExistentEvent123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_doorlock server event supports javascript examples', function () {
|
||||
$tool = new GetOxDoorlockServerEvent;
|
||||
$request = new Request(['event_name' => 'ox_doorlock:stateChanged', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Doorlock\Server\GetOxDoorlockServerFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_doorlock server function returns response with content', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'getDoor']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock server function handles unknown function', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'NonExistentFunction123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_doorlock server function works with getDoorFromName', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'getDoorFromName']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock server function works with editDoor', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'editDoor']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock server function works with setDoorState', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'setDoorState']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_doorlock server function supports javascript examples', function () {
|
||||
$tool = new GetOxDoorlockServerFunction;
|
||||
$request = new Request(['function_name' => 'getDoor', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Fuel\Client\GetOxFuelClientFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_fuel client function returns response with content', function () {
|
||||
$tool = new GetOxFuelClientFunction;
|
||||
$request = new Request(['function_name' => 'setMoneyCheck']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_fuel client function handles unknown function', function () {
|
||||
$tool = new GetOxFuelClientFunction;
|
||||
$request = new Request(['function_name' => 'NonExistentFunction123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_fuel client function supports javascript examples', function () {
|
||||
$tool = new GetOxFuelClientFunction;
|
||||
$request = new Request(['function_name' => 'setMoneyCheck', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Fuel\Server\GetOxFuelServerFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_fuel server function returns response with content', function () {
|
||||
$tool = new GetOxFuelServerFunction;
|
||||
$request = new Request(['function_name' => 'setPaymentMethod']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_fuel server function handles unknown function', function () {
|
||||
$tool = new GetOxFuelServerFunction;
|
||||
$request = new Request(['function_name' => 'NonExistentFunction123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_fuel server function supports javascript examples', function () {
|
||||
$tool = new GetOxFuelServerFunction;
|
||||
$request = new Request(['function_name' => 'setPaymentMethod', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\COX\Target\Client\GetOxTargetClientFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('get ox_target client function returns response with content', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addSphereZone']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function handles unknown function', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'NonExistentFunction123']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('not found');
|
||||
});
|
||||
|
||||
it('get ox_target client function works with addGlobalVehicle', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addGlobalVehicle']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function works with addModel', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addModel']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function works with addBoxZone', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addBoxZone']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function works with addPolyZone', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addPolyZone']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function works with isActive', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'isActive']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('get ox_target client function supports javascript examples', function () {
|
||||
$tool = new GetOxTargetClientFunction;
|
||||
$request = new Request(['function_name' => 'addEntity', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
Reference in new issue
Block a user