dolibarr 25.0.0-alpha
ToolThirdParty Class Reference

Class ToolThirdParty. More...

Inheritance diagram for ToolThirdParty:
Collaboration diagram for ToolThirdParty:

Public Member Functions

 __construct ($db, $user)
 Constructor.
 
 getDefinitions ()
 Returns an array of tool definitions, including name, description, and input schema.
 
 getRequiredRights (string $toolName)
 Third-party reads and writes.
 
 writeConfirmationPreview (string $toolName, array $args)
 Preview of the third-party record this call would write.
 
 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

 search (array $args, int $count=0)
 Search for third parties based on provided criteria.
 
 getDetails (array $args)
 Fetch details for a specific third party (Societe).
 
 listContacts (array $args)
 List all contacts for a given thirdparty.
 
 addContact (array $args)
 Add a contact linked to a thirdparty.
 

Additional Inherited Members

- Public Attributes inherited from McpTool
const RIGHTS_UNDECLARED = 'undeclared'
 Default of getRequiredRights(): the class never declared anything, deny.
 
const NO_WRITE = ''
 Returned by writeConfirmationPreview() when the tool writes nothing.
 

Detailed Description

Class ToolThirdParty.

Provides various tools related to Dolibarr categories.

Definition at line 35 of file thirdparty.class.php.

Constructor & Destructor Documentation

◆ __construct()

ToolThirdParty::__construct ( $db,
$user )

Constructor.

Parameters
DoliDB$dbDatabase handler
User$userUser object for permission checks

Definition at line 44 of file thirdparty.class.php.

References user.

Member Function Documentation

◆ addContact()

ToolThirdParty::addContact ( array $args)
private

Add a contact linked to a thirdparty.

Parameters
array{thirdparty_identifier:int|string,firstname:string,lastname:string,email?:string,phone?:string}$args Arguments array (identifier, firstname, lastname required).
Returns
array{status:string,message:string,id:int,url?:string}|array{error:string}

Definition at line 698 of file thirdparty.class.php.

References user.

Referenced by execute().

◆ execute()

ToolThirdParty::execute ( string $name,
array $args )

Executes the requested tool function based on its name.

Parameters
string$nameThe name of the tool to execute.
array<string,mixed>$args The arguments for the tool (key-value pairs).
Returns
mixed The result of the tool execution (usually an array) or an error array.

Reimplemented from McpTool.

Definition at line 235 of file thirdparty.class.php.

References addContact(), getDetails(), listContacts(), and search().

◆ getCategories()

ToolThirdParty::getCategories ( )

Return categories this tool belongs to.

Used by the intent parser to filter available tools.

Returns
array<string> List of categories (e.g., ['billing', 'commercial'])

Reimplemented from McpTool.

Definition at line 223 of file thirdparty.class.php.

◆ getDefinitions()

ToolThirdParty::getDefinitions ( )

Returns an array of tool definitions, including name, description, and input schema.

Returns
list<array<string, mixed>> Array of tool definitions.

Reimplemented from McpTool.

Definition at line 55 of file thirdparty.class.php.

◆ getDetails()

ToolThirdParty::getDetails ( array $args)
private

Fetch details for a specific third party (Societe).

Parameters
array{idint|string} $args Arguments array containing the thirdparty ID.
Returns
array{error:string}|array<string,mixed>

Definition at line 383 of file thirdparty.class.php.

References user.

Referenced by execute().

◆ getRequiredRights()

ToolThirdParty::getRequiredRights ( string $toolName)

Third-party reads and writes.

Parameters
string$toolNameTool being executed.
Returns
array<int,array<int,string>>|string Rights required, or a RIGHTS_* constant.

Reimplemented from McpTool.

Definition at line 177 of file thirdparty.class.php.

References McpTool\RIGHTS_UNDECLARED.

◆ listContacts()

ToolThirdParty::listContacts ( array $args)
private

List all contacts for a given thirdparty.

Parameters
array{idint|string} $args Arguments array containing the thirdparty ID.
Returns
array{error: string}|list<array<string, int|string>>

Definition at line 618 of file thirdparty.class.php.

References dol_syslog(), getEntity(), and user.

Referenced by execute().

◆ search()

ToolThirdParty::search ( array $args,
int $count = 0 )
private

Search for third parties based on provided criteria.

Parameters
array{query:string|int,type?:string,country_code?:string,limit?:int|string}$args Array of arguments:
  • query: Search string or ID
  • country_code: ISO country code on 2 chars (FR, US, GR...)
  • type: 'customer', 'prospect', 'supplier'
  • limit: Limit results (default 5)
int$countIf set to 1, returns only the count of results.
Returns
array{error:string}|array{count:int}|list<array{id:int,name:string,alias:string,code_cust:string,code_sup:string,email:string,type:string,url:string}>

Definition at line 268 of file thirdparty.class.php.

References dol_syslog(), getEntity(), and user.

Referenced by execute().

◆ writeConfirmationPreview()

ToolThirdParty::writeConfirmationPreview ( string $toolName,
array $args )

Preview of the third-party record this call would write.

Parameters
string$toolNameTool that would run.
array<string,mixed>$args Arguments it would run with.
Returns
string Preview text, or McpTool\NO_WRITE for a read.

Reimplemented from McpTool.

Definition at line 199 of file thirdparty.class.php.

References McpTool\NO_WRITE.


The documentation for this class was generated from the following file: