34 lines
769 B
C++
34 lines
769 B
C++
#pragma once
|
|
#include <fstream>
|
|
#include <unordered_map>
|
|
#include "mcp_plugin_api.h"
|
|
|
|
class mcp_Tools
|
|
{
|
|
private:
|
|
std::unordered_map<std::string, std::shared_ptr<mcp_Tool>> m_tools;
|
|
|
|
public:
|
|
// 注册工具
|
|
void Register(std::shared_ptr<mcp_Tool> pTool);
|
|
|
|
// 组装所有工具的描述,返回 JSON 数组 (用于 tools/list)
|
|
nlohmann::json ToLLM() const;
|
|
|
|
// 路由分发执行指令 (用于 tools/call)
|
|
nlohmann::json Call(const std::string &name, const nlohmann::json &args);
|
|
|
|
void print();
|
|
|
|
void clear();
|
|
};
|
|
|
|
class mcp_ConfigParser
|
|
{
|
|
public:
|
|
static bool LoadAndRegister(const std::wstring &jsonFilePath, mcp_Tools ®istry);
|
|
|
|
private:
|
|
static void LoadDllTool(const nlohmann::json &toolConfig, const std::wstring &pluginDir, mcp_Tools ®istry);
|
|
};
|