Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 30 additions & 19 deletions src/content/docs/docs/cli/config-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sidebar:

This page explains how to configure the mcp-automem client to connect to your AutoMem service. It covers environment variables, configuration resolution priority, platform-specific configuration files, and validation. For initial setup instructions, see [Setup & Installation](/docs/cli/setup/). For platform-specific integration details, see [Platform Installers](/docs/cli/platform-installers/).

The examples on this page are pinned to the audited `mcp-automem` `0.16.0` release commit `9a0bbf754dd31db524da25638b0e97907e32ff37`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the audited parent-watchdog setting

The new release-pin claim leaves the environment-variable reference incomplete: the repository's pinned audit at .github/docs-pr-reconciliation/audits/release-audit-final.md:64 identifies AUTOMEM_PARENT_WATCHDOG_MS as a supported 0.16.0 runtime setting, with a 30,000 ms default, POSIX-only effect, and no disable value, and explicitly requires a row here. Operators needing to tune lifecycle polling therefore cannot discover this setting from the page now presented as release-audited.

Useful? React with 👍 / 👎.


## Environment Variables

The mcp-automem client uses two primary environment variables to locate and authenticate with the AutoMem backend service. These can be set via `.env` file, shell environment, or platform-specific MCP configuration files.
Expand Down Expand Up @@ -66,12 +68,16 @@ graph TB
subgraph Env_Resolution["Environment Variable Resolution<br/>src/env.ts + src/index.ts"]
DOTENV["dotenv.config()<br/>.env file loading"]

ENDPOINT_CHECK{"AUTOMEM_API_URL<br/>exists?"}
ENDPOINT_CHECK{"AUTOMEM_API_URL<br/>nonblank?"}
PLUGIN_URL_CHECK{"CLAUDE_PLUGIN_OPTION_API_URL<br/>nonblank?"}
LEGACY_URL_CHECK{"AUTOMEM_ENDPOINT<br/>nonblank?"}
ENDPOINT_DEFAULT["Default:<br/>http://127.0.0.1:8001"]
ENDPOINT_VALUE["Use env value"]
ENDPOINT_VALUE["Use AUTOMEM_API_URL"]
PLUGIN_URL_VALUE["Use Claude plugin URL"]
LEGACY_URL_VALUE["Use legacy alias"]

API_KEY_FUNC["readAutoMemApiKeyFromEnv()<br/>src/env.ts"]
KEY_PRIORITY["Priority:<br/>1. AUTOMEM_API_KEY<br/>2. AUTOMEM_API_TOKEN"]
KEY_PRIORITY["Priority:<br/>1. AUTOMEM_API_KEY<br/>2. AUTOMEM_API_TOKEN<br/>3. CLAUDE_PLUGIN_OPTION_API_KEY / api_key<br/>4. CLAUDE_PLUGIN_OPTION_API_TOKEN / api_token"]
end

subgraph Client_Config["AutoMemClient Config<br/>src/index.ts"]
Expand All @@ -80,10 +86,16 @@ graph TB
end

DOTENV --> ENDPOINT_CHECK
ENDPOINT_CHECK -->|"No"| ENDPOINT_DEFAULT
ENDPOINT_CHECK -->|"No"| PLUGIN_URL_CHECK
ENDPOINT_CHECK -->|"Yes"| ENDPOINT_VALUE
PLUGIN_URL_CHECK -->|"No"| LEGACY_URL_CHECK
PLUGIN_URL_CHECK -->|"Yes"| PLUGIN_URL_VALUE
LEGACY_URL_CHECK -->|"No"| ENDPOINT_DEFAULT
LEGACY_URL_CHECK -->|"Yes"| LEGACY_URL_VALUE
ENDPOINT_DEFAULT --> CONFIG_OBJ
ENDPOINT_VALUE --> CONFIG_OBJ
PLUGIN_URL_VALUE --> CONFIG_OBJ
LEGACY_URL_VALUE --> CONFIG_OBJ

DOTENV --> API_KEY_FUNC
API_KEY_FUNC --> KEY_PRIORITY
Expand Down Expand Up @@ -114,6 +126,7 @@ graph TB
- Direct shell environment: `export AUTOMEM_API_URL=...`
- `.env` file in current directory (loaded via `dotenv`)
- Platform-specific MCP server `env` blocks
- Resolution order: `AUTOMEM_API_URL` → `CLAUDE_PLUGIN_OPTION_API_URL` → `AUTOMEM_ENDPOINT`
2. **`~/.claude.json` configuration**
- Used by CLI commands when environment is not set
- Fallback for queue processing and other utilities
Expand Down Expand Up @@ -143,7 +156,7 @@ Each AI platform stores MCP server configuration differently. The setup wizard a
```json
{
"mcpServers": {
"automem": {
"memory": {
"command": "npx",
"args": ["@verygoodplugins/mcp-automem"],
"env": {
Expand All @@ -155,22 +168,21 @@ Each AI platform stores MCP server configuration differently. The setup wizard a
}
```

The `command` and `args` launch the MCP server in stdio mode. The `env` block passes configuration to the server process. Platform launchers spawn this command when initializing MCP connections.
This generic JSON example matches the shipped `config --format=json` output shape: it uses the `memory` server key and does not prepend `-y` in `args`. The `command` and `args` launch the MCP server in stdio mode, and the `env` block passes configuration to the server process.

