#pragma once
#include "game_manager.hpp"
namespace nethack_mcp
{
/// Dispatch MCP JSON-RPC messages across all active game sessions.
class McpServer
{
public:
/// Bind the protocol dispatcher to the shared game manager.
explicit McpServer(GameManager& manager);
/// Dispatch one HTTP transport message.
/// Set should_respond when the client expects a JSON-RPC reply.
Json handleMessage(const Json& request, bool& should_respond,
const std::string& client_id = {},
bool modern_protocol = false);
private:
Json handleMessageInternal(const Json& request, bool& should_respond,
const std::string& client_id,
bool modern_protocol);
Json addModernMetadata(Json response, const Json& request,
bool modern_protocol) const;
Json tools() const;
Json toolResult(const ToolResult& result) const;
Json jsonRpcError(const Json& id, int code,
const std::string& message) const;
GameManager& manager_;
};
} // namespace nethack_mcp