Worktree 001 mcp stream dockerize - #939
Conversation
- Install @modelcontextprotocol/node SDK for MCP Streamable HTTP transport - Add @modelcontextprotocol/node to tsdown external array (ESM, not bundled) - Add mcpPort field to AgentMemoryConfig type (defaults to restPort + 3) - Add AGENTMEMORY_MCP_PORT env var support in loadConfig() Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Move handleToolsList() and handleToolCall() plus all their internal helpers (validate, handleProxy, handleLocal, handleProxyGeneric, normalizeList, parseLimit, textResponse, announceMode) from src/mcp/standalone.ts into a new src/mcp/handler.ts shared module. The extracted functions accept explicit sdk, kv, and config parameters so they can be reused by both the existing stdio transport and the upcoming Stream HTTP transport without code duplication. standalone.ts retains: - InMemoryKV instantiation - createStdioTransport and the stdio message dispatch loop - SIGINT/SIGTERM handlers - Backward-compatible wrapper exports (old signatures) for tests All 1410 non-integration tests pass; no behavioral changes. Co-Authored-By: Claude <noreply@anthropic.com>
Implement JSON-RPC-over-HTTP MCP transport that coexists with existing stdio transport. Uses Node.js http.createServer() with manual JSON-RPC handling, Bearer auth via timingSafeCompare(), and session management via a Map. - src/mcp/stream-http.ts: HTTP server with MCP JSON-RPC handling (initialize, tools/list, tools/call, notifications) - test/mcp-stream-http.test.ts: 22 tests covering initialize, tools/list, tools/call, Bearer auth, JSON-RPC errors, session management - test/mcp-transport-coexistence.test.ts: 5 tests verifying HTTP and stdio transports expose identical tool sets and handle notifications - src/index.ts: Wire up MCP server on config.mcpPort (3114), add to boot log and graceful shutdown - package.json: Add @cfworker/json-schema peer dependency Port scheme: restPort + 3 (3114), configurable via AGENTMEMORY_MCP_PORT Co-Authored-By: Claude <noreply@anthropic.com>
- Add session TTL with lastUsedAt tracking and periodic eviction (every 10 min) - Fix session-not-found error code from -32001 to -32000 per contract - Add explanation comment for manual JSON-RPC vs SDK transport - Add 5MB request body size limit with 413 response - Add HTTP method validation (POST/DELETE only, 405 for others) - Add Content-Type validation (application/json required, 415 otherwise) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix JsonRpcMessage.id type to allow null (JSON-RPC notification compliant) - Remove as cast in errorResponse() now that id type includes null - Remove dead req.headers["Mcp-Session-Id"] branch (Node.js lowercases headers) - DELETE handler now removes session from sessions Map - Remove unused @cfworker/json-schema dependency - Tighten parse error test to assert exactly -32700 - Add SDK bug reference URL in header comment - Add safety guard comment for res.headersSent in body-too-large handler Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…cker - T039: Add "stream-http" connection category to ConnectAdapter types - T040: Add AGENTMEMORY_MCP_HTTP_BLOCK constant and HTTP transport comments in CLI connect adapters for Stream HTTP URL-based connections - T041: Add AGENTMEMORY_MCP_PORT entry to .env.example ports section - T042: Add Docker quickstart section to README.md - T045: Add mcpPort to startup banner alongside REST API and MCP surface lines Co-Authored-By: Claude <noreply@anthropic.com>
- Remove @modelcontextprotocol/node from package.json dependencies - Remove @modelcontextprotocol/node from tsdown.config.ts external array - Update stream-http.ts comment to remove SDK revisit suggestion - Update spec.md assumptions: Stream HTTP uses hand-rolled JSON-RPC server on port 3114 (separate from REST on 3111) - 1450 tests pass (6 pre-existing environmental failures in worktree) Co-Authored-By: Claude <noreply@anthropic.com>
|
@Noodle05 is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (33)
📝 WalkthroughWalkthroughAdds an MCP Streamable HTTP transport (hand-rolled JSON-RPC 2.0 on port 3114), refactors existing standalone MCP logic into a shared ChangesMCP Stream HTTP Transport and Docker Deployment
Plugin Scripts ESM Export Normalization
Sequence Diagram(s)sequenceDiagram
participant Client as MCP Client
participant StreamHTTP as stream-http.ts (port 3114)
participant Sessions as SessionMap
participant Handler as handler.ts
rect rgba(70, 130, 180, 0.5)
Note over Client, Sessions: Session initialization
Client->>StreamHTTP: POST /mcp {method: initialize}
StreamHTTP->>StreamHTTP: validate method, Content-Type, Bearer token
StreamHTTP->>Sessions: create SessionEntry
StreamHTTP-->>Client: 200 + mcp-session-id header
end
rect rgba(60, 179, 113, 0.5)
Note over Client, Handler: Tool discovery
Client->>StreamHTTP: POST /mcp + Mcp-Session-Id {method: tools/list}
StreamHTTP->>Sessions: lookup + bump lastUsedAt
StreamHTTP->>Handler: handleToolsList(null, kv)
Handler-->>StreamHTTP: tools array
StreamHTTP-->>Client: 200 JSON-RPC response
end
rect rgba(255, 165, 0, 0.5)
Note over Client, Handler: Tool invocation
Client->>StreamHTTP: POST /mcp + Mcp-Session-Id {method: tools/call, name, args}
StreamHTTP->>Handler: handleToolCall(name, args, null, kv)
Handler->>Handler: validate args, route proxy or local KV
Handler-->>StreamHTTP: content array
StreamHTTP-->>Client: 200 JSON-RPC response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
New Features
Documentation