@gethmy/mcp 2.2.4 → 2.3.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.
package/src/server.ts CHANGED
@@ -58,6 +58,7 @@ import {
58
58
  } from "./context-assembly.js";
59
59
  import { autoExpandGraph } from "./graph-expansion.js";
60
60
  import { runLifecycleMaintenance } from "./lifecycle-maintenance.js";
61
+ import { runMemoryCleanup } from "./memory-cleanup.js";
61
62
  import { onboardNewUser } from "./onboard.js";
62
63
  import type { PromptVariant } from "./prompt-builder.js";
63
64
 
@@ -1637,6 +1638,51 @@ const TOOLS = {
1637
1638
  required: [],
1638
1639
  },
1639
1640
  },
1641
+
1642
+ harmony_cleanup_memories: {
1643
+ description:
1644
+ "Run a unified memory cleanup: prune stale drafts, consolidate similar memories, detect orphans and duplicates, and backfill embeddings. Returns a health report. Dry-run by default — run with dryRun=false to execute.",
1645
+ inputSchema: {
1646
+ type: "object",
1647
+ properties: {
1648
+ workspaceId: {
1649
+ type: "string",
1650
+ description: "Workspace ID (optional if context set)",
1651
+ },
1652
+ projectId: {
1653
+ type: "string",
1654
+ description: "Project ID (optional)",
1655
+ },
1656
+ dryRun: {
1657
+ type: "boolean",
1658
+ description:
1659
+ "Preview cleanup without executing changes (default: true)",
1660
+ },
1661
+ steps: {
1662
+ type: "array",
1663
+ items: {
1664
+ type: "string",
1665
+ enum: ["prune", "consolidate", "orphans", "duplicates", "backfill"],
1666
+ },
1667
+ description:
1668
+ "Which cleanup steps to run (default: all). Options: prune, consolidate, orphans, duplicates, backfill.",
1669
+ },
1670
+ maxAgeDays: {
1671
+ type: "number",
1672
+ description: "Max age in days for stale draft pruning (default: 30)",
1673
+ },
1674
+ minClusterSize: {
1675
+ type: "number",
1676
+ description: "Min cluster size for consolidation (default: 3)",
1677
+ },
1678
+ orphanAgeDays: {
1679
+ type: "number",
1680
+ description: "Min age in days for orphan detection (default: 14)",
1681
+ },
1682
+ },
1683
+ required: [],
1684
+ },
1685
+ },
1640
1686
  };
1641
1687
 
1642
1688
  // Resource URIs
@@ -3967,6 +4013,49 @@ async function handleToolCall(
3967
4013
  };
3968
4014
  }
3969
4015
 
4016
+ case "harmony_cleanup_memories": {
4017
+ const workspaceId =
4018
+ (args.workspaceId as string) || deps.getActiveWorkspaceId();
4019
+ if (!workspaceId) {
4020
+ throw new Error(
4021
+ "No workspace specified. Use harmony_set_workspace_context or provide workspaceId.",
4022
+ );
4023
+ }
4024
+ const projectId =
4025
+ (args.projectId as string) || deps.getActiveProjectId() || undefined;
4026
+
4027
+ const validSteps = [
4028
+ "prune",
4029
+ "consolidate",
4030
+ "orphans",
4031
+ "duplicates",
4032
+ "backfill",
4033
+ ];
4034
+ const rawSteps = args.steps as string[] | undefined;
4035
+ const steps = rawSteps?.filter((s) => validSteps.includes(s));
4036
+ if (rawSteps && steps && steps.length < rawSteps.length) {
4037
+ const invalid = rawSteps.filter((s) => !validSteps.includes(s));
4038
+ // Will appear in report.errors via the healthReport
4039
+ console.warn(`Unknown cleanup steps ignored: ${invalid.join(", ")}`);
4040
+ }
4041
+
4042
+ const report = await runMemoryCleanup(client, workspaceId, projectId, {
4043
+ dryRun: args.dryRun as boolean | undefined,
4044
+ steps,
4045
+ maxAgeDays: args.maxAgeDays as number | undefined,
4046
+ minClusterSize: args.minClusterSize as number | undefined,
4047
+ orphanAgeDays: args.orphanAgeDays as number | undefined,
4048
+ });
4049
+
4050
+ return {
4051
+ success: report.success,
4052
+ dryRun: report.dryRun,
4053
+ summary: report.summary,
4054
+ errors: report.errors,
4055
+ healthReport: report.healthReport,
4056
+ };
4057
+ }
4058
+
3970
4059
  default:
3971
4060
  throw new Error(`Unknown tool: ${name}`);
3972
4061
  }