dolibarr 24.0.0-beta
mcptool.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2026 Nick Fragoulis
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY, without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
32abstract class McpTool
33{
35 protected $db;
36
38 protected $user;
39
41 protected $conf;
42
50 public function __construct($db, $user, $conf)
51 {
52 $this->db = $db;
53 $this->user = $user;
54 $this->conf = $conf;
55 }
56
65 abstract public function getDefinitions(): array;
66
78 abstract public function execute(string $toolName, array $args);
79
86 public function getCategories(): array
87 {
88 return ['global']; // Default
89 }
90
105 public function isSystem()
106 {
107 return false;
108 }
109}
Abstract base class for all MCP (Model Context Protocol) tools.
execute(string $toolName, array $args)
Execute a specific tool.
getDefinitions()
Return the list of tools provided by this class.
__construct($db, $user, $conf)
Constructor.
isSystem()
Return true if this is a system/infrastructure tool that must always remain visible and executable re...
getCategories()
Return categories this tool belongs to.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:426
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:134