Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7af53f5
feat: add MCP Stream HTTP dependency and mcpPort config (Phase 1)
Noodle05 Jun 15, 2026
562ac50
fix: add mcpPort to multi-instance tests and update config comment
Noodle05 Jun 15, 2026
130e2c0
refactor: extract MCP tool handlers to shared module
Noodle05 Jun 15, 2026
c1e8c39
feat: add MCP Streamable HTTP transport on port 3114
Noodle05 Jun 15, 2026
991b75d
fix: address spec review findings for MCP Stream HTTP transport
Noodle05 Jun 15, 2026
f5871a4
fix: address code quality review findings for stream-http
Noodle05 Jun 15, 2026
4e5de24
feat: add full Docker compose deployment with agentmemory service
Noodle05 Jun 15, 2026
b7c01b1
fix: add agentmemory healthcheck and clean up Docker config
Noodle05 Jun 15, 2026
bc69864
feat: add CLI HTTP adapter, docs, and polish for MCP Stream HTTP + Do…
Noodle05 Jun 15, 2026
153102a
fix: remove unused @modelcontextprotocol/node dependency and update spec
Noodle05 Jun 15, 2026
eb32522
fix: revert formatting-only changes to hook build artifacts
Noodle05 Jun 15, 2026
f5e6824
fix: restore dropped comments in handler.ts from extraction
Noodle05 Jun 15, 2026
7084573
fix: revert unnecessary comment in json-mcp-adapter.ts
Noodle05 Jun 15, 2026
d939961
fix: remove redundant iii-config generation from entrypoint.sh
Noodle05 Jun 15, 2026
659ecf8
fix: remove iii binary and port 3111/3112 from agentmemory Dockerfile
Noodle05 Jun 15, 2026
cf5c597
fix: restore original docker-compose comments
Noodle05 Jun 15, 2026
dd96448
fix: move docker-compose engine comment to correct position
Noodle05 Jun 15, 2026
e05181d
fix: remove incorrect healthcheck from iii-engine, fix agentmemory he…
Noodle05 Jun 15, 2026
aecec18
feat: add env_file to agentmemory service in docker-compose
Noodle05 Jun 15, 2026
66124c1
fix: bind MCP Stream HTTP to 0.0.0.0 for Docker port forwarding
Noodle05 Jun 15, 2026
ea8aa6f
feat: separate agentmemory data volume from engine data
Noodle05 Jun 15, 2026
c2cda47
fix: bind agentmemory ports to 0.0.0.0 for network access
Noodle05 Jun 15, 2026
cf36c02
fix: export AGENTMEMORY_SECRET and set VIEWER_ALLOWED_HOSTS for viewer
Noodle05 Jun 15, 2026
01d0a28
fix: make VIEWER_ALLOWED_HOSTS configurable via .env, add docs to .en…
Noodle05 Jun 15, 2026
0516252
fix: make viewer REST upstream host configurable for Docker
Noodle05 Jun 15, 2026
56f0ccc
feat: consolidate iii-engine + agentmemory into single Docker image
Noodle05 Jun 15, 2026
b055c76
docs: add AGENTMEMORY_SECRET_FILE and AGENTMEMORY_REST_HOST to .env.e…
Noodle05 Jun 15, 2026
9b81487
fix: correct iii-engine startup command and trap signal names
Noodle05 Jun 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.git
test
specs
deploy
website
data
dist
.claude
.specify
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
# you expose the daemon beyond loopback or run behind a reverse proxy.

# AGENTMEMORY_SECRET=your-secret-here
# AGENTMEMORY_SECRET_FILE=/data/.hmac # Path to persisted HMAC secret file (Docker: auto-generated by entrypoint)

# -----------------------------------------------------------------------------
# 4. Search tuning
Expand Down Expand Up @@ -148,6 +149,17 @@
# III_REST_PORT=3111 # REST API port (also affects viewer at +2)
# III_STREAMS_PORT=3112 # Streams API port
# III_ENGINE_URL=ws://localhost:49134 # iii-engine WebSocket URL (used by the worker)
# AGENTMEMORY_REST_HOST=127.0.0.1 # REST upstream host for viewer reverse proxy (Docker: set to 127.0.0.1)

# AGENTMEMORY_MCP_PORT=3114 # MCP Streamable HTTP port (JSON-RPC transport). Defaults to REST port + 3.
# # MCP clients that speak Streamable HTTP can connect directly to
# # http://localhost:3114/mcp instead of spawning npx @agentmemory/mcp.
# AGENTMEMORY_VIEWER_HOST=0.0.0.0 # Viewer bind address. Unset = loopback only. Set to 0.0.0.0 to
# # make the viewer reachable from other hosts on the network (requires
# # AGENTMEMORY_SECRET and VIEWER_ALLOWED_HOSTS).
# VIEWER_ALLOWED_HOSTS=localhost:3113,127.0.0.1:3113 # Comma-separated Host header values the viewer trusts.
# # Add remote hostnames/IPs when AGENTMEMORY_VIEWER_HOST is set
# # to 0.0.0.0 (e.g. "my-host:3113,192.168.1.5:3113").

