|
dolibarr 25.0.0-alpha
|
Tool class for CRUD operations on Dolibarr objects TODO Remove all tools in this file. More...


Public Member Functions | |
| __construct (DoliDB $db, $user=null, $conf=null) | |
| Constructor. | |
| getDefinitions () | |
| Returns an array of tool definitions, including name, description, and input schema. | |
| getCategories () | |
| Return categories this tool belongs to. | |
| execute (string $name, array $args) | |
| Executes the requested tool function based on its name. | |
Public Member Functions inherited from McpTool | |
| __construct ($db, $user, $conf) | |
| Constructor. | |
| isSystem () | |
| Return true if this is a system/infrastructure tool that must always remain visible and executable regardless of the admin allow-list. | |
Private Member Functions | |
| addLineItem (array $args) | |
| Entry point for the 'add_line_item' tool. | |
| findProduct ($identifier) | |
| Find a product by various identifiers (ID, Ref, Barcode, Label). | |
| deleteObject (array $args) | |
| Delete a document object. | |
| checkPermission (string $type) | |
| Check if the current user has permission for the given object type. | |
| instantiate (string $type) | |
| Factory Helper to instantiate Dolibarr objects. | |
Tool class for CRUD operations on Dolibarr objects TODO Remove all tools in this file.
Must be into the objectname.class.php to follow the same structure than APIs.
Definition at line 36 of file crud_objects.class.php.
| ToolCrudObjects::__construct | ( | DoliDB | $db, |
| $user = null, | |||
| $conf = null ) |
Constructor.
Aligned with McpHandler's instantiation contract: new $className($db, $user, $conf). Accepting $user via DI allows this tool to work in HTTP MCP context where no PHP web session exists. Some sibling tool classes (ToolThirdParty, ToolCategories, ToolProducts) already use this signature; this aligns ToolCrudObjects with them.
| DoliDB | $db | Database handler |
| User | null | $user | Service user provided by McpHandler (from AI_MCP_USER_ID) |
| Conf | null | $conf | Dolibarr config (optional) |
Definition at line 50 of file crud_objects.class.php.
|
private |
Entry point for the 'add_line_item' tool.
Adds line to an already existing object. Instantiates the document and calls the line processing helper.
| array{object_type:string,parent_id:int,product_id?:int,description?:string,quantity?:float|int,unit_price?:float|int,vat_rate?:float|int} | $args Tool arguments for adding a line item |
Definition at line 708 of file crud_objects.class.php.
References string.
Referenced by execute().
|
private |
Check if the current user has permission for the given object type.
| string | $type | Object type key. |
Definition at line 894 of file crud_objects.class.php.
References user.
|
private |
Delete a document object.
| array{object_type | string, id: int|string} $args Arguments containing type and ID. |
Definition at line 849 of file crud_objects.class.php.
Referenced by execute().
| ToolCrudObjects::execute | ( | string | $name, |
| array | $args ) |
Executes the requested tool function based on its name.
| string | $name | The name of the tool to execute. |
| array<string,mixed> | $args The arguments for the tool (key-value pairs). |
Reimplemented from McpTool.
Definition at line 335 of file crud_objects.class.php.
References $conf, $mysoc, addLineItem(), deleteObject(), and user.
|
private |
Find a product by various identifiers (ID, Ref, Barcode, Label).
| string | int | $identifier | The search term (ID, ref, barcode, etc.). |
Definition at line 757 of file crud_objects.class.php.
References getEntity().
| ToolCrudObjects::getCategories | ( | ) |
Return categories this tool belongs to.
Used by the intent parser to filter available tools.
Reimplemented from McpTool.
Definition at line 323 of file crud_objects.class.php.
| ToolCrudObjects::getDefinitions | ( | ) |
Returns an array of tool definitions, including name, description, and input schema.
Reimplemented from McpTool.
Definition at line 152 of file crud_objects.class.php.
|
private |
Factory Helper to instantiate Dolibarr objects.
| string | $type | Object type key (e.g., 'proposal', 'invoice'). |
| Exception | If the type is unknown or class not found. |
Definition at line 914 of file crud_objects.class.php.
References string.