@totalreclaw/mcp-server 3.2.0 → 3.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +2 -1
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +119 -168
  5. package/dist/index.js.map +1 -1
  6. package/dist/pair-crypto.d.ts +95 -0
  7. package/dist/pair-crypto.d.ts.map +1 -0
  8. package/dist/pair-crypto.js +223 -0
  9. package/dist/pair-crypto.js.map +1 -0
  10. package/dist/pair-remote-client.d.ts +78 -0
  11. package/dist/pair-remote-client.d.ts.map +1 -0
  12. package/dist/pair-remote-client.js +355 -0
  13. package/dist/pair-remote-client.js.map +1 -0
  14. package/dist/prompts.d.ts +3 -2
  15. package/dist/prompts.d.ts.map +1 -1
  16. package/dist/prompts.js +14 -7
  17. package/dist/prompts.js.map +1 -1
  18. package/dist/session-id.d.ts +17 -0
  19. package/dist/session-id.d.ts.map +1 -0
  20. package/dist/session-id.js +26 -0
  21. package/dist/session-id.js.map +1 -0
  22. package/dist/subgraph/confirm-indexed.d.ts +37 -0
  23. package/dist/subgraph/confirm-indexed.d.ts.map +1 -0
  24. package/dist/subgraph/confirm-indexed.js +99 -0
  25. package/dist/subgraph/confirm-indexed.js.map +1 -0
  26. package/dist/subgraph/reranker.d.ts +49 -134
  27. package/dist/subgraph/reranker.d.ts.map +1 -1
  28. package/dist/subgraph/reranker.js +84 -376
  29. package/dist/subgraph/reranker.js.map +1 -1
  30. package/dist/tools/index.d.ts +1 -0
  31. package/dist/tools/index.d.ts.map +1 -1
  32. package/dist/tools/index.js +7 -1
  33. package/dist/tools/index.js.map +1 -1
  34. package/dist/tools/pair.d.ts +118 -0
  35. package/dist/tools/pair.d.ts.map +1 -0
  36. package/dist/tools/pair.js +399 -0
  37. package/dist/tools/pair.js.map +1 -0
  38. package/dist/tools/pin.d.ts +12 -0
  39. package/dist/tools/pin.d.ts.map +1 -1
  40. package/dist/tools/pin.js +14 -0
  41. package/dist/tools/pin.js.map +1 -1
  42. package/dist/tools/retype.d.ts +15 -0
  43. package/dist/tools/retype.d.ts.map +1 -1
  44. package/dist/tools/retype.js +17 -0
  45. package/dist/tools/retype.js.map +1 -1
  46. package/dist/tools/status.d.ts.map +1 -1
  47. package/dist/tools/status.js +19 -5
  48. package/dist/tools/status.js.map +1 -1
  49. package/package.json +4 -2
package/README.md CHANGED
@@ -141,7 +141,8 @@ All 19 tools are invoked by the host agent from natural language context. Tool s
141
141
  | `totalreclaw_migrate` | Migrate testnet memories to mainnet after Pro upgrade |
142
142
  | `totalreclaw_account` | View account details (wallet, tier, quota, phrase hint) |
143
143
  | `totalreclaw_support` | Troubleshooting help + contact links |
144
- | `totalreclaw_setup` | Generate or import a recovery phrase (first-run flow) |
144
+
145
+ > **Onboarding (recovery phrase):** the `totalreclaw_setup` tool was removed in 3.2.1 for phrase-safety. Onboarding follows the URL-driven flow at [`docs/guides/claude-code-setup.md`](../docs/guides/claude-code-setup.md): the user sources their phrase out-of-band (OpenClaw / Hermes browser pair flow, offline BIP-39 generator, or a prior `~/.totalreclaw/credentials.json` cache) and pastes it into `TOTALRECLAW_RECOVERY_PHRASE` in the MCP host config. The agent never sees the phrase.
145
146
 
146
147
  Users invoke the new v1 tools naturally: *"pin that"*, *"that was actually a rule, not a preference"*, *"file that under work"*. Tool descriptions teach the host LLM to match utterances to tools.
