搭建 mcp server+mcp plugin
This commit is contained in:
gjm committed 2026-10-02 12:39:35 +08:00
1 parent 09f9d69d36
commit 5d6f1c74d1
16 files changed
+792 -229

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
#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);
};
class mcp_ConfigParser
{
public:
static bool LoadAndRegister(const std::string &jsonFilePath, mcp_Tools &registry);
private:
static void LoadDllTool(const nlohmann::json &toolConfig, const std::string &pluginDir, mcp_Tools &registry);
};