sepia-mcp 0.9.7 → 0.10.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +58 -32
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  A self-contained MCP server for [Sepia](https://sepia.fly.dev) — your personal
4
4
  knowledge-graph memory server. It exposes the **same 7 tools** as the Sepia
5
- server (`manage_namespace`, `manage_entity`, `manage_relation`, `manage_memory`,
6
- `search`, `traverse_graph`, `prune_memories`), but every call is proxied to the
5
+ server (`wake`, `manage_namespace`, `manage_entity`, `manage_relation`,
6
+ `manage_memory`, `search`, `prune_memories`), but every call is proxied to the
7
7
  Sepia REST API. No database, no migrations — just a lightweight MCP wrapper.
8
8
 
9
9
  ## Install
package/dist/index.js CHANGED
@@ -600,8 +600,8 @@ TYPES — use the canonical values, never invent new ones:
600
600
  performance) for discovery — add 1-4 per write when the topic is recurring.
601
601
 
602
602
  RULE 0 — THIS IS NOT OPTIONAL. If you skip memory, you WILL hallucinate preferences,
603
- repeat questions, and contradict past decisions. Using sepia is not a suggestion — it is
604
- your first tool call.
603
+ repeat questions, and contradict past decisions. Using sepia is not a suggestion — "wake"
604
+ then "briefing" are your first two tool calls, in that order, at the top of the session.
605
605
 
606
606
  MANDATORY — ALMOST EVERY MESSAGE: Default to using Sepia on every turn — search BEFORE
