File size: 1,313 Bytes
98773fc 9209b46 8ef64a9 98773fc e5f329d 98773fc a87020c 98773fc a87020c 9209b46 a87020c 9209b46 8ef64a9 98773fc a87020c 98773fc e5f329d 98773fc | 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 48 49 50 | #pragma once
#include <thread>
#include <atomic>
#include <string>
#include <memory>
#include <functional>
#include <vector>
#include <map>
namespace httplib { class Server; }
class HelperConnection;
class McpServer
{
public:
McpServer(HelperConnection& helper);
~McpServer();
void start();
void stop();
bool isRunning() const;
int getPort() const { return port; }
// Callbacks set by Processor
std::function<std::string()> getAnalysisCallback;
std::function<std::string()> channelNameCallback;
// Param callbacks — wired to inProcessPlugin when SAFE, null when UNSAFE
std::function<std::string(const std::string& keyword)> searchParamCallback;
std::function<std::string(const std::vector<int>& ids)> getParamsCallback;
std::function<bool(const std::map<int,float>& values)> setParamsCallback;
private:
void setupRoutes();
std::string handleInitialize(const std::string& requestBody);
std::string handleToolsList(const std::string& requestBody);
std::string handleToolsCall(const std::string& requestBody);
std::unique_ptr<httplib::Server> server;
std::thread serverThread;
std::atomic<bool> running{false};
int port = 0;
std::string sessionId;
bool initialized = false;
HelperConnection& helper;
};
|