Skip to content

feat(#381): MCP Streamable HTTP transport + protocol version bump - #397

Merged
ajianaz merged 5 commits into
developfrom
feat/381-mcp-http
Jun 19, 2026
Merged

ajianaz merged 5 commits into
developfrom
feat/381-mcp-http

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #381.

  • Bump protocolVersion 2024-11-05 → 2025-06-18 (current MCP spec)
  • Extract MCP handler into uteke_mcp library crate (shared between stdio + HTTP)
  • New POST /mcp endpoint on uteke-server with MCP-Protocol-Version header
  • Enables remote MCP clients without subprocess spawning

283 tests pass, clippy clean.

Protocol:
  - Bump protocolVersion from 2024-11-05 to 2025-06-18 (current spec)

Architecture:
  - Extract MCP handler into uteke_mcp library crate (lib.rs)
  - main.rs simplified to just stdio transport loop delegating to lib
  - uteke-server gains POST /mcp endpoint that calls the shared handler

HTTP endpoint:
  - POST /mcp accepts JSON-RPC body (initialize, tools/list, tools/call)
  - Returns application/json with MCP-Protocol-Version header
  - Uses existing Mutex<Uteke> from uteke-server (thread-safe)
  - Enables remote MCP clients without subprocess spawning

Closes #381
@ajianaz ajianaz added this to the v0.2.1 — DX & Ecosystem milestone Jun 19, 2026
@ajianaz ajianaz added enhancement New feature or request type:feature New feature scope:server uteke-server / uteke-mcp binaries labels Jun 19, 2026
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (3)

  • crates/uteke-server/src/main.rs:881 — The new /mcp route passes &uteke into uteke_mcp::handle_jsonrpc(&uteke, &body), but handle_jsonrpc is defined in crates/uteke-mcp/src/lib.rs as pub fn handle_jsonrpc(uteke: &Uteke, raw: &str) -> String. In this file, uteke is the route parameter &Mutex<Uteke>, not &Uteke. That means the HTTP endpoint is not using the shared handler with the expected type and will fail unless the mutex is locked and the guard dereferenced before the call.
  • crates/uteke-server/src/main.rs:872 — The route only rejects oversized requests based on the content-length header, then reads with req.as_reader().take(MAX_MCP_BODY).read_to_string(&mut body). If a client omits Content-Length or lies about it, the take(MAX_MCP_BODY) call truncates the body to exactly 1 MiB, but the code still processes the truncated JSON instead of rejecting the request as too large. This can turn an oversized valid JSON-RPC payload into a parse error and still wastes work reading the maximum allowed bytes from an untrusted client.
  • crates/uteke-mcp/src/lib.rs:66 — JSON-RPC notifications have no id, but handle_jsonrpc always fabricates id: null via let id = req.id.clone().unwrap_or(Value::Null); and then serializes either a success or error response for every request. This is especially visible for unknown methods or tool failures: a notification will still emit a response object with id: null. For MCP/JSON-RPC clients, notifications should not receive any response at all.

Review powered by cora-cli · BYOK · MIT

CodeCora #397:

1. exec_remember now passes --type to remember_typed (was dropped in
   refactor).
2. exec_recall now accepts tags filter and min_score (were hardcoded
   to None and 0.0).
3. exec_list now accepts offset for pagination (was hardcoded to 0).
4. POST /mcp enforces 1 MiB body size limit via .take() to prevent
   memory exhaustion from unbounded reads.

Also: updated tool schemas to document the restored parameters.
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
CodeCora #397 r2: the refactor dropped room and author parameters from
the MCP remember tool. Clients using collaborative memory (room mode)
would silently lose room linkage.

Fix: restore room/author handling with remember_in_room() when room is
provided, plus add them to the tool schema.
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-mcp/src/lib.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
CodeCora #397 r3:

1. exec_list used &m.id[..8] which panics if ID < 8 bytes. Fix: use
   m.id.get(..8).unwrap_or(&m.id) for safe slicing.

2. POST /mcp used .take(MAX_MCP_BODY) which silently truncated oversized
   bodies, processing a partial JSON-RPC message as if valid. Fix: check
   Content-Length header first and return 413 if > 1 MiB.
Comment thread crates/uteke-server/src/main.rs Fixed
return ctx.error_response_for(req, 413, "Payload too large");
}
let mut body = String::new();
if let Err(e) = req.as_reader().take(MAX_MCP_BODY).read_to_string(&mut body) {
error: Some(JsonRpcError {
code: -32700,
message: format!("Parse error: {e}"),
}),
const MAX_MCP_BODY: u64 = 1024 * 1024;
// Check Content-Length and reject oversized requests.
let content_length = req
.headers()
@ajianaz
ajianaz merged commit ec2ad0a into develop Jun 19, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/381-mcp-http branch July 9, 2026 14:28
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat(#381): MCP Streamable HTTP transport + protocol version bump

Protocol:
  - Bump protocolVersion from 2024-11-05 to 2025-06-18 (current spec)

Architecture:
  - Extract MCP handler into uteke_mcp library crate (lib.rs)
  - main.rs simplified to just stdio transport loop delegating to lib
  - uteke-server gains POST /mcp endpoint that calls the shared handler

HTTP endpoint:
  - POST /mcp accepts JSON-RPC body (initialize, tools/list, tools/call)
  - Returns application/json with MCP-Protocol-Version header
  - Uses existing Mutex<Uteke> from uteke-server (thread-safe)
  - Enables remote MCP clients without subprocess spawning

Closes #381

* fix(#381): restore dropped params + body size limit

CodeCora #397:

1. exec_remember now passes --type to remember_typed (was dropped in
   refactor).
2. exec_recall now accepts tags filter and min_score (were hardcoded
   to None and 0.0).
3. exec_list now accepts offset for pagination (was hardcoded to 0).
4. POST /mcp enforces 1 MiB body size limit via .take() to prevent
   memory exhaustion from unbounded reads.

Also: updated tool schemas to document the restored parameters.

* fix(#381): restore room/author params in exec_remember

CodeCora #397 r2: the refactor dropped room and author parameters from
the MCP remember tool. Clients using collaborative memory (room mode)
would silently lose room linkage.

Fix: restore room/author handling with remember_in_room() when room is
provided, plus add them to the tool schema.

* fix(#381): safe ID slicing + reject oversized MCP bodies

CodeCora #397 r3:

1. exec_list used &m.id[..8] which panics if ID < 8 bytes. Fix: use
   m.id.get(..8).unwrap_or(&m.id) for safe slicing.

2. POST /mcp used .take(MAX_MCP_BODY) which silently truncated oversized
   bodies, processing a partial JSON-RPC message as if valid. Fix: check
   Content-Length header first and return 413 if > 1 MiB.

* chore: retrigger CI (flaky env test on previous run)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request scope:server uteke-server / uteke-mcp binaries type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: MCP Streamable HTTP transport + protocol version bump

2 participants