File size: 1,236 Bytes
30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 db82307 30fff00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #pragma once
#include <thread>
#include <atomic>
#include <string>
#include <memory>
// Forward declarations
namespace httplib { class Server; }
class HostedPluginManager;
class McpServer
{
public:
McpServer(int port, HostedPluginManager& pluginManager);
~McpServer();
void start();
void stop();
bool isRunning() const;
int getPort() const { return port; }
private:
void setupRoutes();
// MCP protocol handlers
std::string handleInitialize(const std::string& requestBody);
std::string handleToolsList(const std::string& requestBody);
std::string handleToolsCall(const std::string& requestBody);
// Tool implementations
std::string toolListPlugins();
std::string toolSearchParam(const std::string& plugin, const std::string& keyword);
std::string toolGetParams(const std::string& plugin, const std::string& idsJson);
std::string toolSetParams(const std::string& plugin, const std::string& valuesJson);
std::string toolGetAnalysis();
std::unique_ptr<httplib::Server> server;
std::thread serverThread;
std::atomic<bool> running{false};
int port;
std::string sessionId;
bool initialized = false;
HostedPluginManager& pluginManager;
};
|