# -----------------------------------------------------------------------------
# 8. iii engine pin
Expand Down
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG III_VERSION=0.11.2

FROM iiidev/iii:${III_VERSION} AS iii-image

FROM node:22-slim AS build
WORKDIR /app
COPY package.json package-lock.json tsconfig.json tsdown.config.ts ./
RUN npm ci
COPY src/ ./src/
RUN npm run build

FROM node:22-slim

ARG III_VERSION=0.11.2

RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl ca-certificates tini gosu curl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=iii-image /app/iii /usr/local/bin/iii

WORKDIR /app
COPY --from=build /app/dist/ ./dist/
COPY --from=build /app/package.json /app/package-lock.json ./
RUN npm ci --omit=dev --no-fund --no-audit

ENV AGENTMEMORY_III_VERSION=${III_VERSION} \
TINI_SUBREAPER=1

COPY --chmod=0755 entrypoint.sh /app/entrypoint.sh

EXPOSE 3113 3114

ENTRYPOINT ["/usr/bin/tini", "--", "/app/entrypoint.sh"]
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,49 @@ Imported sessions show up in the Replay picker alongside native ones. Under the

> **Heads-up if you rely on `import-jsonl` as your primary capture path:** Claude Code's `cleanupPeriodDays` (in `~/.claude/settings.json`, default **30**) auto-deletes JSONL transcripts older than that window from `~/.claude/projects/`. If you install agentmemory fresh on a months-old Claude Code history, anything older than 30 days is already gone before the first import. Either run `import-jsonl` on a cron, raise `cleanupPeriodDays` to something higher, or wire the auto-capture hooks (the default plugin install path) so each turn lands in agentmemory while the session is live and the JSONL cleanup stops mattering.

### Docker

Run agentmemory in a container with one command — no Node.js or npm required on the host.

**Prerequisites:** Docker and docker-compose.

```bash
# Clone and start — iii engine + agentmemory worker + viewer + MCP Stream HTTP
git clone https://github.com/rohitg00/agentmemory.git
cd agentmemory
docker compose build && docker compose up -d

# Grab the auto-generated HMAC secret for MCP client auth
docker compose logs agentmemory | grep AGENTMEMORY_SECRET
# or: docker compose exec agentmemory cat /data/.hmac

# Verify it is up
curl -s http://localhost:3111/agentmemory/health | head -c 200
```

MCP clients that speak Streamable HTTP can connect directly without spawning
an `npx` process:

```json
{
"mcpServers": {
"agentmemory": {
"url": "http://localhost:3114/mcp",
"headers": {
"Authorization": "Bearer <secret-from-/data/.hmac>"
}
}
}
}
```

Stdio-based MCP clients (Cursor, Claude Code, etc.) still work through the
`npx @agentmemory/mcp` shim as usual — set `AGENTMEMORY_URL=http://localhost:3111`
and `AGENTMEMORY_SECRET` in the client's env block.

See [specs/001-mcp-stream-dockerize/quickstart.md](specs/001-mcp-stream-dockerize/quickstart.md)
for advanced Docker setups (custom ports, external volumes, multi-instance).

### Upgrade / Maintenance

Use the maintenance command when you intentionally want to update your local runtime:
Expand Down
60 changes: 24 additions & 36 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
services:
# One-shot init container: docker creates named volumes root:root mode
# 755, but the iii-engine image is distroless and runs as UID 65532
# with no `chown` of its own. Without this, /data is unwritable, the
# engine silently buffers in RAM, and state evaporates on every
# restart — the exact symptom v0.9.7's working-directory fix set out
# to solve. Runs once at compose-up and exits.
iii-init:
image: busybox:1.36
user: "0:0"
volumes:
- iii-data:/data
entrypoint: ["sh", "-c", "chown -R 65532:65532 /data && chmod 755 /data"]
restart: "no"

