#ifndef STRAWBERRY_MCP_SERVER_HPP #define STRAWBERRY_MCP_SERVER_HPP // Transport-free MCP (Model Context Protocol) server for Strawberry. // `handle()` takes one JSON-RPC message and returns the reply (if any), so the // protocol and tools are unit-testable without stdio. #include "strawberry/evidence_store.hpp" #include #include #include namespace strawberry::mcp { using json = nlohmann::json; struct McpOptions { std::string socket_path; std::string db_path_override; // empty = path reported by the daemon std::string default_db_path = "/var/lib/strawberry/database.db"; bool read_only = false; // hide reload/rescan/scan tools }; class McpServer { public: explicit McpServer(McpOptions options); /// Handle one JSON-RPC message. Returns nullopt for notifications. std::optional handle(const json& message); /// Serialize for the wire: invalid UTF-8 from host evidence is replaced, /// never thrown on. static std::string dump(const json& value); private: json handle_initialize(const json& params); json tools_list() const; json call_tool(const std::string& name, const json& arguments); json tool_status(); json tool_list_findings(const json& args); json tool_get_finding(const json& args); json tool_search_processes(const json& args); json tool_get_process(const json& args); json tool_scan_paths(const json& args); json tool_control(const std::string& verb); json tool_get_policy(); /// Daemon status reply (`data` object) or nullopt with `error` set. std::optional daemon_status(std::string& error); void refresh_store(); McpOptions options_; EvidenceStore store_; }; } // namespace strawberry::mcp #endif // STRAWBERRY_MCP_SERVER_HPP