dolibarr 25.0.0-alpha
ToolCoffeeMaker Class Reference

Class ToolCoffeeMaker. More...

Inheritance diagram for ToolCoffeeMaker:
Collaboration diagram for ToolCoffeeMaker:

Public Member Functions

 __construct (DoliDB $db)
 Constructor.
 
 getDefinitions ()
 Returns tool definitions if the hidden constant is enabled.
 
 getRequiredRights (string $toolName)
 No business data.
 
 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.
 
 writeConfirmationPreview (string $toolName, array $args)
 Preview of what a call would write, or NO_WRITE for a read tool.
 

Public Attributes

const COFFEE_TYPES
 Beverages the bridge accepts; the Home Assistant script receives the value verbatim as coffee_type and decides what its machine can brew.
 
- 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.
 

Private Member Functions

 brewCoffee (array $args)
 Triggers the Home Assistant API dynamically using stored configuration.
 

Detailed Description

Class ToolCoffeeMaker.

Easter Egg tool to bridge Dolibarr MCP with local Home Assistant coffee configurations.

Definition at line 31 of file coffeemaker.class.php.

Constructor & Destructor Documentation

◆ __construct()

ToolCoffeeMaker::__construct ( DoliDB $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 51 of file coffeemaker.class.php.

Member Function Documentation

◆ brewCoffee()

ToolCoffeeMaker::brewCoffee ( array $args)
private

Triggers the Home Assistant API dynamically using stored configuration.

Parameters
array<string,mixed>$args Input filters (type, intensity)
Returns
array<string, string> Status message or error description.

Definition at line 143 of file coffeemaker.class.php.

References dol_syslog(), getDolGlobalString(), and getURLContent().

Referenced by execute().

◆ execute()

ToolCoffeeMaker::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.
Returns
mixed The result of the tool execution or an error array.

Reimplemented from McpTool.

Definition at line 122 of file coffeemaker.class.php.

References brewCoffee(), and getDolGlobalInt().

◆ getCategories()

ToolCoffeeMaker::getCategories ( )

Return categories this tool belongs to.

Returns
array<string> List of categories

Reimplemented from McpTool.

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

◆ getDefinitions()

ToolCoffeeMaker::getDefinitions ( )

Returns tool definitions if the hidden constant is enabled.

Returns
list<array<string, mixed>> Array of tool definitions or empty array if hidden.

Reimplemented from McpTool.

Definition at line 61 of file coffeemaker.class.php.

References COFFEE_TYPES, and getDolGlobalInt().

◆ getRequiredRights()

ToolCoffeeMaker::getRequiredRights ( string $toolName)

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 100 of file coffeemaker.class.php.


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