@cencori/mcp 0.4.0 → 0.5.0

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.
package/dist/index.mjs CHANGED
@@ -199,6 +199,16 @@ var DocsClient = class {
199
199
  }
200
200
  return response.json();
201
201
  }
202
+ /** Fetch the raw `llm.txt` integration contract (public, no auth). */
203
+ async getIntegrationGuide() {
204
+ const url = new URL("/llm.txt", this.baseUrl);
205
+ const response = await fetch(url, { signal: fetchSignal() });
206
+ if (!response.ok) {
207
+ const message = await readHttpErrorMessage(response);
208
+ throw new Error(`Integration guide fetch failed (${response.status}): ${message}`);
209
+ }
210
+ return response.text();
211
+ }
202
212
  };
203
213
 
204
214
  // src/tools/docs.ts
@@ -287,6 +297,28 @@ function registerDocsTools(server, docs, docsBaseUrl) {
287
297
  return jsonResult(navigation);
288
298
  }
289
299
  );
300
+ server.registerTool(
301
+ "get_integration_guide",
302
+ {
303
+ title: "Get the Cencori integration guide (llm.txt)",
304
+ description: 'Fetch the full Cencori "Integration Contract for Code Agents" (llm.txt) \u2014 the authoritative, always-current guide for setting up Cencori in a codebase: package names, import paths, env vars, base URLs, SDK usage, request/response shapes, and step-by-step setup. Call this FIRST when asked to add, integrate, or set up Cencori in a project.',
305
+ inputSchema: {},
306
+ annotations: READ_ONLY_ANNOTATIONS
307
+ },
308
+ async () => {
309
+ const guide = await docs.getIntegrationGuide();
310
+ return {
311
+ content: [
312
+ {
313
+ type: "text",
314
+ text: `Source: ${docsBaseUrl}/llm.txt
315
+
316
+ ${guide}`
317
+ }
318
+ ]
319
+ };
320
+ }
321
+ );
290
322
  }
291
323
 
292
324
  // src/tools/gateway.ts
