dolibarr 25.0.0-alpha
ToolConversation Class Reference
Inheritance diagram for ToolConversation:
Collaboration diagram for ToolConversation:

Public Member Functions

 getDefinitions ()
 Defines the conversational tools available to the AI.
 
 getRequiredRights (string $toolName)
 Protocol tools: no business data.
 
 getCategories ()
 Return categories this tool belongs to.
 
 isSystem ()
 Conversation tools are system-level infrastructure.
 
 execute (string $name, array $args)
 Executes a conversational tool.
 
- Public Member Functions inherited from McpTool
 __construct ($db, $user, $conf)
 Constructor.
 
 writeConfirmationPreview (string $toolName, array $args)
 Preview of what a call would write, or NO_WRITE for a read tool.
 

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

Definition at line 29 of file conversation.class.php.

Member Function Documentation

◆ execute()

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

Executes a conversational tool.

Since these tools don't perform backend actions, this method simply packages the provided arguments into a structured array for the MCP server to send to the client.

Parameters
string$nameThe name of the tool to execute.
array<string,mixed>$args The arguments for the tool (key-value pairs).
Returns
array{tool: string, arguments: array<string, mixed>}|null A structured command array or null if the tool is not found.

Reimplemented from McpTool.

Definition at line 154 of file conversation.class.php.

◆ getCategories()

ToolConversation::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 121 of file conversation.class.php.

◆ getDefinitions()

ToolConversation::getDefinitions ( )

Defines the conversational tools available to the AI.

These tools control the interaction flow with the end-user.

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

Reimplemented from McpTool.

Definition at line 37 of file conversation.class.php.

◆ getRequiredRights()

ToolConversation::getRequiredRights ( string $toolName)

Protocol tools: no business data.

Parameters
string$toolNameTool being executed.
Returns
array<int,array<int,string>>|string Empty: no right required.

Reimplemented from McpTool.

Definition at line 110 of file conversation.class.php.

◆ isSystem()

ToolConversation::isSystem ( )

Conversation tools are system-level infrastructure.

They must always be available so the assistant can communicate with the user (send replies, ask clarifying questions, request confirmation for destructive actions, reject out-of-scope queries) regardless of which tools are enabled or disabled in the admin allow-list.

McpHandler reads this at runtime — no tool names are hardcoded there. Any future tool class that provides similar infrastructure simply overrides this method to return true; no other file needs to change.

Returns
bool

Reimplemented from McpTool.

Definition at line 139 of file conversation.class.php.


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