147
148
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import { getSessionId } from './session-id.js';
3
+ export { getSessionId };
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAgMA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.getSessionId = void 0;
40
41
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
41
42
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
42
43
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
@@ -54,6 +55,7 @@ const embedding_js_1 = require("./subgraph/embedding.js");
54
55
  const reranker_js_1 = require("./subgraph/reranker.js");
55
56
  const store_js_1 = require("./subgraph/store.js");
56
57
  const search_js_1 = require("./subgraph/search.js");
58
+ const confirm_indexed_js_1 = require("./subgraph/confirm-indexed.js");
57
59
  const contradiction_sync_js_1 = require("./contradiction-sync.js");
58
60
  const pin_js_1 = require("./tools/pin.js");
59
61
  const retype_js_1 = require("./tools/retype.js");
@@ -70,32 +72,57 @@ const accounts_2 = require("permissionless/accounts");
70
72
  const account_abstraction_1 = require("viem/account-abstraction");
71
73
  const node_crypto_1 = __importDefault(require("node:crypto"));
72
74
  const fs = __importStar(require("node:fs"));
73
- const path = __importStar(require("node:path"));
74
75
  const setup_js_1 = require("./cli/setup.js");
75
76
  // ── Configuration ───────────────────────────────────────────────────────────
76
77
  const SERVER_URL = process.env.TOTALRECLAW_SERVER_URL || 'https://api.totalreclaw.xyz';
77
78
  const MASTER_PASSWORD = process.env.TOTALRECLAW_RECOVERY_PHRASE;
78
79
  // v1 env var cleanup — warn once if any removed env var is still set.
79
80
  // See docs/guides/env-vars-reference.md for the canonical list.
81
+ //
82
+ // NOTE: TOTALRECLAW_SESSION_ID was previously in this list and silently
83
+ // rejected with a warning, breaking Axiom traceability for QA runs that rely
84
+ // on the X-TotalReclaw-Session header for log filtering. Restored as
85
+ // SUPPORTED — see `./session-id.ts` + internal#127. Do NOT add it back.
80
86
  (() => {
81
87
  const removed = [
82
88
  'TOTALRECLAW_CHAIN_ID',
83
89
  'TOTALRECLAW_EMBEDDING_MODEL',
84
90
  'TOTALRECLAW_STORE_DEDUP',
85
91
  'TOTALRECLAW_LLM_MODEL',
86
- 'TOTALRECLAW_SESSION_ID',
87
92
  'TOTALRECLAW_TAXONOMY_VERSION',
88
93
  'TOTALRECLAW_CLAIM_FORMAT',
89
94
  'TOTALRECLAW_DIGEST_MODE',
90
95
  ].filter((name) => process.env[name] !== undefined);
91
96
  if (removed.length > 0) {
97
+ // rc.22 finding #4 — full URL beats relative repo path on stderr.
92
98
  console.error(`TotalReclaw MCP: ignoring removed env var(s): ${removed.join(', ')}. ` +
93
- `See docs/guides/env-vars-reference.md for the v1 env var surface.`);
99
+ `Migration guide: https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/env-vars-reference.md`);
94
100
  }
95
101
  })();
102
+ // QA / observability session-tag reader. See `./session-id.ts`.
103
+ // Re-exported so the existing wide imports of `mcp/src/index.ts` keep working.
104
+ const session_id_js_1 = require("./session-id.js");
105
+ Object.defineProperty(exports, "getSessionId", { enumerable: true, get: function () { return session_id_js_1.getSessionId; } });
96
106
  // ── Client identification ──────────────────────────────────────────────────
97
107
  const client_id_js_1 = require("./client-id.js");
98
108
  let clientIdentifierResolved = false;