@@ -449,39 +481,50 @@ function registerAgentsTools(server, client, caps) {
449
481
  import { z as z4 } from "zod";
450
482
  var scopeShape = {
451
483
  namespace: z4.string().optional().describe("Memory namespace to scope to."),
452
- scope: z4.string().optional().describe("Memory scope (e.g. project, user, session)."),
453
- user_id: z4.string().optional().describe("Scope to a specific end-user id."),
454
- session_id: z4.string().optional().describe("Scope to a specific session id.")
484
+ scope: z4.enum(["user", "session"]).optional().describe('Memory scope. Defaults to "user".'),
485
+ user_id: z4.string().optional().describe("End-user id. REQUIRED for user scope (the default)."),
486
+ session_id: z4.string().optional().describe("Session id. REQUIRED for session scope.")
455
487
  };
488
+ function missingScopeKey({ scope, user_id, session_id }) {
489
+ if ((scope ?? "user") === "session") {
490
+ return session_id || user_id ? null : "session_id (or user_id) is required for session scope.";
491
+ }
492
+ return user_id ? null : 'user_id is required for user scope (the default). Pass user_id, or use scope="session" with session_id.';
493
+ }
494
+ var scopeErr = (msg) => jsonResult({ error: "missing_scope", message: msg });
456
495
  function registerMemoryTools(server, client, caps) {
457
496
  server.registerTool(
458
497
  "list_memories",
459
498
  {
460
499
  title: "List memories",
461
- description: "List stored memories for the project, optionally scoped by namespace/user/session.",
500
+ description: "List stored memories for a user or session. Requires user_id (or session_id for session scope).",
462
501
  inputSchema: {
463
502
  ...scopeShape,
464
- limit: z4.number().int().positive().max(200).optional(),
503
+ limit: z4.number().int().positive().max(100).optional(),
465
504
  cursor: z4.string().optional().describe("Pagination cursor from a previous response.")
466
505
  },
467
506
  annotations: READ_ONLY_ANNOTATIONS
468
507
  },
469
- async ({ namespace, scope, user_id, session_id, limit, cursor }) => jsonResult(
470
- await client.get("/v1/memory/list", {
471
- namespace,
472
- scope,
473
- userId: user_id,
474
- sessionId: session_id,
475
- limit: limit?.toString(),
476
- cursor
477
- })
478
- )
508
+ async ({ namespace, scope, user_id, session_id, limit, cursor }) => {
509
+ const err = missingScopeKey({ scope, user_id, session_id });
510
+ if (err) return scopeErr(err);
511
+ return jsonResult(
512
+ await client.get("/v1/memory/list", {
513
+ namespace,
514
+ scope,
515
+ userId: user_id,
516
+ sessionId: session_id,
517
+ limit: limit?.toString(),
518
+ cursor
519
+ })
520
+ );
521
+ }
479
522
  );
480
523
  server.registerTool(
481
524
  "search_memory",
482
525
  {
483
526
  title: "Search memory (semantic)",
484
- description: "Semantically search stored memories by query.",
527
+ description: "Semantically search a user\u2019s or session\u2019s memories. Requires user_id (or session_id for session scope).",
485
528
  inputSchema: {
486
529
  query: z4.string().min(1).describe("Natural-language search query."),
487
530
  ...scopeShape,
@@ -490,17 +533,21 @@ function registerMemoryTools(server, client, caps) {
490
533
  },
491
534
  annotations: READ_ONLY_ANNOTATIONS
492
535
  },
493
- async ({ query, namespace, scope, user_id, session_id, top_k, threshold }) => jsonResult(
494
- await client.post("/v1/memory/search", {
495
- query,
496
- namespace,
497
- scope,
498
- userId: user_id,
499
- sessionId: session_id,
500
- topK: top_k,
501
- threshold
502
- })
503
- )
536
+ async ({ query, namespace, scope, user_id, session_id, top_k, threshold }) => {
537
+ const err = missingScopeKey({ scope, user_id, session_id });
538
+ if (err) return scopeErr(err);
539
+ return jsonResult(
540
+ await client.post("/v1/memory/search", {
541
+ query,
542
+ namespace,
543
+ scope,
544
+ userId: user_id,
545
+ sessionId: session_id,
546
+ topK: top_k,
547
+ threshold
548
+ })
549
+ );
550
+ }
504
551
  );
505
552
  server.registerTool(
506
553
  "get_memory",
@@ -516,24 +563,23 @@ function registerMemoryTools(server, client, caps) {
516
563
  "list_memory_entities",
517
564
  {
518
565
  title: "List memory entities",
519
- description: "List entities resolved from the memory graph.",
566
+ description: "List entities resolved from a user\u2019s or session\u2019s memory graph. Requires user_id (or session_id).",
520
567
  inputSchema: scopeShape,
521
568
  annotations: READ_ONLY_ANNOTATIONS
522
569
  },
523
- async ({ namespace, scope, user_id, session_id }) => jsonResult(
524
- await client.get("/v1/memory/entities", {
525
- namespace,
526
- scope,
527
- userId: user_id,
528
- sessionId: session_id
529
- })
530
- )
570
+ async ({ namespace, scope, user_id, session_id }) => {
571
+ const err = missingScopeKey({ scope, user_id, session_id });
572
+ if (err) return scopeErr(err);
573
+ return jsonResult(
574
+ await client.get("/v1/memory/entities", { namespace, scope, userId: user_id, sessionId: session_id })
575
+ );
576
+ }
531
577
  );
532
578
  server.registerTool(
533
579
  "get_memory_graph",
534
580
  {
535
581
  title: "Get memory entity graph",
536
- description: "Traverse the memory entity graph from an optional starting entity.",
582
+ description: "Traverse a user\u2019s or session\u2019s memory entity graph. Requires user_id (or session_id).",
537
583
  inputSchema: {
538
584
  ...scopeShape,
539
585
  entity: z4.string().optional().describe("Entity to start traversal from."),
@@ -541,40 +587,48 @@ function registerMemoryTools(server, client, caps) {
541
587
  },
542
588
  annotations: READ_ONLY_ANNOTATIONS
543
589
  },
544
- async ({ namespace, scope, user_id, session_id, entity, hops }) => jsonResult(
545
- await client.get("/v1/memory/graph", {
546
- namespace,
547
- scope,
548
- userId: user_id,
549
- sessionId: session_id,
550
- entity,
551
- hops: hops?.toString()
552
- })
553
- )
590
+ async ({ namespace, scope, user_id, session_id, entity, hops }) => {
591
+ const err = missingScopeKey({ scope, user_id, session_id });
592
+ if (err) return scopeErr(err);
593
+ return jsonResult(
594
+ await client.get("/v1/memory/graph", {
595
+ namespace,
596
+ scope,
597
+ userId: user_id,
598
+ sessionId: session_id,
599
+ entity,
600
+ hops: hops?.toString()
601
+ })
602
+ );
603
+ }
554
604
  );
555
605
  server.registerTool(
556
606
  "get_forget_suggestions",
557
607
  {
558
608
  title: "Get forget suggestions",
559
- description: "List memories the system suggests forgetting (stale/superseded).",
609
+ description: "List memories the system suggests forgetting for a user or session. Requires user_id (or session_id).",
560
610
  inputSchema: scopeShape,
561
611
  annotations: READ_ONLY_ANNOTATIONS
562
612
  },
563
- async ({ namespace, scope, user_id, session_id }) => jsonResult(
564
- await client.get("/v1/memory/forget-suggestions", {
565
- namespace,
566
- scope,
567
- userId: user_id,
568
- sessionId: session_id
569
- })
570
- )
613
+ async ({ namespace, scope, user_id, session_id }) => {
614
+ const err = missingScopeKey({ scope, user_id, session_id });
615
+ if (err) return scopeErr(err);
616
+ return jsonResult(
617
+ await client.get("/v1/memory/forget-suggestions", {
618
+ namespace,
619
+ scope,
620
+ userId: user_id,
621
+ sessionId: session_id
622
+ })
623
+ );
624
+ }
571
625
  );
572
626
  if (caps.write) {
573
627
  server.registerTool(
574
628
  "remember_memory",
575
629
  {
576
630
  title: "Remember a conversation turn",
577
- description: "Store a user/assistant exchange as memory for later retrieval.",
631
+ description: "Store a user/assistant exchange as memory. Requires user_id (or session_id for session scope).",
578
632
  inputSchema: {
579
633
  user: z4.string().min(1).describe("The user message."),
580
634
  assistant: z4.string().min(1).describe("The assistant response."),
@@ -582,22 +636,26 @@ function registerMemoryTools(server, client, caps) {
582
636
  },
583
637
  annotations: WRITE_ANNOTATIONS
584
638
  },
585
- async ({ user, assistant, namespace, scope, user_id, session_id }) => jsonResult(
586
- await client.post("/v1/memory/remember", {
587
- user,
588
- assistant,
589
- namespace,
590
- scope,
591
- userId: user_id,
592
- sessionId: session_id
593
- })
594
- )
639
+ async ({ user, assistant, namespace, scope, user_id, session_id }) => {
640
+ const err = missingScopeKey({ scope, user_id, session_id });
641
+ if (err) return scopeErr(err);
642
+ return jsonResult(
643
+ await client.post("/v1/memory/remember", {
644
+ user,
645
+ assistant,
646
+ namespace,
647
+ scope,
648
+ userId: user_id,
649
+ sessionId: session_id
650
+ })
651
+ );
652
+ }
595
653
  );
596
654
  server.registerTool(
597
655
  "write_memory",
598
656
  {
599
657
  title: "Write a memory",
600
- description: "Store a single memory (a fact/note) directly.",
658
+ description: "Store a single memory (a fact/note). Requires user_id (or session_id for session scope).",
601
659
  inputSchema: {
602
660
  content: z4.string().min(1).describe("The memory content to store."),
603
661
  importance: z4.number().min(0).max(1).optional().describe("Importance weight 0\u20131."),
@@ -605,16 +663,20 @@ function registerMemoryTools(server, client, caps) {
605
663
  },
606
664
  annotations: WRITE_ANNOTATIONS
607
665
  },
608
- async ({ content, importance, namespace, scope, user_id, session_id }) => jsonResult(
609
- await client.post("/v1/memory/write", {
610
- content,
611
- importance,
612
- namespace,
613
- scope,
614
- userId: user_id,
615
- sessionId: session_id
616
- })
617
- )
666
+ async ({ content, importance, namespace, scope, user_id, session_id }) => {
667
+ const err = missingScopeKey({ scope, user_id, session_id });
668
+ if (err) return scopeErr(err);
669
+ return jsonResult(
670
+ await client.post("/v1/memory/write", {
671
+ content,
672
+ importance,
673
+ namespace,
674
+ scope,
675
+ userId: user_id,
676
+ sessionId: session_id
677
+ })
678
+ );
679
+ }
618
680
  );
619
681
  server.registerTool(
620
682
  "create_namespace",
@@ -1151,7 +1213,7 @@ function registerGuidanceTools(server, baseUrl) {
1151
1213
 
1152
1214
  // src/server.ts
1153
1215
  var SERVER_NAME = "cencori";
1154
- var SERVER_VERSION = "0.4.0";
1216
+ var SERVER_VERSION = "0.5.0";
1155
1217
  function createServer(config) {
1156
1218
  const server = new McpServer(
1157
1219
  {