|
dolibarr 25.0.0-alpha
|
Class ToolApiBridge. More...


Public Member Functions | |
| __construct ($db, $user=null, $conf=null) | |
| Constructor. | |
| getDefinitions () | |
| Returns tool definitions derived from the enabled REST API endpoints. | |
| getCategories () | |
| Return categories this tool belongs to. | |
| execute (string $name, array $args) | |
| Execute a bridged tool: authenticate the service user, call the API method in-process with positional arguments, catch RestException. | |
Public Member Functions inherited from McpTool | |
| 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 | |
| loadApiRuntime () | |
| Load the REST API runtime (Restler autoloader + DolibarrApi base classes), mirroring the bootstrap sequence of htdocs/api/index.php, so that the endpoint classes (which extend DolibarrApi and throw RestException) can be loaded and executed outside the Restler HTTP runtime. | |
| buildToolDefinition (array $ep, string $key, string $method, string $toolname, array $meta=[]) | |
| Build one MCP tool definition from an API class method: reflection + docblock give the skeleton, then the hand-written per-method enrichment is merged over it ('description' appended, 'params' overriding parameter docs, shared common docs as last fallback). | |
| docTypeToJson (string $type) | |
| Convert a docblock type to a JSON Schema type. | |
Class ToolApiBridge.
Exposes enabled REST API endpoints as MCP tools (read-only POC).
Definition at line 62 of file api_bridge.class.php.
| ToolApiBridge::__construct | ( | $db, | |
| $user = null, | |||
| $conf = null ) |
Constructor.
| DoliDB | $db | Database handler |
| User | null | $user | Service user provided by McpHandler |
| Conf | null | $conf | Dolibarr config (optional) |
Reimplemented from McpTool.
Definition at line 251 of file api_bridge.class.php.
|
private |
Build one MCP tool definition from an API class method: reflection + docblock give the skeleton, then the hand-written per-method enrichment is merged over it ('description' appended, 'params' overriding parameter docs, shared common docs as last fallback).
| array{module:string,path:string,class:string,label:string} | $ep Endpoint entry | |
| string | $key | Endpoint key (e.g. 'thirdparties') |
| string | $method | Whitelisted API method name (e.g. 'index', 'get') |
| string | $toolname | Generated tool name |
| array{suffix?:string,description?:string,params?:array<string,string>} | $meta Hand-written enrichment for this method |
Definition at line 341 of file api_bridge.class.php.
References docTypeToJson(), and string.
Referenced by getDefinitions().
|
private |
Convert a docblock type to a JSON Schema type.
| string | $type | Docblock type (may be a union like int|string) |
Definition at line 426 of file api_bridge.class.php.
Referenced by buildToolDefinition().
| ToolApiBridge::execute | ( | string | $name, |
| array | $args ) |
Execute a bridged tool: authenticate the service user, call the API method in-process with positional arguments, catch RestException.
| string | $name | The tool name (e.g. 'api_thirdparties_list'). |
| array<string,mixed> | $args The tool arguments (named). |
Reimplemented from McpTool.
Definition at line 459 of file api_bridge.class.php.
References getDefinitions(), getDolGlobalInt(), and loadApiRuntime().
| ToolApiBridge::getCategories | ( | ) |
Return categories this tool belongs to.
Reimplemented from McpTool.
Definition at line 446 of file api_bridge.class.php.
| ToolApiBridge::getDefinitions | ( | ) |
Returns tool definitions derived from the enabled REST API endpoints.
Reimplemented from McpTool.
Definition at line 282 of file api_bridge.class.php.
References buildToolDefinition(), getDolGlobalInt(), isModEnabled(), and loadApiRuntime().
Referenced by execute().
|
private |
Load the REST API runtime (Restler autoloader + DolibarrApi base classes), mirroring the bootstrap sequence of htdocs/api/index.php, so that the endpoint classes (which extend DolibarrApi and throw RestException) can be loaded and executed outside the Restler HTTP runtime.
Definition at line 268 of file api_bridge.class.php.
Referenced by execute(), and getDefinitions().