109
+ /**
110
+ * Build outbound relay headers including the optional session tag.
111
+ * Uses the late-resolved client identifier — falls back to the raw
112
+ * `getClientId()` value if `getClientIdentifier()` hasn't run yet (which
113
+ * can happen for fetches kicked off before the MCP `initialize` handshake
114
+ * completes, e.g. proactive billing fetch).
115
+ */
116
+ function buildRelayHeaders(overrides = {}) {
117
+ const clientId = clientIdentifierResolved ? getClientIdentifier() : (0, client_id_js_1.getClientId)();
118
+ const headers = {
119
+ 'X-TotalReclaw-Client': clientId,
120
+ };
121
+ const sid = (0, session_id_js_1.getSessionId)();
122
+ if (sid)
123
+ headers['X-TotalReclaw-Session'] = sid;
124
+ return { ...headers, ...overrides };
125
+ }
99
126
  function resolveMnemonic() {
100
127
  // Priority 1: env var
101
128
  if (MASTER_PASSWORD)
@@ -138,10 +165,9 @@ function proactiveBillingFetch(state) {
138
165
  const url = `${state.serverUrl.replace(/\/+$/, '')}/v1/billing/status?wallet_address=${encodeURIComponent(state.smartAccountAddress)}`;
139
166
  fetch(url, {
140
167
  method: 'GET',
141
- headers: {
168
+ headers: buildRelayHeaders({
142
169
  'Authorization': `Bearer ${authKeyHex}`,
143
- 'X-TotalReclaw-Client': getClientIdentifier(),
144
- },
170
+ }),
145
171
  })
146
172
  .then(async (resp) => {
147
173
  if (resp.ok) {
@@ -238,10 +264,9 @@ async function initSubgraphState(mnemonic) {
238
264
  const billingUrl = `${SERVER_URL.replace(/\/+$/, '')}/v1/billing/status?wallet_address=${encodeURIComponent(smartAccountAddress)}`;
239
265
  const resp = await fetch(billingUrl, {
240
266
  method: 'GET',
241
- headers: {
267
+ headers: buildRelayHeaders({
242
268
  'Authorization': `Bearer ${authKeyHex}`,
243
- 'X-TotalReclaw-Client': getClientIdentifier(),
244
- },
269
+ }),
245
270
  signal: AbortSignal.timeout(5000),
246
271
  });
247
272
  if (resp.ok) {
@@ -979,35 +1004,22 @@ async function handleRecallSubgraph(state, args) {
979
1004
  // 6. Detect query intent for dynamic weight selection
980
1005
  const intent = (0, reranker_js_1.detectQueryIntent)(query.trim());
981
1006
  const weights = reranker_js_1.INTENT_WEIGHTS[intent];
982
- // 7. Rerank with BM25 + cosine + importance + recency via weighted RRF
983
- // (+ MMR diversity). Then apply Retrieval v2 Tier 1 source weights via
984
- // core's `rerankWithConfig` using only the bm25/cosine components (the
985
- // MCP-side recency + MMR + intent weighting remain in TS for now).
986
- // Strategy: run the TS reranker to produce the top-K ordering; use
987
- // core's source-weight helper to nudge the final score so assistant-
988
- // authored claims drop behind user-authored ones with comparable text.
989
- const reranked = (0, reranker_js_1.rerank)(query.trim(), queryEmbedding, decryptedCandidates, k, weights);
990
- const core = require('@totalreclaw/core');
991
- const weighted = reranked
992
- .map((r) => {
993
- const s = sourceMap.get(r.id);
994
- const w = s
995
- ? core.sourceWeight(s)
996
- : core.legacyClaimFallbackWeight();
997
- return { r, weightedScore: r.rrfScore * w, sourceWeight: w };
998
- })
999
- .sort((a, b) => b.weightedScore - a.weightedScore)
1000
- .slice(0, k);
1007
+ // 7. Rerank via core's `rerankWithConfig` (BM25 + cosine + intent-weighted
1008
+ // RRF + Tier 1 source weighting in one shot). The legacy `weights`
1009
+ // argument is accepted for API stability but ignored -- core handles
1010
+ // intent-weighting internally based on per-candidate cosine scores.
1011
+ const reranked = (0, reranker_js_1.rerank)(query.trim(), queryEmbedding, decryptedCandidates, k, weights,
1012
+ /* applySourceWeights (Retrieval v2 Tier 1) */ true);
1001
1013
  // 8. Format results
1002
- const memories = weighted.map(({ r, weightedScore, sourceWeight }) => ({
1014
+ const memories = reranked.map((r) => ({
1003
1015
  fact_id: r.id,
1004
1016
  fact_text: r.text,
1005
1017
  type: categoryMap.get(r.id) ?? 'fact',
1006
1018
  source: sourceMap.get(r.id),
1007
1019
  scope: scopeMap.get(r.id),
1008
- score: weightedScore,
1020
+ score: r.rrfScore,
1009
1021
  rrf_score: r.rrfScore,
1010
- source_weight: sourceWeight,
1022
+ source_weight: r.sourceWeight ?? 1.0,
1011
1023
  cosine_similarity: r.cosineSimilarity ?? 0,
1012
1024
  importance: Math.round((r.importance ?? 0.5) * 10),
1013
1025
  age_days: r.createdAt
@@ -1088,6 +1100,25 @@ async function handleForgetSubgraph(state, args) {
1088
1100
  walletAddress: state.smartAccountAddress,
1089
1101
  });
1090
1102
  const { txHash, success } = await (0, store_js_1.submitFactOnChain)(protobuf, config);
1103
+ // Read-after-write: poll the subgraph until the fact is no longer
1104
+ // active (forget flips isActive=false). On timeout we still report
1105
+ // deleted_count: 1 — the chain write IS acknowledged — but flag
1106
+ // `partial: true` so callers know the indexer is still propagating.
1107
+ let indexed = true;
1108
+ if (success) {
1109
+ const subgraphUrl = process.env.TOTALRECLAW_SUBGRAPH_URL || `${state.serverUrl}/v1/subgraph`;
1110
+ try {
1111
+ const r = await (0, confirm_indexed_js_1.confirmIndexed)(factId, {
1112
+ subgraphUrl,
1113
+ authKeyHex: Buffer.from(state.authKey).toString('hex'),
1114
+ expect: 'inactive',
1115
+ });
1116
+ indexed = r.indexed;
1117
+ }
1118
+ catch {
1119
+ indexed = false;
1120
+ }
1121
+ }
1091
1122
  return {
1092
1123
  content: [{
1093
1124
  type: 'text',
@@ -1096,6 +1127,7 @@ async function handleForgetSubgraph(state, args) {
1096
1127
  fact_ids: success ? [factId] : [],
1097
1128
  tx_hash: txHash,
1098
1129
  mode: 'subgraph',
1130
+ ...(success && !indexed ? { partial: true } : {}),
1099
1131
  }),
1100
1132
  }],
1101
1133
  };
@@ -1159,6 +1191,15 @@ function buildPinDepsFromState(state) {
1159
1191
  encryptedEmbedding,
1160
1192
  };
1161
1193
  },
1194
+ confirmIndexed: async (factId, expect) => {
1195
+ const subgraphUrl = process.env.TOTALRECLAW_SUBGRAPH_URL || `${state.serverUrl}/v1/subgraph`;
1196
+ const result = await (0, confirm_indexed_js_1.confirmIndexed)(factId, {
1197
+ subgraphUrl,
1198
+ authKeyHex: Buffer.from(state.authKey).toString('hex'),
1199
+ expect,
1200
+ });
1201
+ return result.indexed;
1202
+ },
1162
1203
  };
1163
1204
  }
1164
1205
  /** Build MetadataOpDeps (retype + set_scope) bound to the live subgraph state. */
@@ -1175,6 +1216,7 @@ function buildMetadataOpDepsFromState(state) {
1175
1216
  encryptBlob: pinDeps.encryptBlob,
1176
1217
  submitBatch: pinDeps.submitBatch,
1177
1218
  generateIndices: pinDeps.generateIndices,
1219
+ confirmIndexed: pinDeps.confirmIndexed,
1178
1220
  };
1179
1221
  }
1180
1222
  /** Handle pin/unpin in subgraph mode. */
@@ -1458,137 +1500,16 @@ function quotaExceededResponse() {
1458
1500
  isError: true,
1459
1501
  };
1460
1502
  }
1461
- // ── Setup tool (unconfigured mode) ──────────────────────────────────────────
1462
- const setupToolDefinition = {
1463
- name: 'totalreclaw_setup',
1464
- description: 'Set up TotalReclaw for first-time use. Generate a new recovery phrase or import an existing one.',
1465
- inputSchema: {
1466
- type: 'object',
1467
- properties: {
1468
- action: {
1469
- type: 'string',
1470
- enum: ['generate', 'import'],
1471
- description: 'Whether to generate a new recovery phrase or import an existing one',
1472
- },
1473
- recovery_phrase: {
1474
- type: 'string',
1475
- description: 'Your existing 12-word BIP-39 recovery phrase (only for action="import")',
1476
- },
1477
- },
1478
- required: ['action'],
1479
- },
1480
- };
1481
- async function handleSetup(args) {
1482
- const input = args;
1483
- const action = input?.action;
1484
- if (action !== 'generate' && action !== 'import') {
1485
- return {
1486
- content: [{ type: 'text', text: JSON.stringify({
1487
- success: false,
1488
- error: 'Invalid action. Use "generate" for a new identity or "import" to restore an existing one.',
1489
- }) }],
1490
- };
1491
- }
1492
- let mnemonic;
1493
- if (action === 'import') {
1494
- const phrase = (input?.recovery_phrase || '').trim();
1495
- const words = phrase.split(/\s+/);
1496
- const allWordsValid = words.length === 12 && words.every(w => english_js_1.wordlist.includes(w));
1497
- if (!phrase || (!(0, bip39_1.validateMnemonic)(phrase, english_js_1.wordlist) && !allWordsValid)) {
1498
- return {
1499
- content: [{ type: 'text', text: JSON.stringify({
1500
- success: false,
1501
- error: 'Invalid recovery phrase. Must be 12 words from the BIP-39 English wordlist.',
1502
- }) }],
1503
- };
1504
- }
1505
- if (!(0, bip39_1.validateMnemonic)(phrase, english_js_1.wordlist)) {
1506
- console.error('Warning: recovery phrase has valid words but invalid BIP-39 checksum. Accepting anyway.');
1507
- }
1508
- mnemonic = phrase;
1509
- }
1510
- else {
1511
- mnemonic = (0, bip39_1.generateMnemonic)(english_js_1.wordlist, 128);
1512
- }
1513
- // Derive keys
1514
- const { authKeyHex, saltHex } = (0, setup_js_1.deriveAuthKey)(mnemonic);
1515
- const authKeyHash = (0, setup_js_1.computeAuthKeyHash)(authKeyHex);
1516
- // Register with relay
1517
- const serverUrl = SERVER_URL;
1518
- let userId;
1519
- try {
1520
- userId = await (0, setup_js_1.registerWithServer)(serverUrl, authKeyHash, saltHex);
1521
- }
1522
- catch (error) {
1523
- const message = error instanceof Error ? error.message : String(error);
1524
- return {
1525
- content: [{ type: 'text', text: JSON.stringify({
1526
- success: false,
1527
- error: `Registration failed: ${message}. Check your internet connection.`,
1528
- }) }],
1529
- };
1530
- }
1531
- // Save credentials (including mnemonic)
1532
- const credDir = path.dirname(setup_js_1.CREDENTIALS_PATH);
1533
- fs.mkdirSync(credDir, { recursive: true });
1534
- const credentials = {
1535
- userId,
1536
- salt: saltHex,
1537
- serverUrl,
1538
- mnemonic,
1539
- };
1540
- fs.writeFileSync(setup_js_1.CREDENTIALS_PATH, JSON.stringify(credentials, null, 2), {
1541
- encoding: 'utf-8',
1542
- mode: 0o600,
1543
- });
1544
- // Pre-download embedding model
1545
- console.error('Downloading embedding model (one-time, ~600MB)...');
1546
- try {
1547
- await (0, embedding_js_1.generateEmbedding)('warmup');
1548
- console.error('Embedding model ready.');
1549
- }
1550
- catch (err) {
1551
- console.error(`Warning: Could not pre-download embedding model: ${err instanceof Error ? err.message : String(err)}`);
1552
- }
1553
- // Hot-reload server state
1554
- try {
1555
- subgraphState = await initSubgraphState(mnemonic);
1556
- currentMode = 'subgraph';
1557
- console.error(`TotalReclaw configured (managed service, owner: ${subgraphState.smartAccountAddress})`);
1558
- }
1559
- catch (error) {
1560
- const message = error instanceof Error ? error.message : String(error);
1561
- return {
1562
- content: [{ type: 'text', text: JSON.stringify({
1563
- success: true,
1564
- warning: `Setup saved but initialization failed: ${message}. Restart the MCP server.`,
1565
- recovery_phrase: action === 'generate' ? mnemonic : undefined,
1566
- user_id: userId,
1567
- }) }],
1568
- };
1569
- }
1570
- const result = {
1571
- success: true,
1572
- user_id: userId,
1573
- mode: 'managed_service',
1574
- smart_account: subgraphState.smartAccountAddress,
1575
- tier: 'free',
1576
- tier_info: 'Free tier: unlimited memories and reads (test network — memories may be reset). Upgrade to Pro for permanent on-chain storage. Pricing: https://totalreclaw.xyz/pricing — upgrade anytime via totalreclaw_upgrade.',
1577
- };
1578
- if (action === 'generate') {
1579
- result.recovery_phrase = mnemonic;
1580
- result.recovery_phrase_warning =
1581
- 'CRITICAL: Write down this recovery phrase and store it securely. ' +
1582
- 'It is your ONLY identity in TotalReclaw. If you lose it, ALL your memories are lost forever. ' +
1583
- 'There is NO password reset, NO recovery, NO support that can help.';
1584
- }
1585
- else {
1586
- result.message = 'Identity restored. Your existing memories are now accessible.';
1587
- }
1588
- return {
1589
- content: [{ type: 'text', text: JSON.stringify(result) }],
1590
- };
1591
- }
1503
+ // ── Setup tool — REMOVED in 3.2.1 (security: phrase-safety) ─────────────────
1504
+ // The `totalreclaw_setup` MCP tool was removed because its response payload
1505
+ // returned the BIP-39 mnemonic via the `recovery_phrase` field, which crossed
1506
+ // the LLM's context window every time an agent invoked the tool. That violated
1507
+ // the phrase-safety invariant ("the recovery phrase MUST NEVER cross the LLM
1508
+ // context"). MCP onboarding now follows the URL-driven flow documented at
1509
+ // `docs/guides/claude-code-setup.md` — agents direct users to source their
1510
+ // phrase from the OpenClaw / Hermes browser pair flow (or an offline BIP-39
1511
+ // generator) and paste it into the MCP host config themselves. No tool path
1512
+ // exists for the agent to ever see the phrase.
1592
1513
  // ── Layer 1: Server with instructions ────────────────────────────────────────
1593
1514
  const server = new index_js_1.Server({ name: 'totalreclaw', version: '1.0.0' }, {
1594
1515
  capabilities: {
@@ -1621,7 +1542,6 @@ function getClientIdentifier() {
1621
1542
  // ── Layer 2 + 3: Tool handlers ───────────────────────────────────────────────
1622
1543
  server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1623
1544
  tools: [
1624
- setupToolDefinition,
1625
1545
  index_js_2.rememberToolDefinition,
1626
1546
  index_js_2.recallToolDefinition,
1627
1547
  index_js_2.forgetToolDefinition,
@@ -1640,27 +1560,58 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1640
1560
  pin_js_1.unpinToolDefinition,
1641
1561
  retype_js_1.retypeToolDefinition,
1642
1562
  set_scope_js_1.setScopeToolDefinition,
1563
+ index_js_2.pairToolDefinition,
1643
1564
  ],
1644
1565
  }));
1645
1566
  server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
1646
1567
  const { name, arguments: args } = request.params;
1647
- // Handle setup tool (available in all modes)
1568
+ // `totalreclaw_setup` was removed in 3.2.1 (security: phrase-safety).
1569
+ // Onboarding now follows the URL-driven flow at
1570
+ // `docs/guides/claude-code-setup.md`. If a stale agent / host catalog
1571
+ // still calls the old tool name, return a structured error pointing at
1572
+ // the canonical install guide — without surfacing any phrase in payload.
1648
1573
  if (name === 'totalreclaw_setup') {
1649
- return await handleSetup(args);
1574
+ return {
1575
+ content: [{
1576
+ type: 'text',
1577
+ text: JSON.stringify({
1578
+ error: 'tool_removed',
1579
+ message: 'The totalreclaw_setup tool was removed in @totalreclaw/mcp-server@3.2.1 ' +
1580
+ 'for phrase-safety. Follow the URL-driven install flow at ' +
1581
+ 'https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md. ' +
1582
+ 'The user sources their recovery phrase out-of-band (OpenClaw or Hermes ' +
1583
+ 'browser pair flow, or an offline BIP-39 generator) and pastes it directly ' +
1584
+ 'into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config — never into chat.',
1585
+ }),
1586
+ }],
1587
+ isError: true,
1588
+ };
1650
1589
  }
1651
1590
  // Handle support tool (available in all modes, including unconfigured)
1652
1591
  if (name === 'totalreclaw_support') {
1653
1592
  const walletAddress = subgraphState?.smartAccountAddress ?? null;
1654
1593
  return (0, index_js_2.handleSupport)(walletAddress);
1655
1594
  }
1656
- // In unconfigured mode, all other tools return setup guidance
1595
+ // Handle pair tool (available in all modes — primary unconfigured-mode entry
1596
+ // point so a user with no credentials can run an MCP-only install end-to-end:
1597
+ // host adds MCP server → agent calls totalreclaw_pair → tool returns URL+PIN
1598
+ // → user pairs in browser → server writes ~/.totalreclaw/credentials.json
1599
+ // → user restarts host → server boots in subgraph mode).
1600
+ if (name === 'totalreclaw_pair') {
1601
+ return await (0, index_js_2.handlePair)(args);
1602
+ }
1603
+ // In unconfigured mode, all other tools return setup guidance pointing at
1604
+ // the URL-driven install flow (NOT the deleted totalreclaw_setup tool).
1657
1605
  if (currentMode === 'unconfigured') {
1658
1606
  return {
1659
1607
  content: [{
1660
1608
  type: 'text',
1661
1609
  text: JSON.stringify({
1662
1610
  error: 'not_configured',
1663
- message: 'TotalReclaw is not configured yet. Ask the user if they have an existing recovery phrase or want to generate a new one, then use the totalreclaw_setup tool.',
1611
+ message: 'TotalReclaw is not configured yet. Follow the URL-driven install flow ' +
1612
+ 'at https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md — ' +
1613
+ 'the user pastes their recovery phrase directly into the MCP host config (TOTALRECLAW_RECOVERY_PHRASE), ' +
1614
+ 'never into chat.',
1664
1615
  }),
1665
1616
  }],
1666
1617
  isError: true,
@@ -2058,7 +2009,7 @@ async function main() {
2058
2009
  console.error('TotalReclaw MCP server started (self-hosted mode)');
2059
2010
  }
2060
2011
  else {
2061
- console.error('TotalReclaw MCP server started (unconfigured — use totalreclaw_setup tool)');
2012
+ console.error('TotalReclaw MCP server started (unconfigured — set TOTALRECLAW_RECOVERY_PHRASE in the MCP host config; see docs/guides/claude-code-setup.md)');
2062
2013
  }
2063
2014
  const transport = new stdio_js_1.StdioServerTransport();
2064
2015
  await server.connect(transport);