607
607
  you answer and persist AFTER you answer. Only skip for trivial chitchat ("hi", "thanks",
@@ -621,10 +621,16 @@ So they are loaded unconditionally, once per session, BEFORE any work starts.
621
621
  - a rule tagged "always" applies in EVERY repo and EVERY session; a rule that is specific to
622
622
  one project must NOT be tagged "always"
623
623
 
624
- MANDATORY WORKFLOW — do this on ALMOST EVERY turn:
624
+ WAKE + BRIEFING — ONCE PER SESSION, AT THE TOP OF THE CHAT, BEFORE ANYTHING ELSE.
625
+ Neither step belongs to the every-turn loop below; do not repeat them on later messages.
625
626
 
626
- FIRST — once per session, before your first substantive action (NOT keyword-driven):
627
- 0. Call manage_memory action=briefing, and treat what it returns as BINDING for the whole
627
+ 0. Call "wake", and retry it until it succeeds. It is the cheapest call in the system and
628
+ the only one whose job is to be retried: the host sleeps when idle, so the first call of
629
+ a chat often lands mid-boot. If it errors or reports ready:false, retry up to 3 times,
630
+ a few seconds apart, before doing anything else. One failed "wake" means you called
631
+ early — NOT that memory is down. Never skip ahead to the briefing on a failed wake, and
632
+ never abandon memory for the rest of the chat because of one failure.
633
+ 1. Call manage_memory action=briefing, and treat what it returns as BINDING for the whole
628
634
  session. It returns the user's CORE standing rules — the ones that must hold before you
629
635
  know anything about the task. The response also reports other_standing: the situational
630
636
  rules it did NOT return. BEFORE anything slow, metered, destructive, or expensive (an
@@ -634,13 +640,15 @@ FIRST — once per session, before your first substantive action (NOT keyword-dr
634
640
  max_chars at its maximum instead — the full standing set is only ~10k tokens (≈1% of your
635
641
  window), it is read once per session, and core-by-default exists to protect small
636
642
  contexts, not to withhold rules from big ones. If you don't know your window size, keep
637
- the default.
643
+ the default. Do NOT call briefing again on later messages in this chat: you already have
644
+ the rules, and re-reading them every turn spends tokens to learn nothing. Re-briefing is
645
+ for a NEW chat only.
638
646
 
639
- THEN — before you answer (every turn except trivial chitchat):
640
- 1. Call "search" with 2-5 keywords from the user's current message + task (e.g. query="auth rate limiting"). If sparse, also call "traverse_graph" from the top entity.
647
+ EVERY TURN AFTER THAT (except trivial chitchat) — search before you answer:
648
+ 2. Call "search" with 2-5 keywords from the user's current message + task (e.g. query="auth rate limiting"). If sparse, also call manage_relation with action="traverse" (start_id = the top entity, depth 2-3) to pull its neighborhood.
641
649
  Search is best-effort: rows matching MORE of your words rank first, so it never returns 0 just because one word is absent. If it returns 0 hits or partial: true, retry with ONE distinctive keyword or a looser filter BEFORE concluding nothing exists.
642
650
  DIAGNOSTIC: identical results for different q values = the filter was NOT applied — wrong tool, or a parameter the schema lacks. Check the schema and the response's filters_applied/ignored_args before theorizing about ranking or tokenization. Ranked keyword search lives ONLY in the search tool.
643
- 2. Weave hits into your answer ("From your memory: ..."). If nothing, say so — never fabricate.
651
+ 3. Weave hits into your answer ("From your memory: ..."). If nothing, say so — never fabricate.
644
652
 
645
653
  AFTER you answer (every turn where you learned something):
646
654
  1. If you learned a durable fact — preference, decision + why, project fact, stack/tool choice, person/role, convention, user correction — persist IMMEDIATELY in the same turn after your response:
@@ -696,15 +704,17 @@ distills — you have the context, you are the best distiller. Rules:
696
704
  digest first, then update with the full metadata + new status — metadata REPLACES).
697
705
  When resuming a paused one, set it back to "active".
698
706
 
699
- TRIGGERS — call the briefing FIRST, once per session, before anything else (step 0 above).
700
- Then always search when user says: "remember", "recall", "what do we know",
707
+ TRIGGERS — at the top of a session, in this order and once each: "wake", then the briefing
708
+ (steps 0-1 above). NEVER a second time on later messages in that chat. Then every turn,
709
+ search when user says: "remember", "recall", "what do we know",
701
710
  "save this", "do you remember", prefers, decided, uses, chose, convention.
702
711
  ALSO ingest when user says: "save this conversation", "hand off", "migrate context",
703
712
  "switch to another AI", "continue this elsewhere".
704
713
 
705
714
  FAILURE MODE: if you answer without searching, you are guessing. If you start work without
706
715
  the briefing, you are guessing about how the user wants you to work — which is how you burn
707
- their bandwidth, their money, or their trust. Briefing first, then search.`;
716
+ their bandwidth, their money, or their trust. Wake first, then briefing, then search: the
717
+ first two once per session, the last one every turn.`;
708
718
  var MEMORY_TYPES = [
709
719
  "fact",
710
720
  "observation",
@@ -831,10 +841,6 @@ var SearchInput = v.looseObject({
831
841
  min_terms: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(50), v.description("Drop hits covering fewer than this many query terms (precision dial; absent = best-effort recall). Too high returns 0 with `terms` present — that is the filter, not a missing memory."))),
832
842
  engine: v.optional(v.pipe(v.picklist([...SEARCH_ENGINES]), v.description('Ranking engine: "coverage" (substring, coverage-first), "bm25" (tokenised, BM25-ranked), or "opensearch" (external cluster; falls back to coverage when unavailable or empty). Omit to use the server default.')))
833
843
  });
834
- var TraverseInput = v.looseObject({
835
- start_id: v.pipe(uuidSchema, v.description("Entity UUID to start the BFS walk from")),
836
- depth: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(TRAVERSE_DEPTH_MAX), v.description("Walk depth (default 1, max 3)")), 1)
837
- });
838
844
  var NamespaceToolInput = v.looseObject({
839
845
  action: v.pipe(v.union([
840
846
  v.literal("create"),
@@ -871,13 +877,20 @@ var EntityToolInput = v.looseObject({
871
877
  batch_limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(500), v.description("batch_update: max rows to touch (default 100, max 500)")), 100)
872
878
  });
873
879
  var RelationToolInput = v.looseObject({
874
- action: v.pipe(v.union([v.literal("create"), v.literal("delete"), v.literal("list")]), v.description("create (relation) | delete (id) | list (by entity_id or namespace)")),
880
+ action: v.pipe(v.union([
881
+ v.literal("create"),
882
+ v.literal("delete"),
883
+ v.literal("list"),
884
+ v.literal("traverse")
885
+ ]), v.description("create (relation) | delete (id) | list (by entity_id or namespace) | traverse (BFS walk from start_id, optional depth 1-3)")),
875
886
  relation: v.optional(v.pipe(RelationInput, v.description("Relation to create: {source_id, target_id, relation_type, weight?} — updates weight if the same relation exists"))),
876
887
  id: v.optional(v.pipe(uuidSchema, v.description("Relation UUID"))),
877
888
  entity_id: v.optional(v.pipe(uuidSchema, v.description("list: filter by entity (in + out)"))),
878
889
  namespace: v.optional(v.pipe(v.string(), v.description("list: filter by namespace"))),
879
890
  limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(1e4), v.description("list: max rows (default 200, max 10000)")), 200),
880
- offset: v.optional(v.pipe(v.number(), v.minValue(0), v.description("list: rows to skip (pagination)")), 0)
891
+ offset: v.optional(v.pipe(v.number(), v.minValue(0), v.description("list: rows to skip (pagination)")), 0),
892
+ start_id: v.optional(v.pipe(uuidSchema, v.description("traverse: Entity UUID to start the BFS walk from"))),
893
+ depth: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(TRAVERSE_DEPTH_MAX), v.description("traverse: Walk depth (default 1, max 3)")), 1)
881
894
  });
