54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
|
#ifndef OPENMANUS_TOOL_BASE_H
|
|||
|
#define OPENMANUS_TOOL_BASE_H
|
|||
|
|
|||
|
#include <string>
|
|||
|
#include <vector>
|
|||
|
#include <functional>
|
|||
|
#include "mcp/include/mcp_message.h"
|
|||
|
#include "mcp/include/mcp_tool.h"
|
|||
|
|
|||
|
namespace openmanus {
|
|||
|
|
|||
|
/**
|
|||
|
* @class ToolBase
|
|||
|
* @brief 工具的基类,定义了所有工具的基本接口
|
|||
|
*/
|
|||
|
class ToolBase {
|
|||
|
public:
|
|||
|
ToolBase(const std::string& name, const std::string& description);
|
|||
|
virtual ~ToolBase() = default;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 执行工具
|
|||
|
* @param params 工具参数
|
|||
|
* @return 执行结果
|
|||
|
*/
|
|||
|
virtual mcp::json execute(const mcp::json& params) = 0;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取工具名称
|
|||
|
* @return 工具名称
|
|||
|
*/
|
|||
|
std::string getName() const { return name_; }
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取工具描述
|
|||
|
* @return 工具描述
|
|||
|
*/
|
|||
|
std::string getDescription() const { return description_; }
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取工具参数定义
|
|||
|
* @return 参数定义
|
|||
|
*/
|
|||
|
mcp::json getParameters() const { return parameters_; }
|
|||
|
|
|||
|
protected:
|
|||
|
std::string name_;
|
|||
|
std::string description_;
|
|||
|
mcp::json parameters_; // 参数定义,使用JSON Schema格式
|
|||
|
};
|
|||
|
|
|||
|
} // namespace openmanus
|
|||
|
|
|||
|
#endif // OPENMANUS_TOOL_BASE_H
|