sepia-mcp 0.3.0 → 0.4.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 +1 -1
  2. package/dist/index.js +20 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
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
5
  server (`manage_namespace`, `manage_entity`, `manage_relation`, `manage_memory`,
6
- `search`, `traverse_graph`, `consolidate`), but every call is proxied to the
6
+ `search`, `traverse_graph`, `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
@@ -611,6 +611,7 @@ MANDATORY WORKFLOW — do this on ALMOST EVERY turn:
611
611
 
612
612
  BEFORE you answer (every turn except trivial chitchat):
613
613
  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.
614
+ 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.
614
615
  2. Weave hits into your answer ("From your memory: ..."). If nothing, say so — never fabricate.
615
616
 
616
617
  AFTER you answer (every turn where you learned something):
@@ -621,6 +622,7 @@ AFTER you answer (every turn where you learned something):
621
622
  2. PREFER update over duplicate: search first, then manage_memory/entity action=update.
622
623
  3. SCORE importance 0-1: 0.9+ identity/core preference, 0.6-0.8 active project fact/decision, 0.3-0.5 observation/person, ≤0.2 transient (will decay).
623
624
  4. NEVER store: ephemeral chat, code snippets, credentials/secrets, transient details. Sepia is not a vault — refuse secrets.
625
+ 5. NEVER call "prune_memories" to save anything — it is NOT a write tool. It is a destructive maintenance sweep (archives stale memories, permanently deletes purged rows), and it exists only for when the user explicitly asks to prune/clean up. Persisting is manage_memory.
624
626
 
625
627
  Rule of thumb: If the user sent a message with any substantive content, you should have called search before replying and considered a manage_memory/manage_entity write after replying. Two Sepia calls per turn is normal and expected.
626
628
 
@@ -774,7 +776,7 @@ var ConversationInput = v.object({
774
776
  tags: v.optional(tagsSchema, [])
775
777
  });
776
778
  var SearchInput = v.object({
777
- q: v.pipe(v.string(), v.maxLength(200), v.description("Search query (required; empty returns recent items). Multi-word = AND-of-words; exact phrases rank first")),
779
+ q: v.pipe(v.string(), v.maxLength(200), v.description("Search query (required; empty returns recent items). Multi-word = best-effort: rows matching MORE of your words rank first, so a result set is never emptied by one absent word. Verbatim phrases rank highest. Check `partial` in the result (+ each hit's `matched_terms`) before concluding nothing exists.")),
778
780
  namespace: v.optional(v.pipe(v.string(), v.description("Restrict to a namespace"))),
779
781
  type: v.optional(v.pipe(v.string(), v.maxLength(64), v.description("Memory type (fact/observation/preference/instruction) OR entity type (person/project/tool/concept/repo)"))),
780
782
  tags: v.optional(v.pipe(tagsSchema, v.description("Match memories/entities carrying ALL of these tags"))),
@@ -784,7 +786,6 @@ var TraverseInput = v.object({
784
786
  start_id: v.pipe(uuidSchema, v.description("Entity UUID to start the BFS walk from")),
785
787
  depth: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(TRAVERSE_DEPTH_MAX), v.description("Walk depth (default 1, max 3)")), 1)
786
788
  });
787
- var ConsolidateInput = v.object({});
788
789
  var NamespaceToolInput = v.object({
789
790
  action: v.pipe(v.union([
790
791
  v.literal("create"),
@@ -856,7 +857,9 @@ var MemoryToolInput = v.object({
856
857
  });
857
858
  var SearchToolInput = SearchInput;
858
859
  var TraverseToolInput = TraverseInput;
859
- var ConsolidateToolInput = v.object({});
860
+ var PruneMemoriesToolInput = v.object({
861
+ 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."))
862
+ });
860
863
  // ../../node_modules/.bun/drizzle-orm@0.45.2+af38a8ac26d8f59c/node_modules/drizzle-orm/entity.js
861
864
  var entityKind = Symbol.for("drizzle:entityKind");
862
865
  var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
@@ -3549,6 +3552,7 @@ var memories = pgTable("memories", {
3549
3552
  check("memories_importance_check", sql`${table.importance} >= 0 AND ${table.importance} <= 1`),
3550
3553
  check("memories_type_check", sql`${table.type} IN ('fact', 'observation', 'preference', 'instruction')`),
3551
3554
  index("idx_memories_content_trgm").using("gin", table.content.op("gin_trgm_ops")),
3555
+ index("idx_memories_metadata_trgm").using("gin", sql`(COALESCE(${table.metadata}->>'title', '') || ' ' || COALESCE(${table.metadata}->>'conversation_id', '') || ' ' || COALESCE(${table.metadata}->>'source_ai', '')) gin_trgm_ops`),
3552
3556
  index("idx_memories_tags").using("gin", table.tags),
3553
3557
  index("idx_memories_active").on(table.namespaceId.asc().nullsLast().op("uuid_ops"), table.importance.desc().nullsLast().op("float4_ops"), table.updatedAt.desc().nullsLast().op("timestamptz_ops")).where(sql`NOT ${table.archived}`),
3554
3558
  foreignKey({
@@ -8730,8 +8734,8 @@ class SepiaClient {
8730
8734
  qs.set("depth", String(depth));
8731
8735
  return this.request("GET", `/api/graph?${qs.toString()}`);
8732
8736
  }
8733
- consolidate() {
8734
- return this.request("POST", "/api/consolidate");
8737
+ pruneMemories() {
8738
+ return this.request("POST", "/api/prune-memories");
8735
8739
  }
8736
8740
  }
8737
8741
 
@@ -8992,19 +8996,19 @@ function registerSearchTools(server, client) {
8992
8996
  server.tool({
8993
8997
  name: "search",
8994
8998
  title: "Search Memory",
8995
- description: "Unified keyword + metadata search across memories, entity names, and entity summaries.",
8999
+ description: "Unified keyword + metadata search across memories, entity names, and entity summaries. Multi-word queries are best-effort: rows matching more of your words rank first, and results are never emptied by one absent word. `partial: true` in the result means no single row covered the whole query.",
8996
9000
  icons: [SEPIA_ICON],
8997
9001
  schema: SearchToolInput,
8998
9002
  annotations: { readOnlyHint: true }
8999
9003
  }, safe(async (args) => {
9000
- const { count, results } = await client.search({
9004
+ const { count, results, terms, partial } = await client.search({
9001
9005
  q: args.q,
9002
9006
  namespace: args.namespace,
9003
9007
  type: args.type,
9004
9008
  tags: args.tags,
9005
9009
  limit: args.limit
9006
9010
  });
9007
- return { count, hits: results };
9011
+ return { count, terms, partial, hits: results };
9008
9012
  }));
9009
9013
  }
9010
9014
 
@@ -9026,17 +9030,17 @@ function registerTraverseTools(server, client) {
9026
9030
  }));
9027
9031
  }
9028
9032
 
9029
- // src/tools/consolidate.ts
9030
- function registerConsolidateTools(server, client) {
9033
+ // src/tools/prune.ts
9034
+ function registerPruneMemoriesTools(server, client) {
9031
9035
  server.tool({
9032
- name: "consolidate",
9033
- title: "Consolidate Memory",
9034
- description: "Idempotent maintenance sweep — pure SQL, no LLM calls. Scoped to your namespaces only.",
9036
+ name: "prune_memories",
9037
+ title: "Maintenance sweep — NOT for saving memories",
9038
+ description: 'Maintenance sweep — NOT for saving memories. Never call this to store, remember, or persist anything (that is manage_memory), and never call it proactively or to "tidy up". Run it ONLY when the user explicitly asks to prune or clean up their memories. Destructive and not reversible: archives stale memories (importance < 0.3, untouched 90 days), de-duplicates identical content, and permanently deletes rows archived more than 30 days ago.',
9035
9039
  icons: [SEPIA_ICON],
9036
- schema: ConsolidateToolInput,
9040
+ schema: PruneMemoriesToolInput,
9037
9041
  annotations: { destructiveHint: true }
9038
9042
  }, safe(async () => {
9039
- return (await client.consolidate()).result;
9043
+ return (await client.pruneMemories()).result;
9040
9044
  }));
9041
9045
  }
9042
9046
 
@@ -9067,7 +9071,7 @@ function createSepiaServer(opts = {}) {
9067
9071
  registerMemoryTools(server, client);
9068
9072
  registerSearchTools(server, client);
9069
9073
  registerTraverseTools(server, client);
9070
- registerConsolidateTools(server, client);
9074
+ registerPruneMemoriesTools(server, client);
9071
9075
  return { server, client };
9072
9076
  }
9073
9077
  async function startStdio(server) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sepia-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.4.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": {