You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ It is split into eight public modules:
11
11
-`include/json_session_invoke`: higher-level session/runtime APIs built on top of `json_invoke` for stateful create/call/destroy flows.
12
12
-`include/task_scheduler`: task classification and scheduling helpers built on top of `json_session_invoke`.
13
13
-`include/runtime`: protocol-neutral runtime facade built on top of `task_scheduler` for normalized tool listing and unary invocation.
14
-
-`include/mcp`: MCP-specific adapters built on top of `runtime` for protocol-facing transports such as stdio.
14
+
-`include/mcp`: MCP-specific adapters built on top of `runtime` for protocol-facing transports such as stdio and a framework-agnostic HTTP gateway core.
15
15
16
16
Project layout
17
17
@@ -35,7 +35,9 @@ Project layout
35
35
-`include/task_scheduler/task_scheduler.hpp`: scheduler-side task abstractions, including a minimal `ITaskScheduler` interface and a keyed scheduler that enforces session-wide and per-object exclusivity.
36
36
-`include/runtime/runtime_facade.hpp`: protocol-neutral facade that projects exported tool schemas into normalized descriptors and turns scheduler-backed JSON requests into normalized invoke results.
37
37
-`include/mcp/mcp_stdio_server.hpp`: minimal MCP stdio server that handles JSON-RPC framing plus `initialize`, `ping`, `tools/list`, and `tools/call` on top of the runtime facade.
38
+
-`include/mcp/mcp_http_gateway.hpp`: framework-agnostic HTTP request/session gateway core for one MCP endpoint backed by session objects.
-`examples/mcp_http/mcp_http_gateway_demo.cpp`: cpp-httplib demo that mounts one `/mcp` endpoint and routes HTTP requests through the framework-agnostic gateway core.
39
41
-`examples/mcp_stdio/mcp_stdio_server_demo.cpp`: standalone MCP stdio server process that exposes demo tools and can be launched directly by an MCP host.
-`examples/json_stateful/json_stateful_demo.cpp`: stateful object-handle example for create/call/destroy flows.
@@ -162,6 +164,7 @@ API notes
162
164
-`runtime::RuntimeFacadeThreadSafe`: protocol-neutral entry point above `task_scheduler`; `listTools()` returns normalized tool descriptors, `submitInvoke(...)` schedules one unary call and returns `std::future<runtime::InvokeResult>`, and `invoke(...)` gives the same normalized result synchronously.
163
165
-`runtime::InvokeResult`: normalized invoke envelope with `ok`, `value`, optional `error`, and the original `raw_response`; classification-time failures such as unknown tools are converted into the same error shape instead of leaking exceptions to protocol adapters.
164
166
-`mcp::McpStdioServerThreadSafe`: thin MCP adapter over `runtime::RuntimeFacadeThreadSafe`; it reads and writes `Content-Length` framed JSON-RPC messages and `serveConcurrent(...)` keeps multiple `tools/call` requests in flight on one stdio session while `initialize`, `ping`, and `tools/list` remain ordered.
167
+
-`mcp::HttpMcpGateway`: framework-agnostic POST `/mcp` core that validates basic HTTP semantics, allocates MCP sessions on `initialize`, requires `Mcp-Session-Id` afterwards, and leaves server startup/routing to whichever HTTP framework hosts it.
165
168
-`mcp::McpStdioServerThreadSafe::handleMessage(...)`: useful when you want protocol handling without a real stdio loop, for example in tests or when embedding the MCP adapter into another transport shim.
166
169
167
170
MCP stdio demo
@@ -170,6 +173,13 @@ MCP stdio demo
170
173
- The demo server registers `sum`, `slow_sum`, `echo_text`, `create_counter`, `counter_add`, `counter_value`, and `destroy_counter`.
171
174
- The process writes only framed MCP responses to stdout; startup notes, `slow_sum` overlap logs, and fatal errors go to stderr.
172
175
-`examples/mcp_stdio/test_mcp.ps1` now runs a fuller smoke test against the demo executable: initialize, tools/list, one stateless `sum` call, then a stateful `create_counter -> counter_add -> counter_value -> destroy_counter` flow.
176
+
177
+
MCP HTTP demo
178
+
179
+
- Build `mcp_http_gateway_demo` when you want a single `/mcp` HTTP endpoint hosted by cpp-httplib while keeping MCP/HTTP semantics inside `mcp::HttpMcpGateway`.
180
+
- The demo keeps one stdio child-process MCP session per `Mcp-Session-Id`; initialize launches `mcp_stdio_server_demo`, later requests reuse that backend process, and clients must send the returned session header.
181
+
- Pass `--backend-executable <path>` when the stdio backend is not discoverable next to the HTTP gateway binary or under `build/`.
182
+
- On Windows, `mcp_stdio_server_demo` switches stdin/stdout to binary mode so MCP `Content-Length` framing survives stdio transport without CRLF expansion.
173
183
- The fluent builder also supports `.options(...)`, so object type selection and session object options can be expressed separately: `.stateful<T>("counter").options(opts)...`.
174
184
- When `.stateful<T>("counter")` uses `.create(...)` without an explicit tool name, the builder defaults to `create_counter`.
175
185
- If a stateful builder creates an object but omits `.destroy()`, the adapter auto-registers the default `destroy_<object_type>` tool unless `setStatefulDefaults(...)` disables `auto_register_destroy`.
0 commit comments