iii-engine:
# Pinned to v0.11.2 — the last engine that runs agentmemory's current
# worker model cleanly. v0.11.6 introduces a new sandbox-everything-
# via-`iii worker add` model that agentmemory hasn't been refactored
# for yet; the architectural mismatch surfaces as EPIPE reconnect
# loops and empty search after save. Bump only after agentmemory is
# refactored to register as a sandboxed worker.
#
# Override per-shell or via .env file:
# AGENTMEMORY_III_VERSION=0.11.7 docker compose up
image: iiidev/iii:${AGENTMEMORY_III_VERSION:-0.11.2}
user: "65532:65532"
depends_on:
iii-init:
condition: service_completed_successfully
agentmemory:
build:
context: .
dockerfile: Dockerfile
ports:
- "127.0.0.1:49134:49134"
- "127.0.0.1:3111:3111"
- "127.0.0.1:3112:3112"
- "127.0.0.1:9464:9464"
- "3114:3114"
- "3113:3113"
volumes:
- iii-data:/data
- ./iii-config.docker.yaml:/app/config.yaml:ro
- agentmemory-data:/data
env_file: .env
environment:
AGENTMEMORY_TOOLS: all
AGENTMEMORY_SECRET_FILE: /data/.hmac
III_ENGINE_URL: ws://127.0.0.1:49134
III_REST_PORT: "3111"
AGENTMEMORY_MCP_PORT: "3114"
AGENTMEMORY_REST_HOST: "127.0.0.1"
AGENTMEMORY_VIEWER_HOST: "0.0.0.0"
VIEWER_ALLOWED_HOSTS: "${VIEWER_ALLOWED_HOSTS:-localhost:3113,127.0.0.1:3113}"
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:3111/agentmemory/livez"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
restart: unless-stopped
logging:
driver: json-file
Expand All @@ -44,4 +32,4 @@ services:
max-file: "3"

volumes:
iii-data:
agentmemory-data:
112 changes: 112 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/sh
# agentmemory first-boot entrypoint.
#
# Runs as root so it can:
# 1. Overwrite the npm-bundled iii-config.yaml (which binds 127.0.0.1
# and uses relative ./data paths) with a deploy-tuned version that
# binds 0.0.0.0 and uses absolute /data paths.
# 2. chown the platform-mounted /data volume to the runtime user
# (managed platforms mount volumes root-owned 755 by default).
# 3. Generate the HMAC secret on first boot and persist it to
# /data/.hmac (chmod 600) so the secret survives restarts.
#
# Then it execs the agentmemory CLI under gosu as the unprivileged
# `node` user.

set -eu

DATA_DIR="${AGENTMEMORY_DATA_DIR:-/data}"
HMAC_FILE="${AGENTMEMORY_HMAC_FILE:-/data/.hmac}"
RUN_AS="node:node"
III_CONFIG="/app/iii-config.yaml"

mkdir -p "$DATA_DIR"
chown -R "$RUN_AS" "$DATA_DIR"

cat > "$III_CONFIG" <<'EOF'
workers:
- name: iii-http
config:
port: 3111
host: 0.0.0.0
default_timeout: 180000
cors:
allowed_origins:
- "http://localhost:3111"
- "http://localhost:3113"
- "http://localhost:3114"
- "http://127.0.0.1:3111"
- "http://127.0.0.1:3113"
- "http://127.0.0.1:3114"
allowed_methods: [GET, POST, PUT, DELETE, OPTIONS]
- name: iii-state
config:
adapter:
name: kv
config:
store_method: file_based
file_path: /data/state_store.db
- name: iii-queue
config:
adapter:
name: builtin
- name: iii-pubsub
config:
adapter:
name: local
- name: iii-cron
config:
adapter:
name: kv
- name: iii-stream
config:
port: 3112
host: 0.0.0.0
adapter:
name: kv
config:
store_method: file_based
file_path: /data/stream_store
- name: iii-observability
config:
enabled: true
service_name: agentmemory
exporter: memory
sampling_ratio: 1.0
metrics_enabled: true
logs_enabled: true
logs_console_output: true
EOF
chown "$RUN_AS" "$III_CONFIG"

if [ ! -s "$HMAC_FILE" ]; then
SECRET="$(openssl rand -hex 32)"
umask 077
printf '%s\n' "$SECRET" > "$HMAC_FILE"
chmod 600 "$HMAC_FILE"
chown "$RUN_AS" "$HMAC_FILE"
echo "================================================================"
echo "agentmemory: generated HMAC secret on first boot"
echo "AGENTMEMORY_SECRET=$SECRET"
echo "Copy this value now. It will not be printed again."
echo "Stored at: $HMAC_FILE (chmod 600)"
echo "To rotate: delete $HMAC_FILE on the persistent volume and restart."
echo "================================================================"
fi

AGENTMEMORY_SECRET="$(cat "$HMAC_FILE")"
export AGENTMEMORY_SECRET

# Start iii-engine in the background.
iii --config "$III_CONFIG" &
III_PID=$!

_shutdown() {
kill -TERM $III_PID 2>/dev/null || true
wait $III_PID 2>/dev/null || true
exit 0
}
trap _shutdown TERM INT

# Start agentmemory in the foreground; the container exits when it exits.
gosu "$RUN_AS" node /app/dist/index.mjs
53 changes: 0 additions & 53 deletions iii-config.docker.yaml

This file was deleted.

Loading