Out-of-process rebuild: Add Plugin/McpServer.h/.cpp — routes MCP tools through HelperConnection
Browse files- Source/Plugin/McpServer.h +37 -0
Source/Plugin/McpServer.h
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
#include <thread>
|
| 4 |
+
#include <atomic>
|
| 5 |
+
#include <string>
|
| 6 |
+
#include <memory>
|
| 7 |
+
|
| 8 |
+
namespace httplib { class Server; }
|
| 9 |
+
class HelperConnection;
|
| 10 |
+
|
| 11 |
+
class McpServer
|
| 12 |
+
{
|
| 13 |
+
public:
|
| 14 |
+
McpServer(int port, HelperConnection& helper);
|
| 15 |
+
~McpServer();
|
| 16 |
+
|
| 17 |
+
void start();
|
| 18 |
+
void stop();
|
| 19 |
+
bool isRunning() const;
|
| 20 |
+
int getPort() const { return port; }
|
| 21 |
+
|
| 22 |
+
private:
|
| 23 |
+
void setupRoutes();
|
| 24 |
+
|
| 25 |
+
std::string handleInitialize(const std::string& requestBody);
|
| 26 |
+
std::string handleToolsList(const std::string& requestBody);
|
| 27 |
+
std::string handleToolsCall(const std::string& requestBody);
|
| 28 |
+
|
| 29 |
+
std::unique_ptr<httplib::Server> server;
|
| 30 |
+
std::thread serverThread;
|
| 31 |
+
std::atomic<bool> running{false};
|
| 32 |
+
int port;
|
| 33 |
+
std::string sessionId;
|
| 34 |
+
bool initialized = false;
|
| 35 |
+
|
| 36 |
+
HelperConnection& helper;
|
| 37 |
+
};
|