13#include <neograph/types.h>
28namespace neograph::mcp {
37 "2025-11-25",
"2025-06-18",
"2025-03-26",
"2024-11-05"};
39inline bool is_supported_protocol_version(std::string_view version)
noexcept {
40 return std::find(MCP_SUPPORTED_PROTOCOL_VERSIONS.begin(),
41 MCP_SUPPORTED_PROTOCOL_VERSIONS.end(),
42 version) != MCP_SUPPORTED_PROTOCOL_VERSIONS.end();
45using HeaderList = std::vector<std::pair<std::string, std::string>>;
46using HeaderProvider = std::function<HeaderList()>;
48struct NEOGRAPH_API MCPClientConfig {
49 std::chrono::milliseconds request_timeout{std::chrono::seconds(30)};
51 HeaderProvider header_provider;
56 std::vector<std::string> argv;
57 std::filesystem::path cwd;
66 bool replace_environment =
false;
67 std::size_t max_frame_bytes = 16 * 1024 * 1024;
78 std::size_t max_stdout_text_lines = 1000;
79 std::size_t max_stdout_text_bytes = 256 * 1024;
84 std::size_t max_stderr_bytes = 64 * 1024;
87 std::chrono::milliseconds startup_timeout{10000};
88 std::chrono::milliseconds request_timeout{30000};
93 std::chrono::milliseconds cancel_grace{500};
96class NEOGRAPH_API MCPError :
public std::runtime_error {
100 MCPError(
int code, std::string message, json data =
nullptr,
int http_status = 0);
102 int code() const noexcept {
return code_; }
103 const json& data() const noexcept {
return data_; }
104 int http_status() const noexcept {
return http_status_; }
109 int http_status_ = 0;
114 connection, timeout, cancelled, shutdown, http_status, protocol
117class NEOGRAPH_API MCPTransportError :
public std::runtime_error {
119 MCPTransportError(MCPFailure failure, std::string message,
int http_status = 0);
120 MCPFailure failure() const noexcept {
return failure_; }
121 int http_status() const noexcept {
return http_status_; }
129struct NEOGRAPH_API InitializeResult {
130 std::string protocol_version;
131 json capabilities = json::object();
132 json server_info = json::object();
133 std::string instructions;
134 json raw = json::object();
136 static InitializeResult from_json(
const json& value);
139struct NEOGRAPH_API ToolDefinition {
142 std::string description;
143 json icons = json::array();
147 json input_schema = json{{
"type",
"object"}};
149 json annotations = json::object();
150 json execution = json::object();
151 json meta = json::object();
152 json raw = json::object();
154 static ToolDefinition from_json(
const json& value);
155 json to_json()
const;
158struct NEOGRAPH_API ListToolsPage {
159 std::vector<ToolDefinition> tools;
160 std::optional<std::string> next_cursor;
161 json meta = json::object();
162 json raw = json::object();
164 static ListToolsPage from_json(
const json& value);
167struct NEOGRAPH_API CallToolResult {
168 json content = json::array();
169 json structured_content;
170 bool is_error =
false;
171 json meta = json::object();
172 json raw = json::object();
174 static CallToolResult from_json(
const json& value);
175 json to_json()
const;
NEOGRAPH_API export/import macro for shared-library builds.
constexpr std::array< std::string_view, 4 > MCP_SUPPORTED_PROTOCOL_VERSIONS
The MCP revisions NeoGraph's server answers and its client accepts, newest first, as the official SDK...
MCPFailure
Transport and wire failures have one classification on both HTTP and stdio.
Explicit subprocess boundary for local credentialless MCP adoption.
std::vector< std::pair< std::string, std::string > > environment
Environment entries for the server.