Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0289f69
refactor(cli): generalise mcp-setup ClientTarget with format + entryP…
May 4, 2026
6f86ffb
feat(cli): mcp-setup monorepo context detection + --installed/--monor…
May 4, 2026
97fe26b
feat(cli): mcp-setup detects Claude Desktop + Windsurf (phase 3 of fo…
May 4, 2026
9e0ac7c
feat(cli): mcp-setup detects VSCode + Copilot Chat (phase 4 of follow…
May 4, 2026
ef0d2fd
feat(cli): mcp-setup detects Cline at VSCode globalStorage (phase 5 o…
May 4, 2026
ad1917a
docs(cli): refresh mcp-setup JSDoc header for post-phase-5 surface (p…
May 4, 2026
f509c34
docs(readme): expand client list to 6 + add monorepo dev workflow (Pa…
May 5, 2026
0756b0d
docs(mcp-dkg): mirror client-list expansion + monorepo dev workflow (…
May 5, 2026
14d2992
fix(cli): resolve absolute dkg bin path on mcp setup to fix GUI-clien…
May 5, 2026
004c873
feat(cli): per-client interactive confirm prompts in mcp setup (F31)
May 7, 2026
cdc3a5d
docs(readme): document F31 per-client confirm prompts + --yes flag
May 7, 2026
1076dfc
fix(cli): address Codex review findings on PR #394 (3 bugs + 2 issues)
May 7, 2026
b0979c2
fix(cli): address Codex round-2 review on PR #394 (3 bugs)
May 7, 2026
b122610
fix(cli,core): address Codex round-3 review on PR #394 (3 findings)
May 7, 2026
a7bc92d
fix(cli): converge MCP entry shape on process.execPath; tighten F31 T…
May 7, 2026
6f669ec
fix(cli): --monorepo bypasses configExists fallback; correct --force …
May 7, 2026
a1ceff6
fix(cli,docs): reject ephemeral install paths; respect XDG_CONFIG_HOM…
May 7, 2026
3be6672
fix(cli,docs): narrow --installed flag scope; complete yaml fast-path…
May 7, 2026
b423b1e
fix(cli): preserve --print-only stdout purity; respect DKG_HOME over …
May 7, 2026
a95da7a
fix(cli): propagate DKG_HOME into MCP entry; restore non-zero exit on…
May 7, 2026
d1a04cc
fix(mcp-dkg): loadConfig honors DKG_HOME for setup-coherence
May 7, 2026
97c8340
fix(cli): auto-detect monorepo by running CLI's location; probe Windo…
May 7, 2026
a8d1f89
fix(cli): forced --monorepo searches cwd; classifier merges env inste…
May 7, 2026
076f866
fix(cli,docs): add Cursor to WSL detection; clarify README monorepo d…
May 7, 2026
dc44160
fix(mcp-dkg,cli): loadConfig reads json+yaml from DKG_HOME; writeRegi…
May 7, 2026
29bd5e1
fix(mcp-dkg,cli): translate setup-home daemon config to DkgConfig; co…
May 7, 2026
e7880e8
fix(cli,docs): decouple mcp-setup from adapter-openclaw writeDkgConfi…
May 7, 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
73 changes: 63 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Pick the on-ramp that matches how you're already working:

| You want… | Recipe | More |
|---|---|---|
| **DKG V10 as memory for Cursor / Claude Code / Continue / Cline** | [MCP setup](#dkg-v10-as-agent-memory-mcp) | two commands |
| **DKG V10 as memory for Cursor / Claude Code / Claude Desktop / Windsurf / VSCode + Copilot / Cline** | [MCP setup](#dkg-v10-as-agent-memory-mcp) | two commands |
| **DKG V10 wired into an OpenClaw agent** | [OpenClaw setup](#openclaw-adapter) | two commands |
| **DKG V10 inside an ElizaOS agent** | [ElizaOS adapter](packages/adapter-elizaos/README.md) | adapter README |
| **DKG V10 inside a Hermes agent** | [Hermes adapter](packages/adapter-hermes/README.md) | adapter README |
Expand All @@ -91,7 +91,7 @@ Every on-ramp installs the same `@origintrail-official/dkg` umbrella package, ru

### DKG V10 as agent memory (MCP)

Two commands give Cursor, Claude Code, Continue, or Cline a verifiable shared memory layer:
Two commands give six MCP-aware clients (Cursor, Claude Code, Claude Desktop, Windsurf, VSCode + GitHub Copilot Chat, Cline) a verifiable shared memory layer:

```bash
npm install -g @origintrail-official/dkg # installs CLI + bundled MCP server
Expand All @@ -103,24 +103,33 @@ That's it. The first command installs the `dkg` umbrella CLI; the second runs a
1. Initializes `~/.dkg/config.json` if it doesn't exist (skipped silently when present)
2. Starts the DKG daemon as a background process (skipped if already running)
3. Funds the node's wallets via the testnet faucet (skip with `--no-fund` for CI)
4. Registers the MCP server with each detected client (Cursor, Claude Code) by writing a single canonical entry under `mcpServers.dkg`:
4. Registers the MCP server with each detected client by writing a single canonical entry. **You confirm per detected client interactively** (`Register DKG MCP with <client>? [Y/n]`) unless `--yes` is passed; non-TTY invocations (CI, piped stdin) auto-confirm so scripts don't hang. The detection set is the six clients above: Cursor (`~/.cursor/mcp.json`), Claude Code (`~/.claude.json`), Claude Desktop (per-platform — `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on Windows, `$XDG_CONFIG_HOME/Claude/claude_desktop_config.json` (or `~/.config/Claude/...` when XDG_CONFIG_HOME is unset) on Linux), Windsurf (`~/.codeium/windsurf/mcp_config.json`), VSCode + GitHub Copilot Chat (per-platform Code user-settings dir + `mcp.json` — note this client uses the `servers.dkg` shape, not `mcpServers.dkg`), and Cline (deep-nested under VSCode's per-extension globalStorage at `Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`). The five `mcpServers.dkg` clients receive the same JSON block, with absolute paths resolved by setup so the registration has zero PATH dependencies in the MCP-client environment:

```json
{
"mcpServers": {
"dkg": {
"command": "dkg",
"args": ["mcp", "serve"]
"command": "/usr/local/bin/node",
"args": [
"/usr/local/lib/node_modules/@origintrail-official/dkg/dist/cli.js",
"mcp",
"serve"
],
"env": {
"DKG_HOME": "/Users/you/.dkg"
}
}
}
}
```

The `command` is the absolute path to the Node binary running this CLI (`process.execPath` at setup time); the first arg is the absolute path to the installed CLI's `cli.js` (resolved from `process.argv[1]` via `realpathSync`, which canonicalises symlinks across `npm relink` / version-manager rotations). GUI MCP clients (Claude Desktop, Windsurf, VSCode + Copilot) often don't inherit the shell PATH that includes `node` or the `dkg` shim, so writing the resolved absolute paths makes the registration robust against that gap. The `env.DKG_HOME` field propagates the resolved bootstrap home so spawned MCP servers (which don't inherit shell env in GUI clients) read the same `config.yaml` / `auth.token` that setup just bootstrapped — important when the operator runs setup with `DKG_HOME=/custom`, or under `--monorepo` where the home is `~/.dkg-dev`. `dkg mcp setup` resolves and writes all three automatically — you only need this manual shape when configuring by hand. For VSCode + Copilot Chat, swap the outer `mcpServers` key for `servers` while keeping the same inner block.

5. Verifies the daemon is healthy

No tokens or URLs in the JSON — those live in `~/.dkg/config.yaml` and the daemon-written `~/.dkg/auth.token`. If no client config is detected, run `dkg mcp setup --print-only` to emit the JSON for manual paste.

**Each step is idempotent and skippable.** Re-running `dkg mcp setup` on an already-set-up box is safe — every step short-circuits when its work is already done. Step-skip flags: `--no-start` (configure only, don't start the daemon), `--no-fund` (skip faucet — CI-friendly), `--no-verify` (skip the post-setup probe), `--dry-run` (preview what would happen), `--force` (refresh every detected client config regardless of state). First-init overrides: `--port <n>`, `--name <s>`.
**Each step is idempotent and skippable.** Re-running `dkg mcp setup` on an already-set-up box is safe — every step short-circuits when its work is already done. Step-skip flags: `--no-start` (configure only, don't start the daemon), `--no-fund` (skip faucet — CI-friendly), `--no-verify` (skip the post-setup probe), `--dry-run` (preview what would happen), `--force` (refresh every detected client config regardless of state), `--yes` (auto-confirm per-client registrations; default false — TTY mode prompts interactively, non-TTY auto-confirms; pass `--yes` in scripts for the safer scripted-environment posture). First-init overrides: `--port <n>`, `--name <s>`.

**First-run verification.** Restart your client so it discovers the MCP, then ask it: *"What tools does dkg expose?"* The `tools/list` response must include at least `dkg_assertion_create`, `dkg_assertion_write`, and `dkg_memory_search`. Then trigger the [round-trip](#round-trip-write-then-recall) below to prove the wiring works end to end.

Expand All @@ -131,7 +140,7 @@ The validated path agents follow when "remember this" actually has to mean *cryp
1. **Install** — `npm install -g @origintrail-official/dkg`
2. **Set up** — `dkg mcp setup` (the bundled flow: initializes config, starts the daemon, funds wallets via testnet faucet, registers the MCP with detected clients, verifies daemon health)
3. **Confirm reachable** — `dkg status` returns a PeerId; `curl -s http://127.0.0.1:9200/health` is `200`
4. **Restart your client** — Cursor / Claude Code / Continue / Cline picks up the new MCP entry on next launch
4. **Restart your client** — Cursor / Claude Code / Claude Desktop / Windsurf / VSCode + Copilot / Cline picks up the new MCP entry on next launch
5. **(no manual CG creation)** — `agent-context` is auto-created on first write by the storage layer; the round-trip below assumes it
6. **Write** — agent calls `dkg_assertion_create` with `name: "session-2026-05-04"`, then `dkg_assertion_write` with one or more quads. Both tools are idempotent / additive — re-runs are safe.
7. **Recall** — agent calls `dkg_memory_search` with a keyword from the write. The result includes `contextGraphId`, `layer` (`working-memory`, `shared-working-memory`, or `verified-memory`), and a `trustWeight` per hit; higher-trust layers collapse lower-trust hits for the same entity. The just-written triple comes back from the WM layer.
Expand All @@ -142,14 +151,58 @@ That round-trip — write → search → optionally promote → optionally final

#### Troubleshooting (MCP)

- **`dkg mcp setup` says "no MCP-aware clients detected"** → install Cursor, Claude Code, Continue, or Cline (or run with `--print-only` to copy the JSON yourself).
- **`dkg mcp setup` says "no MCP-aware clients detected"** → install one of Cursor, Claude Code, Claude Desktop, Windsurf, VSCode + GitHub Copilot Chat, or Cline. Continue and Codex CLI are NOT auto-detected today (Continue's YAML-config shape and Codex CLI's TOML format ship in a follow-up); users with those clients should run `dkg mcp setup --print-only` and paste the JSON manually.
- **`dkg mcp` says command not found** → the umbrella CLI isn't on PATH; verify with `which dkg`. `npm i -g @origintrail-official/dkg` does NOT propagate transitive bins, so `dkg-mcp` directly is also unavailable — always go through `dkg mcp serve`.
- **MCP not visible in client** → restart the client; on Cursor verify `~/.cursor/mcp.json` is syntactically valid; on Claude Code run `claude mcp list`.
- **HTTP 401 from MCP tools** → token mismatch. `dkg auth show` returns the expected value; confirm it matches `~/.dkg/auth.token`. On CI / containers / proxied environments where `dkg init` can't run, set the env-var fallbacks documented at `packages/mcp-dkg/src/config.ts`: `DKG_API` (daemon URL), `DKG_TOKEN` (bearer), `DKG_PROJECT` (default context graph), `DKG_AGENT_URI`. A stale exported `DKG_PROJECT` from a prior session can silently mis-route writes — unset it if you switch projects.
- **Daemon unreachable** → `dkg status`; if it errors, `dkg logs` and `cat ~/.dkg/daemon.log`. Stale pid → `cat ~/.dkg/daemon.pid` and kill it, then `dkg start` again.
- **Port 9200 already in use** → another node is running. `dkg stop` once, or override via `dkg init` and pick a different API port.
- **WSL2: daemon dies when the terminal closes** → wrap in `tmux` or install as a systemd user service. See the [WSL2 section in JOIN_TESTNET.md](docs/setup/JOIN_TESTNET.md) for the systemd unit file.

#### Contributor (monorepo dev) workflow

To register the local monorepo CLI dist with your MCP clients (so the registered server runs your in-progress changes), use **either** of these two entry-points. Auto-detect keys off the *running CLI's* on-disk location, **not** your shell `cwd` — so just `cd`-ing into the checkout and calling the global `dkg` is NOT enough.

**Option A (preferred): invoke the repo-built CLI directly.** Auto-detect sees the running CLI lives inside the monorepo and switches to monorepo mode automatically:

```bash
pnpm --filter @origintrail-official/dkg build # rebuild the CLI dist
node packages/cli/dist/cli.js mcp setup # invoke the local build directly
```

**Option B: pass `--monorepo` with the global bin.** When you have `npm i -g @origintrail-official/dkg` already and want to override auto-detect from the global install, pass `--monorepo` from inside the checkout. The flag's contract is "use the monorepo from this `cwd`", so the global `dkg` invocation resolves the local checkout via cwd:

```bash
pnpm --filter @origintrail-official/dkg build # rebuild the CLI dist
dkg mcp setup --monorepo # global `dkg` + explicit monorepo override
```

Either way, the resolved registration looks like this — the shape stays uniform across modes; only `args[0]` differs:

```json
{
"mcpServers": {
"dkg": {
"command": "/usr/local/bin/node",
"args": ["/absolute/path/to/dkg-v9/packages/cli/dist/cli.js", "mcp", "serve"]
}
}
}
```

**What does NOT work**: `cd dkg-v9 && dkg mcp setup` (without `--monorepo`). With a globally-installed `dkg`, the running CLI lives at the npm global path — auto-detect sees that location is outside any monorepo and stays in installed mode, registering the global build. Your local edits won't be picked up. Either invoke the local dist directly (Option A) or pass `--monorepo` (Option B).

**Always rebuild before re-running setup** — skip the rebuild and the registered entry points at a stale `dist/cli.js`, so your edits won't show up.

**Mode overrides** (mutually exclusive — pass at most one):

- `--installed` forces installed-mode setup. **Bootstrap home**: `~/.dkg`. **Registered binary**: the running CLI (whichever invoked the command — typically the global `dkg`). Use this from a monorepo cwd when you want the global install registered instead of the local dist. Only the bootstrap home changes — the registered binary is always the CLI you ran.
- `--monorepo` forces monorepo-mode setup. **Bootstrap home**: `~/.dkg-dev`. **Registered binary**: the local `<repo>/packages/cli/dist/cli.js` script (located via cwd-first walk; falls back to the running CLI dir). Errors if no DKG monorepo root is detected. Unlike `--installed`, this switches **both** the bootstrap home **and** the registered binary — so re-running setup in a fresh checkout with `--monorepo` swaps the persisted MCP entry to the local build.

The `[setup] Registering CLI: …` log line emitted at registration time prints the exact `command` and `args` that will be persisted into client configs, so you can verify the resolved binary path before any write happens.

**Moved checkout caveat.** The written `args` carry an absolute path. If you rename or move your checkout, every registered client still points at the old path. Re-run `dkg mcp setup --force` from the new location to refresh every detected client's entry.

### OpenClaw adapter

Two commands:
Expand Down Expand Up @@ -286,7 +339,7 @@ dkg auth status # show whether auth is enabled
# Framework adapters & MCP wiring
dkg openclaw setup # install & configure the OpenClaw adapter
dkg hermes setup # install & configure the Hermes adapter
dkg mcp setup # register the MCP server with Cursor / Claude Code / Continue / Cline
dkg mcp setup # register the MCP server with Cursor / Claude Code / Claude Desktop / Windsurf / VSCode + Copilot / Cline
dkg mcp serve # run the MCP server on stdio (invoked by the client; not run manually)

# Community integrations (registry: OriginTrail/dkg-integrations)
Expand Down Expand Up @@ -327,7 +380,7 @@ Use adapters for OpenClaw, ElizaOS, Hermes, or your own Node.js / TypeScript pro

| Guide | Use it when |
|---|---|
| [DKG V10 as agent memory (MCP)](#dkg-v10-as-agent-memory-mcp) | You want Cursor / Claude Code / Continue / Cline to use DKG as memory |
| [DKG V10 as agent memory (MCP)](#dkg-v10-as-agent-memory-mcp) | You want Cursor / Claude Code / Claude Desktop / Windsurf / VSCode + Copilot / Cline to use DKG as memory |
| [`packages/mcp-dkg/README.md`](packages/mcp-dkg/README.md) | You want the full MCP tool surface and config reference |
| [Join the Testnet](docs/setup/JOIN_TESTNET.md) | You want a full node setup and first publish/query flow |
| [OpenClaw Setup](docs/setup/SETUP_OPENCLAW.md) | You want OpenClaw to use DKG as memory/tools |
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-openclaw/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ export async function runSetup(options: SetupOptions): Promise<void> {
}
} catch { /* use pre-merge values */ }
} else if (network) {
log(`[dry-run] Would write ~/.dkg/config.json (${network.networkName}, port ${apiPort})`);
log(`[dry-run] Would write ${join(dkgDir(), 'config.json')} (${network.networkName}, port ${apiPort})`);
}

// Step 4: Preflight ~/.openclaw/openclaw.json BEFORE the daemon spins up
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,9 @@ mcpCmd
.option('--dry-run', 'Preview steps without writing or starting anything')
.option('--force', 'Refresh every detected client regardless of current registration state')
.option('--print-only', 'Print the canonical JSON to stdout; skip every other step')
.option('--yes', 'Auto-confirm all registrations (default; reserved for future interactive prompts)')
.option('--yes', 'Auto-confirm per-client registrations (default false: prompt interactively in TTY mode; non-TTY auto-confirms — pass `--yes` in scripts for the safer scripted-environment posture)')
.option('--installed', 'Force installed-mode setup. Bootstrap home: `~/.dkg`. Registered binary: the running CLI (whichever invoked this command — typically the global `dkg`). Use this from a monorepo cwd when you want the global install instead of the local dist. Mutually exclusive with --monorepo.')
.option('--monorepo', 'Force monorepo-mode setup. Bootstrap home: `~/.dkg-dev`. Registered binary: the local `<repo>/packages/cli/dist/cli.js` script (located via cwd-first walk; falls back to the running CLI dir). Errors if no DKG monorepo root is detected. Switches BOTH bootstrap home AND the registered binary, unlike --installed which only switches the home. Mutually exclusive with --installed.')
.action(async (opts) => {
// Dynamic-import the openclaw-setup primitives for the bundled
// init + daemon-start. Same import surface (and same package
Expand Down Expand Up @@ -1835,11 +1837,13 @@ mcpCmd
try {
await mcpSetupAction(opts, {
loadNetworkConfig: openclawSetupExports.loadNetworkConfig,
writeDkgConfig: openclawSetupExports.writeDkgConfig,
ensureDkgNodeConfig: coreExports.ensureDkgNodeConfig,
startDaemon: openclawSetupExports.startDaemon,
readWalletsWithRetry: openclawSetupExports.readWalletsWithRetry,
logManualFundingInstructions: openclawSetupExports.logManualFundingInstructions,
requestFaucetFunding: coreExports.requestFaucetFunding,
findDkgMonorepoRoot: coreExports.findDkgMonorepoRoot,
resolveDkgConfigHome: coreExports.resolveDkgConfigHome,
});
} catch (err: any) {
console.error(`\n[dkg mcp setup] ERROR: ${err?.message ?? err}\n`);
Expand Down
Loading
Loading