Files
cad-agent/src/AutoAgent/mcp_ConfigParser.h
T
gjm 1435b864f8 refactor
重构 mcp-server 功能
2026-10-02 20:39:34 +08:00

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 &registry);
private:
static void LoadDllTool(const nlohmann::json &toolConfig, const std::wstring &pluginDir, mcp_Tools &registry);
};