feat: consolidate iii-engine + agentmemory into single Docker image - #940
feat: consolidate iii-engine + agentmemory into single Docker image#940Noodle05 wants to merge 28 commits into
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>
Merge the multi-container Docker setup into a single image: - Dockerfile: 3-stage build (iii binary + TypeScript build + runtime) - entrypoint.sh: based on deploy/coolify upstream, starts iii-engine in background then agentmemory in foreground with graceful shutdown trap - docker-compose.yml: simplified to single agentmemory service - iii-config.docker.yaml: removed (entrypoint generates config dynamically) Builds agentmemory from local TypeScript source (not npm registry). Minimal diff vs deploy/coolify upstream — only source-build vs npm-install differences. Co-Authored-By: Claude <noreply@anthropic.com>
…xample These env vars are needed for the single-image Docker setup. AGENTMEMORY_SECRET_FILE points to the persisted HMAC secret file. AGENTMEMORY_REST_HOST sets the REST upstream host for the viewer proxy. Co-Authored-By: Claude <noreply@anthropic.com>
- Fix 'iii run' → 'iii' (no 'run' subcommand in iii CLI) - Fix 'SIGTERM SIGINT' → 'TERM INT' (POSIX sh requires no SIG prefix) - Verified: container starts, health check passes, viewer responds, HMAC persists across restarts, no regressions 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 (20)
📝 WalkthroughWalkthroughAdds an MCP Streamable HTTP JSON-RPC transport server ( ChangesMCP Streamable HTTP Transport and Docker Deployment
Sequence Diagram(s)sequenceDiagram
participant Client as MCP Client
participant StreamHTTP as stream-http.ts (port 3114)
participant Handler as handler.ts
participant KV as InMemoryKV
participant REST as agentmemory REST API
Client->>StreamHTTP: POST /mcp initialize
StreamHTTP->>StreamHTTP: validate auth, create session
StreamHTTP->>Client: 200 + mcp-session-id
Client->>StreamHTTP: POST /mcp tools/list (mcp-session-id)
StreamHTTP->>Handler: handleToolsList(sdk, kv)
Handler-->>StreamHTTP: { tools: [...] }
StreamHTTP->>Client: 200 JSON-RPC result
Client->>StreamHTTP: POST /mcp tools/call (mcp-session-id)
StreamHTTP->>Handler: handleToolCall(name, args, sdk, kv)
alt proxy mode
Handler->>REST: GET/POST /agentmemory/...
REST-->>Handler: result
else local fallback
Handler->>KV: read/write
KV-->>Handler: data
end
Handler-->>StreamHTTP: { content: [...] }
StreamHTTP->>Client: 200 JSON-RPC result
Client->>StreamHTTP: DELETE (mcp-session-id)
StreamHTTP->>StreamHTTP: remove session
StreamHTTP->>Client: 200
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
✨ 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
Consolidate the multi-container Docker setup (separate
iii-engine+agentmemory+iii-initcontainers) into a single Docker image that runs both processes in one container.Motivation
The iii-engine and agentmemory are tightly coupled (1:1, version-pinned). Splitting across containers adds orchestration complexity without benefit. The platform deploys already use this pattern.
Changes
Dockerfileentrypoint.shdocker-compose.ymliii-config.docker.yaml.env.exampleAGENTMEMORY_SECRET_FILEandAGENTMEMORY_REST_HOSTVerification
docker buildsucceeds, container starts with both processesdeploy/coolify/upstream🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation
Chores