@brain-protocol/mcp 0.7.1 → 0.7.3

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.
@@ -18,10 +18,36 @@ import { updateKnowledge } from "./update.js";
18
18
  import { syncStatus, resolveConflict, triggerSync } from "./sync.js";
19
19
  import { verify } from "./verify.js";
20
20
  import { listBrains, createBrain } from "./brains.js";
21
- export const toolDefinitions = [
21
+ /**
22
+ * Tools demoted from MCP surface — accessible via REST API only.
23
+ * These are deterministic/admin/telemetry tools that don't need LLM reasoning.
24
+ */
25
+ const demotedToolNames = new Set([
26
+ "get_stats", // GET /health/stats
27
+ "get_agent_stats", // GET /api/agents/stats
28
+ "log_agent_task", // POST /api/agents/tasks
29
+ "get_usage", // GET /api/usage
30
+ "get_usage_dashboard", // GET /api/usage/dashboard
31
+ "get_consciousness_trend", // GET /api/consciousness/trend
32
+ "get_archive_stats", // GET /api/archive/stats
33
+ "get_onboarding_status", // GET /api/onboarding
34
+ "run_onboarding_setup", // POST /api/onboarding
35
+ "get_subscription", // GET /api/subscription
36
+ "list_brains", // GET /api/brains
37
+ "create_brain", // POST /api/brains
38
+ "export", // GET /api/export
39
+ "import", // POST /api/import
40
+ "bulk_archive", // POST /api/archive/bulk
41
+ "sync_status", // GET /api/sync
42
+ "trigger_sync", // POST /api/sync
43
+ ]);
44
+ export const DEFAULT_GROUPS = ["core", "graph"];
45
+ const allToolDefinitions = [
46
+ // ─── CORE GROUP ───
22
47
  {
23
48
  name: "query_knowledge",
24
- description: "Search the knowledge base using full-text search with filters",
49
+ group: "core",
50
+ description: "Search Brain for existing entries by keyword, category, or tags. Use BEFORE any task to find relevant patterns, decisions, and prior work. Read-only, no side effects. All modes.",
25
51
  inputSchema: {
26
52
  type: "object",
27
53
  properties: {
@@ -46,7 +72,8 @@ export const toolDefinitions = [
46
72
  },
47
73
  {
48
74
  name: "archive_knowledge",
49
- description: "Store a new knowledge entry",
75
+ group: "core",
76
+ description: "Store a new knowledge entry (pattern, decision, code snippet, documentation). Use AFTER completing a task to persist reusable knowledge. SIDE EFFECT: creates a new entry. All modes.",
50
77
  inputSchema: {
51
78
  type: "object",
52
79
  properties: {
@@ -58,7 +85,10 @@ export const toolDefinitions = [
58
85
  author: { type: "string", description: "Author name" },
59
86
  category: { type: "string", description: "Category" },
60
87
  tags: { type: "array", items: { type: "string" }, description: "Tags" },
61
- confidence: { type: "number", description: "Confidence 0-1" },
88
+ confidence: {
89
+ type: "number",
90
+ description: "Confidence 0-1 (default 0.85)",
91
+ },
62
92
  brain_id: { type: "string", description: "Target brain UUID" },
63
93
  is_public: {
64
94
  type: "boolean",
@@ -70,7 +100,8 @@ export const toolDefinitions = [
70
100
  },
71
101
  {
72
102
  name: "update_knowledge",
73
- description: "Update an existing knowledge entry (partial update)",
103
+ group: "core",
104
+ description: "Partial-update an existing knowledge entry (content, tags, confidence, etc.). Use to correct or enrich entries. SIDE EFFECT: modifies entry in-place. Requires entry UUID. All modes.",
74
105
  inputSchema: {
75
106
  type: "object",
76
107
  properties: {
@@ -93,7 +124,8 @@ export const toolDefinitions = [
93
124
  },
94
125
  {
95
126
  name: "delete_knowledge",
96
- description: "Delete a knowledge entry by ID",
127
+ group: "core",
128
+ description: "Permanently delete a knowledge entry by UUID. DESTRUCTIVE: cannot be undone. Use only for incorrect or duplicate entries. All modes.",
97
129
  inputSchema: {
98
130
  type: "object",
99
131
  properties: {
@@ -103,152 +135,177 @@ export const toolDefinitions = [
103
135
  },
104
136
  },
105
137
  {
106
- name: "create_edge",
107
- description: "Create a relationship edge between two knowledge entries",
138
+ name: "search_with_context",
139
+ group: "core",
140
+ description: "Search Brain with graph-enriched results. Returns matching entries plus their connected graph neighbors for richer context. Use for deep research where related entries matter. Read-only. Cloud mode only.",
108
141
  inputSchema: {
109
142
  type: "object",
110
143
  properties: {
111
- source_id: { type: "string", description: "Source entry UUID" },
112
- target_id: { type: "string", description: "Target entry UUID" },
113
- edge_type: {
144
+ q: { type: "string", description: "Search query" },
145
+ limit: {
146
+ type: "number",
147
+ description: "Max results (default 10, max 20)",
148
+ },
149
+ graph_depth: {
150
+ type: "number",
151
+ description: "Graph traversal depth for context (default 1, max 2)",
152
+ },
153
+ brain_id: {
114
154
  type: "string",
115
- description: "Edge type: derives_from, conflicts_with, validates, extends, implements, supersedes, tested_by, documented_by, optimizes, related_to",
155
+ description: "Brain UUID to scope search to (optional, defaults to personal brain)",
116
156
  },
117
- confidence: { type: "number", description: "Edge confidence 0-1" },
118
157
  },
119
- required: ["source_id", "target_id", "edge_type"],
158
+ required: ["q"],
120
159
  },
160
+ cloudOnly: true,
121
161
  },
122
162
  {
123
- name: "get_graph",
124
- description: "Traverse the knowledge graph from an entry",
163
+ name: "get_memory_guidance",
164
+ group: "core",
165
+ description: "Get relevant past decisions and high-confidence patterns before acting on a task (Retrieval-Augmented Execution). Use at task start to avoid reinventing solutions. Read-only. All modes.",
125
166
  inputSchema: {
126
167
  type: "object",
127
168
  properties: {
128
- entry_id: { type: "string", description: "Starting entry UUID" },
129
- depth: {
169
+ task_description: {
170
+ type: "string",
171
+ description: "Description of the task the agent is about to perform",
172
+ },
173
+ limit: {
130
174
  type: "number",
131
- description: "Max traversal depth (default 3, max 5)",
175
+ description: "Max results (default 10, max 50)",
132
176
  },
177
+ brain_id: { type: "string", description: "Filter by brain UUID" },
133
178
  },
134
- required: ["entry_id"],
135
- },
136
- },
137
- {
138
- name: "get_stats",
139
- description: "Get knowledge base statistics",
140
- inputSchema: {
141
- type: "object",
142
- properties: {},
179
+ required: ["task_description"],
143
180
  },
144
181
  },
182
+ // ─── GRAPH GROUP ───
145
183
  {
146
- name: "prove",
147
- description: "Anchor a knowledge entry on Starknet for verifiable proof (cloud mode only)",
184
+ name: "create_edge",
185
+ group: "graph",
186
+ description: "Create a typed relationship between two knowledge entries (derives_from, validates, extends, etc.). Use to build the knowledge graph after archiving related entries. SIDE EFFECT: creates edge. All modes.",
148
187
  inputSchema: {
149
188
  type: "object",
150
189
  properties: {
151
- entry_id: { type: "string", description: "Entry UUID to anchor" },
190
+ source_id: { type: "string", description: "Source entry UUID" },
191
+ target_id: { type: "string", description: "Target entry UUID" },
192
+ edge_type: {
193
+ type: "string",
194
+ description: "Edge type: derives_from, conflicts_with, validates, extends, implements, supersedes, tested_by, documented_by, optimizes, related_to",
195
+ },
196
+ confidence: { type: "number", description: "Edge confidence 0-1" },
152
197
  },
153
- required: ["entry_id"],
198
+ required: ["source_id", "target_id", "edge_type"],
154
199
  },
155
200
  },
156
201
  {
157
- name: "verify",
158
- description: "Verify a knowledge entry's on-chain proof (cloud mode only)",
202
+ name: "get_graph",
203
+ group: "graph",
204
+ description: "Traverse the knowledge graph from an entry via recursive CTE. Use to explore relationships and dependency chains. Read-only. All modes.",
159
205
  inputSchema: {
160
206
  type: "object",
161
207
  properties: {
162
- entry_id: { type: "string", description: "Entry UUID to verify" },
208
+ entry_id: { type: "string", description: "Starting entry UUID" },
209
+ depth: {
210
+ type: "number",
211
+ description: "Max traversal depth (default 3, max 5)",
212
+ },
163
213
  },
164
214
  required: ["entry_id"],
165
215
  },
166
216
  },
167
217
  {
168
- name: "export",
169
- description: "Export all knowledge entries and edges as JSON",
218
+ name: "suggest_connections",
219
+ group: "graph",
220
+ description: "Suggest potential graph edges for an entry based on embedding similarity. Use after archiving to discover related knowledge. Read-only. Cloud mode only.",
170
221
  inputSchema: {
171
222
  type: "object",
172
223
  properties: {
173
- format: { type: "string", description: "Export format (json)" },
224
+ entry_id: {
225
+ type: "string",
226
+ description: "Entry UUID to find connections for",
227
+ },
228
+ limit: {
229
+ type: "number",
230
+ description: "Max suggestions (default 5, max 20)",
231
+ },
232
+ brain_id: {
233
+ type: "string",
234
+ description: "Brain UUID to scope search to (optional, defaults to personal brain)",
235
+ },
174
236
  },
237
+ required: ["entry_id"],
175
238
  },
239
+ cloudOnly: true,
176
240
  },
177
241
  {
178
- name: "import",
179
- description: "Import knowledge entries and edges from a JSON export",
242
+ name: "record_decision",
243
+ group: "graph",
244
+ description: "Record a structured decision with context, options considered, rationale, and optional chain to prior decisions. Use for architectural choices, technology selections. SIDE EFFECT: creates entry + optional edge. All modes.",
180
245
  inputSchema: {
181
246
  type: "object",
182
247
  properties: {
183
- entries: {
184
- type: "array",
185
- description: "Array of knowledge entries to import",
186
- items: { type: "object" },
248
+ decision: {
249
+ type: "string",
250
+ description: "The decision made (concise summary)",
187
251
  },
188
- edges: {
252
+ context: {
253
+ type: "string",
254
+ description: "Context/situation that led to this decision",
255
+ },
256
+ options: {
189
257
  type: "array",
190
- description: "Array of knowledge edges to import",
191
- items: { type: "object" },
258
+ items: { type: "string" },
259
+ description: "Options that were considered (minimum 2)",
260
+ },
261
+ chosen: { type: "string", description: "The option that was chosen" },
262
+ rationale: {
263
+ type: "string",
264
+ description: "Why this option was chosen over alternatives",
265
+ },
266
+ chain_id: {
267
+ type: "string",
268
+ description: "UUID of a previous decision to chain to (creates derives_from edge)",
269
+ },
270
+ confidence: {
271
+ type: "number",
272
+ description: "Decision confidence 0-1 (default 0.85)",
273
+ },
274
+ tags: { type: "array", items: { type: "string" }, description: "Tags" },
275
+ category: {
276
+ type: "string",
277
+ description: "Category (default: decision)",
192
278
  },
279
+ author: { type: "string", description: "Author (default: agent)" },
280
+ brain_id: { type: "string", description: "Target brain UUID" },
193
281
  },
194
- required: ["entries"],
195
- },
196
- },
197
- {
198
- name: "get_agent_stats",
199
- description: "Get aggregated agent performance statistics and cost breakdown (cloud mode only)",
200
- inputSchema: {
201
- type: "object",
202
- properties: {},
282
+ required: ["decision", "context", "options", "chosen", "rationale"],
203
283
  },
204
284
  },
205
285
  {
206
- name: "log_agent_task",
207
- description: "Log an agent task execution with cost and performance metrics (cloud mode only)",
286
+ name: "get_decision_chain",
287
+ group: "graph",
288
+ description: "Traverse the decision graph from a starting decision. Use to understand the history and rationale behind a chain of decisions. Read-only. All modes.",
208
289
  inputSchema: {
209
290
  type: "object",
210
291
  properties: {
211
- agent_name: {
212
- type: "string",
213
- description: "Agent name (e.g., ARCHITECT, BUILDER)",
214
- },
215
- task_type: {
216
- type: "string",
217
- description: "Task type (e.g., security-audit, implementation)",
218
- },
219
- model: { type: "string", description: "LLM model used" },
220
- provider: {
292
+ entry_id: {
221
293
  type: "string",
222
- description: "LLM provider (e.g., anthropic, groq)",
294
+ description: "Starting decision entry UUID",
223
295
  },
224
- prompt_tokens: { type: "number", description: "Input tokens" },
225
- completion_tokens: { type: "number", description: "Output tokens" },
226
- total_tokens: { type: "number", description: "Total tokens" },
227
- cost_usd: { type: "number", description: "Cost in USD" },
228
- latency_ms: { type: "number", description: "Latency in milliseconds" },
229
- status: {
230
- type: "string",
231
- description: "Task status (success, error, timeout)",
296
+ depth: {
297
+ type: "number",
298
+ description: "Max traversal depth (default 3, max 5)",
232
299
  },
233
- metadata: { type: "object", description: "Optional metadata" },
234
300
  },
235
- required: [
236
- "agent_name",
237
- "task_type",
238
- "model",
239
- "provider",
240
- "prompt_tokens",
241
- "completion_tokens",
242
- "total_tokens",
243
- "cost_usd",
244
- "latency_ms",
245
- "status",
246
- ],
301
+ required: ["entry_id"],
247
302
  },
248
303
  },
304
+ // ─── DEVELOPMENT GROUP ───
249
305
  {
250
306
  name: "suggest_patterns",
251
- description: "Analyze code and suggest applicable design patterns from the knowledge base (cloud mode only)",
307
+ group: "development",
308
+ description: "Submit code for pattern matching against Brain's known patterns. Use when writing new code to discover reusable patterns and avoid reinvention. Read-only. Cloud mode only.",
252
309
  inputSchema: {
253
310
  type: "object",
254
311
  properties: {
@@ -260,10 +317,12 @@ export const toolDefinitions = [
260
317
  },
261
318
  required: ["code"],
262
319
  },
320
+ cloudOnly: true,
263
321
  },
264
322
  {
265
323
  name: "detect_antipatterns",
266
- description: "Analyze code for anti-patterns and potential issues (cloud mode only)",
324
+ group: "development",
325
+ description: "Analyze code for known anti-patterns and potential issues from Brain's pattern database. Use during code review. Read-only. Cloud mode only.",
267
326
  inputSchema: {
268
327
  type: "object",
269
328
  properties: {
@@ -275,10 +334,12 @@ export const toolDefinitions = [
275
334
  },
276
335
  required: ["code"],
277
336
  },
337
+ cloudOnly: true,
278
338
  },
279
339
  {
280
340
  name: "architectural_advice",
281
- description: "Get architectural recommendations for code based on project context (cloud mode only)",
341
+ group: "development",
342
+ description: "Get architectural recommendations for code based on project context and Brain's stored patterns. Use for design decisions. Read-only. Cloud mode only.",
282
343
  inputSchema: {
283
344
  type: "object",
284
345
  properties: {
@@ -290,23 +351,39 @@ export const toolDefinitions = [
290
351
  },
291
352
  required: ["code"],
292
353
  },
354
+ cloudOnly: true,
293
355
  },
356
+ // ─── PROOF GROUP ───
294
357
  {
295
- name: "get_usage",
296
- description: "Get API usage statistics for your account — request counts by endpoint, method, and status code (cloud mode only)",
358
+ name: "prove",
359
+ group: "proof",
360
+ description: "Anchor entry hash to Starknet L3 for tamper-proof audit trail. Use for high-value entries (audits, seals, critical decisions). SIDE EFFECT: on-chain tx (gas cost, irreversible). Cloud mode only.",
297
361
  inputSchema: {
298
362
  type: "object",
299
363
  properties: {
300
- days: {
301
- type: "number",
302
- description: "Number of days to look back (default 30, max 365)",
303
- },
364
+ entry_id: { type: "string", description: "Entry UUID to anchor" },
365
+ },
366
+ required: ["entry_id"],
367
+ },
368
+ cloudOnly: true,
369
+ },
370
+ {
371
+ name: "verify",
372
+ group: "proof",
373
+ description: "Verify an entry's on-chain proof by checking the L3 anchor matches the current content hash. Use to audit integrity. Read-only (chain read). Cloud mode only.",
374
+ inputSchema: {
375
+ type: "object",
376
+ properties: {
377
+ entry_id: { type: "string", description: "Entry UUID to verify" },
304
378
  },
379
+ required: ["entry_id"],
305
380
  },
381
+ cloudOnly: true,
306
382
  },
307
383
  {
308
384
  name: "archive_giza_proof",
309
- description: "Archive a Giza zkML proof result as a verifiable knowledge entry with structured metadata",
385
+ group: "proof",
386
+ description: "Archive a Giza zkML proof result as a verifiable knowledge entry with structured metadata. Use after ML inference to persist proof artifacts. SIDE EFFECT: creates entry. Cloud mode only.",
310
387
  inputSchema: {
311
388
  type: "object",
312
389
  properties: {
@@ -360,10 +437,12 @@ export const toolDefinitions = [
360
437
  },
361
438
  required: ["proof_id", "model_id", "input_hash", "verified", "timestamp"],
362
439
  },
440
+ cloudOnly: true,
363
441
  },
364
442
  {
365
443
  name: "query_giza_proofs",
366
- description: "Query archived Giza zkML proofs with optional filters by model, verification status, and brain",
444
+ group: "proof",
445
+ description: "Query archived Giza zkML proofs with filters (model, verification status, brain). Use to find and audit past inferences. Read-only. Cloud mode only.",
367
446
  inputSchema: {
368
447
  type: "object",
369
448
  properties: {
@@ -386,10 +465,12 @@ export const toolDefinitions = [
386
465
  brain_id: { type: "string", description: "Filter by brain UUID" },
387
466
  },
388
467
  },
468
+ cloudOnly: true,
389
469
  },
390
470
  {
391
471
  name: "link_proof_to_entry",
392
- description: "Create a relationship edge between a Giza proof entry and another knowledge entry",
472
+ group: "proof",
473
+ description: "Create an edge between a Giza proof entry and another knowledge entry (validates, derives_from, related_to). Use to connect proofs to the knowledge they validate. SIDE EFFECT: creates edge. Cloud mode only.",
393
474
  inputSchema: {
394
475
  type: "object",
395
476
  properties: {
@@ -408,283 +489,216 @@ export const toolDefinitions = [
408
489
  },
409
490
  required: ["proof_entry_id", "target_entry_id"],
410
491
  },
492
+ cloudOnly: true,
411
493
  },
494
+ // ─── SYNC GROUP ───
412
495
  {
413
- name: "record_decision",
414
- description: "Record a structured agent decision with context, options, rationale, and optional chain linking to previous decisions",
496
+ name: "resolve_conflict",
497
+ group: "sync",
498
+ description: "Resolve a sync conflict between local and cloud versions. Use when hybrid sync detects divergent entries. SIDE EFFECT: overwrites one version. Hybrid mode only.",
415
499
  inputSchema: {
416
500
  type: "object",
417
501
  properties: {
418
- decision: {
419
- type: "string",
420
- description: "The decision made (concise summary)",
421
- },
422
- context: {
423
- type: "string",
424
- description: "Context/situation that led to this decision",
425
- },
426
- options: {
427
- type: "array",
428
- items: { type: "string" },
429
- description: "Options that were considered (minimum 2)",
430
- },
431
- chosen: { type: "string", description: "The option that was chosen" },
432
- rationale: {
433
- type: "string",
434
- description: "Why this option was chosen over alternatives",
435
- },
436
- chain_id: {
502
+ entry_id: {
437
503
  type: "string",
438
- description: "UUID of a previous decision to chain to (creates derives_from edge)",
439
- },
440
- confidence: {
441
- type: "number",
442
- description: "Decision confidence 0-1 (default 0.85)",
504
+ description: "UUID of the conflicted entry (the forked cloud version)",
443
505
  },
444
- tags: { type: "array", items: { type: "string" }, description: "Tags" },
445
- category: {
506
+ resolution: {
446
507
  type: "string",
447
- description: "Category (default: decision)",
508
+ description: "Resolution strategy: keep_local (discard cloud), keep_cloud (overwrite local), keep_both (keep both as separate entries)",
448
509
  },
449
- author: { type: "string", description: "Author (default: agent)" },
450
- brain_id: { type: "string", description: "Target brain UUID" },
451
510
  },
452
- required: ["decision", "context", "options", "chosen", "rationale"],
511
+ required: ["entry_id", "resolution"],
453
512
  },
454
513
  },
514
+ // ─── DEMOTED (kept in allToolDefinitions for handleTool backward compat) ───
455
515
  {
456
- name: "get_decision_chain",
457
- description: "Traverse the decision graph from a starting decision to see the chain of related decisions",
516
+ name: "get_stats",
517
+ description: "Get knowledge base statistics. DEMOTED: use GET /health/stats.",
518
+ inputSchema: { type: "object", properties: {} },
519
+ },
520
+ {
521
+ name: "get_agent_stats",
522
+ description: "Get agent stats. DEMOTED: use GET /api/agents/stats.",
523
+ inputSchema: { type: "object", properties: {} },
524
+ },
525
+ {
526
+ name: "log_agent_task",
527
+ description: "Log agent task. DEMOTED: use POST /api/agents/tasks.",
458
528
  inputSchema: {
459
529
  type: "object",
460
530
  properties: {
461
- entry_id: {
462
- type: "string",
463
- description: "Starting decision entry UUID",
464
- },
465
- depth: {
466
- type: "number",
467
- description: "Max traversal depth (default 3, max 5)",
468
- },
531
+ agent_name: { type: "string", description: "Agent name" },
532
+ task_type: { type: "string", description: "Task type" },
533
+ model: { type: "string", description: "LLM model used" },
534
+ provider: { type: "string", description: "LLM provider" },
535
+ prompt_tokens: { type: "number", description: "Input tokens" },
536
+ completion_tokens: { type: "number", description: "Output tokens" },
537
+ total_tokens: { type: "number", description: "Total tokens" },
538
+ cost_usd: { type: "number", description: "Cost in USD" },
539
+ latency_ms: { type: "number", description: "Latency in milliseconds" },
540
+ status: { type: "string", description: "Task status" },
541
+ metadata: { type: "object", description: "Optional metadata" },
469
542
  },
470
- required: ["entry_id"],
543
+ required: [
544
+ "agent_name",
545
+ "task_type",
546
+ "model",
547
+ "provider",
548
+ "prompt_tokens",
549
+ "completion_tokens",
550
+ "total_tokens",
551
+ "cost_usd",
552
+ "latency_ms",
553
+ "status",
554
+ ],
471
555
  },
472
556
  },
473
557
  {
474
- name: "get_memory_guidance",
475
- description: "Get relevant past decisions and high-confidence patterns before acting on a task (Retrieval-Augmented Execution)",
558
+ name: "get_usage",
559
+ description: "Get usage stats. DEMOTED: use GET /api/usage.",
476
560
  inputSchema: {
477
561
  type: "object",
478
562
  properties: {
479
- task_description: {
480
- type: "string",
481
- description: "Description of the task the agent is about to perform",
563
+ days: { type: "number", description: "Days to look back (default 30)" },
564
+ },
565
+ },
566
+ },
567
+ {
568
+ name: "export",
569
+ description: "Export all entries. DEMOTED: use GET /api/export.",
570
+ inputSchema: {
571
+ type: "object",
572
+ properties: {
573
+ format: { type: "string", description: "Export format (json)" },
574
+ },
575
+ },
576
+ },
577
+ {
578
+ name: "import",
579
+ description: "Import entries. DEMOTED: use POST /api/import.",
580
+ inputSchema: {
581
+ type: "object",
582
+ properties: {
583
+ entries: {
584
+ type: "array",
585
+ description: "Entries to import",
586
+ items: { type: "object" },
482
587
  },
483
- limit: {
484
- type: "number",
485
- description: "Max results (default 10, max 50)",
588
+ edges: {
589
+ type: "array",
590
+ description: "Edges to import",
591
+ items: { type: "object" },
486
592
  },
487
- brain_id: { type: "string", description: "Filter by brain UUID" },
488
593
  },
489
- required: ["task_description"],
594
+ required: ["entries"],
490
595
  },
491
596
  },
492
597
  {
493
598
  name: "bulk_archive",
494
- description: "Archive multiple knowledge entries in bulk by category, date range, author, IDs, or confidence threshold. Supports dry_run preview (cloud mode only)",
599
+ description: "Bulk archive entries. DEMOTED: use POST /api/archive/bulk.",
495
600
  inputSchema: {
496
601
  type: "object",
497
602
  properties: {
498
603
  category: { type: "string", description: "Filter by category" },
499
- date_before: {
500
- type: "string",
501
- description: "ISO date: archive entries created before this date",
502
- },
503
- date_after: {
504
- type: "string",
505
- description: "ISO date: archive entries created after this date",
506
- },
604
+ date_before: { type: "string", description: "ISO date" },
605
+ date_after: { type: "string", description: "ISO date" },
507
606
  author: { type: "string", description: "Filter by author" },
508
607
  ids: {
509
608
  type: "array",
510
609
  items: { type: "string" },
511
- description: "Specific entry UUIDs (max 1000)",
610
+ description: "Entry UUIDs",
512
611
  },
513
612
  confidence_max: {
514
613
  type: "number",
515
- description: "Archive entries with confidence at or below this value (0-1)",
614
+ description: "Max confidence threshold",
516
615
  },
517
616
  dry_run: {
518
617
  type: "boolean",
519
- description: "Preview without archiving (default true)",
618
+ description: "Preview mode (default true)",
520
619
  },
521
620
  },
522
621
  },
523
622
  },
524
623
  {
525
624
  name: "get_archive_stats",
526
- description: "Get archive statistics: count by reason (manual, duplicate, consolidated), by category, and total archived entries (cloud mode only)",
527
- inputSchema: {
528
- type: "object",
529
- properties: {},
530
- },
531
- },
532
- {
533
- name: "search_with_context",
534
- description: "Search knowledge base with graph-enriched context — returns results plus connected entries for richer understanding (Epoch 25)",
535
- inputSchema: {
536
- type: "object",
537
- properties: {
538
- q: { type: "string", description: "Search query" },
539
- limit: {
540
- type: "number",
541
- description: "Max results (default 5, max 20)",
542
- },
543
- graph_depth: {
544
- type: "number",
545
- description: "Graph traversal depth for context (default 1, max 2)",
546
- },
547
- brain_id: {
548
- type: "string",
549
- description: "Brain UUID to scope search to (optional, defaults to personal brain)",
550
- },
551
- },
552
- required: ["q"],
553
- },
625
+ description: "Archive stats. DEMOTED: use GET /api/archive/stats.",
626
+ inputSchema: { type: "object", properties: {} },
554
627
  },
555
628
  {
556
629
  name: "get_consciousness_trend",
557
- description: "Get historical consciousness score trend for the Brain — shows score evolution over time (cloud mode only, Epoch 25)",
630
+ description: "Consciousness trend. DEMOTED: use GET /api/consciousness/trend.",
558
631
  inputSchema: {
559
632
  type: "object",
560
633
  properties: {
561
- period: {
562
- type: "string",
563
- description: "Time period: 1d, 7d, 30d, 90d (default 7d)",
564
- },
634
+ period: { type: "string", description: "Period: 1d, 7d, 30d, 90d" },
565
635
  },
566
636
  },
567
637
  },
568
- {
569
- name: "suggest_connections",
570
- description: "Suggest potential graph connections for a knowledge entry based on content similarity (Epoch 25)",
571
- inputSchema: {
572
- type: "object",
573
- properties: {
574
- entry_id: {
575
- type: "string",
576
- description: "Entry UUID to find connections for",
577
- },
578
- limit: {
579
- type: "number",
580
- description: "Max suggestions (default 5, max 20)",
581
- },
582
- brain_id: {
583
- type: "string",
584
- description: "Brain UUID to scope search to (optional, defaults to personal brain)",
585
- },
586
- },
587
- required: ["entry_id"],
588
- },
589
- },
590
638
  {
591
639
  name: "get_usage_dashboard",
592
- description: "Get full usage dashboard: request stats, storage (entries, edges, MB, embeddings), daily breakdown, and quota status (cloud mode only)",
640
+ description: "Usage dashboard. DEMOTED: use GET /api/usage/dashboard.",
593
641
  inputSchema: {
594
642
  type: "object",
595
643
  properties: {
596
- days: {
597
- type: "number",
598
- description: "Number of days to look back (default 30, max 365)",
599
- },
644
+ days: { type: "number", description: "Days to look back" },
600
645
  },
601
646
  },
602
647
  },
603
648
  {
604
649
  name: "get_onboarding_status",
605
- description: "Check onboarding progress: has personal brain, has API key, has first entry (cloud mode only)",
606
- inputSchema: {
607
- type: "object",
608
- properties: {},
609
- },
650
+ description: "Onboarding status. DEMOTED: use GET /api/onboarding.",
651
+ inputSchema: { type: "object", properties: {} },
610
652
  },
611
653
  {
612
654
  name: "run_onboarding_setup",
613
- description: "Run guided onboarding: creates personal brain, first API key, and welcome entry. Idempotent — skips already-completed steps (cloud mode only)",
614
- inputSchema: {
615
- type: "object",
616
- properties: {},
617
- },
655
+ description: "Run onboarding. DEMOTED: use POST /api/onboarding.",
656
+ inputSchema: { type: "object", properties: {} },
618
657
  },
619
658
  {
620
659
  name: "sync_status",
621
- description: "Get sync status: mode, pending uploads/downloads, last sync time, and active conflicts (hybrid mode only)",
622
- inputSchema: {
623
- type: "object",
624
- properties: {},
625
- },
626
- },
627
- {
628
- name: "resolve_conflict",
629
- description: "Resolve a sync conflict between local and cloud versions of a knowledge entry (hybrid mode only)",
630
- inputSchema: {
631
- type: "object",
632
- properties: {
633
- entry_id: {
634
- type: "string",
635
- description: "UUID of the conflicted entry (the forked cloud version)",
636
- },
637
- resolution: {
638
- type: "string",
639
- description: "Resolution strategy: keep_local (discard cloud), keep_cloud (overwrite local), keep_both (keep both as separate entries)",
640
- },
641
- },
642
- required: ["entry_id", "resolution"],
643
- },
660
+ description: "Sync status. DEMOTED: use GET /api/sync.",
661
+ inputSchema: { type: "object", properties: {} },
644
662
  },
645
663
  {
646
664
  name: "trigger_sync",
647
- description: "Manually trigger a sync cycle between local and cloud (hybrid mode only)",
648
- inputSchema: {
649
- type: "object",
650
- properties: {},
651
- },
665
+ description: "Trigger sync. DEMOTED: use POST /api/sync.",
666
+ inputSchema: { type: "object", properties: {} },
652
667
  },
653
668
  {
654
669
  name: "get_subscription",
655
- description: "Get current billing subscription: tier, status, period end, and cancellation info (cloud mode only)",
656
- inputSchema: {
657
- type: "object",
658
- properties: {},
659
- },
670
+ description: "Subscription info. DEMOTED: use GET /api/subscription.",
671
+ inputSchema: { type: "object", properties: {} },
660
672
  },
661
673
  {
662
674
  name: "list_brains",
663
- description: "List all brains accessible to the current user: personal, project, and public brains (cloud mode only)",
664
- inputSchema: {
665
- type: "object",
666
- properties: {},
667
- },
675
+ description: "List brains. DEMOTED: use GET /api/brains.",
676
+ inputSchema: { type: "object", properties: {} },
668
677
  },
669
678
  {
670
679
  name: "create_brain",
671
- description: "Create a new brain for organizing knowledge. Each brain is a separate namespace (cloud mode only)",
680
+ description: "Create brain. DEMOTED: use POST /api/brains.",
672
681
  inputSchema: {
673
682
  type: "object",
674
683
  properties: {
675
- name: {
676
- type: "string",
677
- description: "Brain name (1-100 characters)",
678
- },
679
- description: {
680
- type: "string",
681
- description: "Brain description (max 500 characters, optional)",
682
- },
684
+ name: { type: "string", description: "Brain name" },
685
+ description: { type: "string", description: "Brain description" },
683
686
  },
684
687
  required: ["name"],
685
688
  },
686
689
  },
687
690
  ];
691
+ /** Tools exposed via MCP ListTools — excludes demoted tools */
692
+ export const toolDefinitions = allToolDefinitions.filter((t) => !demotedToolNames.has(t.name));
693
+ /** Filter tools by active groups. Returns all non-demoted tools if no groups specified. */
694
+ export function getToolsForGroups(groups) {
695
+ if (!groups || groups.length === 0)
696
+ return toolDefinitions;
697
+ const groupSet = new Set(groups);
698
+ return toolDefinitions.filter((t) => t.group && groupSet.has(t.group));
699
+ }
700
+ /** All tools including demoted — handleTool still dispatches all for backward compat */
701
+ export { allToolDefinitions };
688
702
  export async function handleTool(store, name, args) {
689
703
  switch (name) {
690
704
  case "query_knowledge":