### TOML Configuration Example (Codex)

```toml
[[mcp_servers]]
name = "automem"
[mcp_servers.memory]
command = "npx"
args = ["@verygoodplugins/mcp-automem"]
args = ["-y", "@verygoodplugins/mcp-automem"]

[mcp_servers.env]
[mcp_servers.memory.env]
AUTOMEM_API_URL = "http://localhost:8001"
AUTOMEM_API_KEY = "your-api-key"
```

The TOML format is semantically equivalent to JSON but uses Codex's native configuration syntax.
This example mirrors the shipped Codex template. It documents the released config shape, but whether a specific Codex build accepts and renders it is still a UI-level check in the host app.

## Configuration Validation

Expand Down Expand Up @@ -229,7 +241,7 @@ Example CLI commands that require configuration:

```bash
# All CLI commands use the same config resolution
npx @verygoodplugins/mcp-automem recall "project architecture"
npx @verygoodplugins/mcp-automem recall --query "project architecture"
npx @verygoodplugins/mcp-automem queue
npx @verygoodplugins/mcp-automem config
```
Expand All @@ -242,11 +254,10 @@ Set `AUTOMEM_LOG_LEVEL=debug` to enable verbose logging in server mode:
AUTOMEM_LOG_LEVEL=debug npx @verygoodplugins/mcp-automem
```

Debug output includes:
- Configuration values loaded (API key is masked)
- Each tool call with parameters
- HTTP request/response details
- Retry attempts and backoff timing
At the audited release, debug stderr is narrow:

- `AUTOMEM_PROCESS_TAG` or `MCP_PROCESS_TAG` can add a tagged process-title line in interactive sessions.
- Server mode logs `AutoMem server running on stdio transport`.

## Configuration Generation

Expand Down Expand Up @@ -317,7 +328,7 @@ If you receive `401 Unauthorized` errors:
If configuration behaves unexpectedly, use debug mode to see which values are being loaded:

```bash
AUTOMEM_LOG_LEVEL=debug npx @verygoodplugins/mcp-automem recall "test"
AUTOMEM_LOG_LEVEL=debug npx @verygoodplugins/mcp-automem
```

The debug output shows the resolved `endpoint` and whether an `apiKey` was found (the actual key value is masked for security).
Expect the narrow stderr lines above rather than per-tool traces, HTTP dumps, or retry/backoff logs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the ineffective debug troubleshooting instruction

When configuration resolution behaves unexpectedly, the preceding text still tells users to enable debug mode “to see which values are being loaded,” but this replacement now correctly states that the audited output contains only the conditional process-title line and the server-start line. Neither reveals the resolved endpoint, key presence, or winning source, so following this troubleshooting step cannot diagnose the stated problem; replace it with an actual way to inspect the effective configuration rather than merely telling readers to expect no traces.

Useful? React with 👍 / 👎.

52 changes: 52 additions & 0 deletions tests/config-tools-docs.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';

const defaultPagePath = fileURLToPath(
new URL('../src/content/docs/docs/cli/config-tools.md', import.meta.url),
);
const pagePath = process.env.CONFIG_TOOLS_DOCS_PAGE_PATH || defaultPagePath;
const releaseSha = '9a0bbf754dd31db524da25638b0e97907e32ff37';

async function readPage() {
return readFile(pagePath, 'utf8');
}

test('config tools docs match the audited 0.16.0 config surfaces', async () => {
const page = await readPage();

assert.match(page, new RegExp(releaseSha, 'u'));
assert.match(
page,
/AUTOMEM_API_URL[\s\S]*CLAUDE_PLUGIN_OPTION_API_URL[\s\S]*AUTOMEM_ENDPOINT[\s\S]*http:\/\/127\.0\.0\.1:8001/i,
);
assert.match(page, /CLAUDE_PLUGIN_OPTION_API_KEY/);
assert.match(page, /CLAUDE_PLUGIN_OPTION_API_TOKEN/);

assert.match(page, /"memory"\s*:\s*\{/);
assert.match(
page,
/"args"\s*:\s*\[\s*"@verygoodplugins\/mcp-automem"\s*\]/,
);
assert.doesNotMatch(
page,
/"args"\s*:\s*\[\s*"-y"\s*,\s*"@verygoodplugins\/mcp-automem"\s*\]/,
);

assert.match(page, /\[mcp_servers\.memory\]/);
assert.match(page, /\[mcp_servers\.memory\.env\]/);
assert.match(page, /args = \["-y", "@verygoodplugins\/mcp-automem"\]/);
assert.doesNotMatch(page, /\[\[mcp_servers\]\]/);
assert.doesNotMatch(page, /name = "automem"/);

assert.match(page, /mcp-automem recall --query "project architecture"/);
assert.doesNotMatch(page, /mcp-automem recall "project architecture"/);

assert.match(page, /AUTOMEM_PROCESS_TAG=cursor-session-1/);
assert.match(page, /AutoMem server running on stdio transport/);
assert.doesNotMatch(page, /HTTP request\/response details/i);
assert.doesNotMatch(page, /Retry attempts and backoff timing/i);
assert.doesNotMatch(page, /Each tool call with parameters/i);
assert.doesNotMatch(page, /Configuration values loaded/i);
});