882
895
  var MemoryToolInput = v.looseObject({
883
896
  action: v.pipe(v.union([
@@ -914,7 +927,7 @@ var MemoryToolInput = v.looseObject({
914
927
  batch_limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(500), v.description("batch_update: max rows to touch (default 100, max 500)")), 100)
915
928
  });
916
929
  var SearchToolInput = SearchInput;
917
- var TraverseToolInput = TraverseInput;
930
+ var WakeToolInput = v.looseObject({});
918
931
  var PruneMemoriesToolInput = v.looseObject({
919
932
  confirm: v.pipe(v.literal(true), v.description("Must be true. Acknowledges that this archives stale memories and permanently deletes rows archived more than 30 days ago. Set it only after the user explicitly asked for the sweep."))
920
933
  });
@@ -8773,6 +8786,9 @@ class SepiaClient {
8773
8786
  return;
8774
8787
  return await res.json();
8775
8788
  }
8789
+ wake() {
8790
+ return this.request("GET", "/api/wake");
8791
+ }
8776
8792
  listNamespaces() {
8777
8793
  return this.request("GET", "/api/namespaces");
8778
8794
  }
@@ -9087,7 +9103,7 @@ function registerRelationTools(server, client) {
9087
9103
  server.tool({
9088
9104
  name: "manage_relation",
9089
9105
  title: "Manage Relations",
9090
- description: "Create, delete, or list relations — directed, weighted edges between entities.",
9106
+ description: "Create, delete, list, or traverse relations — directed, weighted edges between entities. `traverse` BFS-walks the graph from an entity in both directions.",
9091
9107
  icons: [SEPIA_ICON],
9092
9108
  schema: RelationToolInput
9093
9109
  }, safe(RelationToolInput, async (args) => {
@@ -9118,6 +9134,16 @@ function registerRelationTools(server, client) {
9118
9134
  offset: args.offset
9119
9135
  })).relations
9120
9136
  };
9137
+ case "traverse": {
9138
+ if (!args.start_id)
9139
+ throw new Error("action=traverse requires start_id");
9140
+ const graph = await client.traverseGraph(args.start_id, args.depth);
9141
+ return {
9142
+ action: "traverse",
9143
+ start_id: args.start_id,
9144
+ ...graph
9145
+ };
9146
+ }
9121
9147
  }
9122
9148
  }));
9123
9149
  }
@@ -9242,20 +9268,20 @@ function registerSearchTools(server, client) {
9242
9268
  }));
9243
9269
  }
9244
9270
 
9245
- // src/tools/traverse.ts
9246
- function registerTraverseTools(server, client) {
9271
+ // src/tools/wake.ts
9272
+ function registerWakeTool(server, client) {
9247
9273
  server.tool({
9248
- name: "traverse_graph",
9249
- title: "Traverse Graph",
9250
- description: "BFS-walk the knowledge graph from a start entity (both directions).",
9274
+ name: "wake",
9275
+ title: "Wake Server",
9276
+ description: "Confirm the server and its database are up. Call this FIRST at the top of a chat, before the briefing — the remote host sleeps when idle, so the first call of a conversation often lands during boot and a failure here costs nothing to retry. Returns {awake, ready, server:{version, docs_version, uptime_sec}, db:{ok, latency_ms}, next}. Takes no arguments.",
9251
9277
  icons: [SEPIA_ICON],
9252
- schema: TraverseToolInput,
9278
+ schema: WakeToolInput,
9253
9279
  annotations: { readOnlyHint: true }
9254
- }, safe(TraverseToolInput, async (args) => {
9255
- const graph = await client.traverseGraph(args.start_id, args.depth);
9280
+ }, safe(WakeToolInput, async (_args) => {
9281
+ const result = await client.wake();
9256
9282
  return {
9257
- start_id: args.start_id,
9258
- ...graph
9283
+ ...result,
9284
+ hint: "Succeeded → call manage_memory action=briefing next, once, then search on later turns. Failed → retry this up to 3 times a few seconds apart; do not skip the briefing and do not conclude sepia is down from one failed call."
9259
9285
  };
9260
9286
  }));
9261
9287
  }
@@ -9276,7 +9302,7 @@ function registerPruneMemoriesTools(server, client) {
9276
9302
  // package.json
9277
9303
  var package_default = {
9278
9304
  name: "sepia-mcp",
9279
- version: "0.9.7",
9305
+ version: "0.10.0",
9280
9306
  description: "Self-contained MCP server for Sepia — a personal knowledge-graph memory server. Talks to the Sepia REST API (SEPIA_URL + SEPIA_API_KEY); stdio or HTTP transport.",
9281
9307
  type: "module",
9282
9308
  repository: {
@@ -9339,12 +9365,12 @@ function createSepiaServer(opts = {}) {
9339
9365
  capabilities: { tools: {} },
9340
9366
  instructions: MEMORY_CONTRACT
9341
9367
  });
9368
+ registerWakeTool(server, client);
9342
9369
  registerNamespaceTools(server, client);
9343
9370
  registerEntityTools(server, client);
9344
9371
  registerRelationTools(server, client);
9345
9372
  registerMemoryTools(server, client);
9346
9373
  registerSearchTools(server, client);
9347
- registerTraverseTools(server, client);
9348
9374
  registerPruneMemoriesTools(server, client);
9349
9375
  return { server, client };
9350
9376
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sepia-mcp",
3
- "version": "0.9.7",
3
+ "version": "0.10.0",
4
4
  "description": "Self-contained MCP server for Sepia — a personal knowledge-graph memory server. Talks to the Sepia REST API (SEPIA_URL + SEPIA_API_KEY); stdio or HTTP transport.",
5
5
  "type": "module",
6
6
  "repository": {