@nhatnguyen9317/memory-mcp-server 1.3.3 → 1.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.
@@ -1,16 +1,4 @@
1
1
  import { z } from "zod";
2
- const REPORT_DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
3
- function isValidReportDate(value) {
4
- if (REPORT_DATE_ONLY_RE.test(value))
5
- return true;
6
- return !Number.isNaN(Date.parse(value));
7
- }
8
- const ReportDateInputSchema = z
9
- .string()
10
- .max(50)
11
- .refine(isValidReportDate, {
12
- message: "Expected YYYY-MM-DD or a valid date-time string.",
13
- });
14
2
  export const MemoryTypeEnum = z.enum([
15
3
  "fact",
16
4
  "preference",
@@ -18,93 +6,33 @@ export const MemoryTypeEnum = z.enum([
18
6
  "decision",
19
7
  "reasoning_summary",
20
8
  ]);
21
- export const MemorySaveInputSchema = z
22
- .object({
23
- content: z
24
- .string()
25
- .min(1, "content is required")
26
- .max(8000, "content must not exceed 8000 characters")
27
- .describe("The memory text to store, written as a self-contained statement (e.g. 'User prefers TypeScript over Python for new services')."),
28
- type: MemoryTypeEnum.default("fact").describe("Category of memory: 'fact' (durable info), 'preference' (user/agent preference), 'episodic' (something that happened), 'decision' (a choice that was made and why), 'reasoning_summary' (distilled conclusion from a reasoning session)."),
29
- tags: z
30
- .array(z.string().min(1).max(50))
31
- .max(20)
32
- .default([])
33
- .describe("Short lowercase topic labels for filtering/search, e.g. ['sqlite','backend'] — topics, not workspace or project names."),
34
- importance: z
35
- .number()
36
- .int()
37
- .min(1)
38
- .max(5)
39
- .default(3)
40
- .describe("Priority from 1 (trivial) to 5 (critical). Use to rank recall when many memories match."),
41
- agent_id: z
42
- .string()
43
- .max(100)
44
- .optional()
45
- .describe("Optional identifier for the agent/persona this memory belongs to, for multi-agent setups."),
46
- workspace: z
47
- .string()
48
- .max(500)
49
- .optional()
50
- .describe("Absolute path of the project directory this memory belongs to. Pass your current working directory so recall can prefer this project's memories. If omitted the server uses its own working directory; '/' and the home directory count as unknown."),
51
- metadata: z
52
- .record(z.unknown())
53
- .optional()
54
- .describe("Optional free-form JSON object for extra structured context (e.g. {\"source_url\": \"...\"})."),
55
- })
56
- .strict();
57
9
  export const MemorySearchInputSchema = z
58
10
  .object({
59
11
  query: z
60
12
  .string()
61
13
  .min(1, "query must be at least 1 character")
62
14
  .max(300)
63
- .describe("Free-text search query, matched against content and tags."),
64
- type: MemoryTypeEnum.optional().describe("Restrict results to a single memory type."),
15
+ .describe("Words to look for in content and tags."),
16
+ type: MemoryTypeEnum.optional().describe("Only this memory type."),
65
17
  agent_id: z.string().max(100).optional().describe("Filter by agent_id."),
66
18
  tags: z
67
19
  .array(z.string())
68
20
  .max(20)
69
21
  .optional()
70
- .describe("Only return memories that contain ALL of these tags."),
22
+ .describe("Must contain all of these tags."),
71
23
  limit: z
72
24
  .number()
73
25
  .int()
74
26
  .min(1)
75
27
  .max(200)
76
28
  .default(20)
77
- .describe("Maximum results to return (default 20, max 200)."),
29
+ .describe("Max results."),
78
30
  offset: z
79
31
  .number()
80
32
  .int()
81
33
  .min(0)
82
34
  .default(0)
83
- .describe("Number of results to skip, for pagination."),
84
- })
85
- .strict();
86
- export const MemoryListInputSchema = z
87
- .object({
88
- type: MemoryTypeEnum.optional().describe("Filter by memory type."),
89
- agent_id: z.string().max(100).optional().describe("Filter by agent_id."),
90
- tags: z
91
- .array(z.string())
92
- .max(20)
93
- .optional()
94
- .describe("Only return memories that contain ALL of these tags."),
95
- min_importance: z
96
- .number()
97
- .int()
98
- .min(1)
99
- .max(5)
100
- .optional()
101
- .describe("Only return memories with importance >= this value."),
102
- sort_by: z
103
- .enum(["created_at", "updated_at", "importance"])
104
- .default("updated_at")
105
- .describe("Field to sort by (default: updated_at, newest first)."),
106
- limit: z.number().int().min(1).max(200).default(20),
107
- offset: z.number().int().min(0).default(0),
35
+ .describe("Results to skip."),
108
36
  })
109
37
  .strict();
110
38
  export const MemoryGetInputSchema = z
@@ -117,43 +45,38 @@ export const MemoryGetInputSchema = z
117
45
  // in the tool handler instead.
118
46
  export const MemoryUpdateInputSchema = z
119
47
  .object({
120
- id: z.string().min(1).describe("The memory id to update."),
48
+ id: z.string().min(1).describe("The memory id."),
121
49
  content: z
122
50
  .string()
123
51
  .min(1)
124
52
  .max(8000)
125
53
  .optional()
126
- .describe("New content text, if changing it."),
127
- type: MemoryTypeEnum.optional().describe("New memory type, if changing it."),
54
+ .describe("New content."),
55
+ type: MemoryTypeEnum.optional().describe("New type."),
128
56
  tags: z
129
57
  .array(z.string().min(1).max(50))
130
58
  .max(20)
131
59
  .optional()
132
- .describe("Replaces the full tag list (not merged), if provided."),
60
+ .describe("Replaces all tags."),
133
61
  tags_append: z
134
62
  .array(z.string().min(1).max(50))
135
63
  .max(20)
136
64
  .optional()
137
- .describe("Tags to append when not replacing the full tag list."),
65
+ .describe("Tags to add."),
138
66
  tags_remove: z
139
67
  .array(z.string().min(1).max(50))
140
68
  .max(20)
141
69
  .optional()
142
- .describe("Tags to remove when not replacing the full tag list."),
143
- importance: z.number().int().min(1).max(5).optional().describe("New importance, if changing it."),
70
+ .describe("Tags to remove."),
71
+ importance: z.number().int().min(1).max(5).optional().describe("New importance."),
144
72
  metadata: z
145
73
  .record(z.unknown())
146
74
  .optional()
147
- .describe("Replaces the full metadata object (not merged), if provided."),
75
+ .describe("Replaces the whole metadata object."),
148
76
  metadata_patch: z
149
77
  .record(z.unknown())
150
78
  .optional()
151
- .describe("Shallow metadata patch to merge when not replacing the full metadata object."),
152
- })
153
- .strict();
154
- export const MemoryDeleteInputSchema = z
155
- .object({
156
- id: z.string().min(1).describe("The memory id to delete."),
79
+ .describe("Keys to merge into metadata (shallow)."),
157
80
  })
158
81
  .strict();
159
82
  export const MemoryGetUsageGuideInputSchema = z
@@ -163,42 +86,6 @@ export const MemoryGetUsageGuideInputSchema = z
163
86
  client_version: z.string().max(100).optional(),
164
87
  })
165
88
  .strict();
166
- export const MemoryUsageReportGroupByEnum = z.enum([
167
- "tool_name",
168
- "agent_id",
169
- "client_name",
170
- "mcp_version",
171
- "operation_type",
172
- "status",
173
- "day",
174
- ]);
175
- export const MemoryUsageReportInputSchema = z
176
- .object({
177
- agent_id: z.string().max(100).optional(),
178
- client_name: z.string().max(100).optional(),
179
- mcp_version: z.string().max(50).optional(),
180
- date_from: ReportDateInputSchema.optional(),
181
- date_to: ReportDateInputSchema.optional(),
182
- group_by: MemoryUsageReportGroupByEnum.default("tool_name"),
183
- limit: z.number().int().min(1).max(200).default(50),
184
- })
185
- .strict();
186
- export const MemoryAdoptionReportInputSchema = z
187
- .object({
188
- agent_id: z.string().max(100).optional(),
189
- date_from: ReportDateInputSchema.optional(),
190
- date_to: ReportDateInputSchema.optional(),
191
- limit: z.number().int().min(1).max(200).default(50),
192
- })
193
- .strict();
194
- export const MemoryAgentScorecardInputSchema = z
195
- .object({
196
- agent_id: z.string().max(100).optional(),
197
- date_from: ReportDateInputSchema.optional(),
198
- date_to: ReportDateInputSchema.optional(),
199
- limit: z.number().int().min(1).max(200).default(20),
200
- })
201
- .strict();
202
89
  export const MemoryFeedbackUsefulnessEnum = z.enum([
203
90
  "used",
204
91
  "ignored",
@@ -69,79 +69,6 @@ export const ReasoningAddStepInputSchema = z
69
69
  .describe("Batch mode: log several steps in one call (each entry needs at least one of thought/action/observation). Use INSTEAD of the top-level thought/action/observation fields, e.g. to record the trace of work you just finished without one call per step."),
70
70
  })
71
71
  .strict();
72
- export const ReasoningGetTraceInputSchema = z
73
- .object({
74
- session_id: z.string().min(1).describe("The session id to retrieve the full trace for."),
75
- })
76
- .strict();
77
- export const ReasoningListSessionsInputSchema = z
78
- .object({
79
- agent_id: z.string().max(100).optional().describe("Filter by agent_id."),
80
- status: z
81
- .enum(["in_progress", "completed", "abandoned"])
82
- .optional()
83
- .describe("Filter by session status."),
84
- limit: z.number().int().min(1).max(200).default(20),
85
- offset: z.number().int().min(0).default(0),
86
- })
87
- .strict();
88
- export const ReasoningMarkTypeEnum = z.enum([
89
- "milestone",
90
- "decision",
91
- "conflict",
92
- "important",
93
- "hypothesis",
94
- ]);
95
- export const ReasoningMarkStepInputSchema = z
96
- .object({
97
- step_id: z.string().min(1).describe("The reasoning step id to mark."),
98
- mark_type: ReasoningMarkTypeEnum.describe("Audit marker type for the step."),
99
- note: z
100
- .string()
101
- .max(1000)
102
- .optional()
103
- .describe("Optional note attached to the mark."),
104
- })
105
- .strict();
106
- export const ReasoningSearchStepsInputSchema = z
107
- .object({
108
- query: z
109
- .string()
110
- .min(1)
111
- .max(200)
112
- .describe("Full-text query across thought, action, and observation."),
113
- session_id: z
114
- .string()
115
- .min(1)
116
- .optional()
117
- .describe("Optional session id filter."),
118
- agent_id: z.string().max(100).optional().describe("Optional agent_id filter."),
119
- mark_type: ReasoningMarkTypeEnum.optional().describe("Optional mark filter."),
120
- limit: z.number().int().min(1).max(200).default(20),
121
- offset: z.number().int().min(0).default(0),
122
- })
123
- .strict();
124
- export const ReasoningListMilestonesInputSchema = z
125
- .object({
126
- session_id: z
127
- .string()
128
- .min(1)
129
- .optional()
130
- .describe("Optional session id filter."),
131
- agent_id: z.string().max(100).optional().describe("Optional agent_id filter."),
132
- mark_type: ReasoningMarkTypeEnum.optional().describe("Optional mark filter."),
133
- limit: z.number().int().min(1).max(200).default(20),
134
- offset: z.number().int().min(0).default(0),
135
- })
136
- .strict();
137
- export const ReasoningGetSessionOutlineInputSchema = z
138
- .object({
139
- session_id: z
140
- .string()
141
- .min(1)
142
- .describe("The session id to summarize into an audit outline."),
143
- })
144
- .strict();
145
72
  export const ReasoningCompleteSessionInputSchema = z
146
73
  .object({
147
74
  session_id: z.string().min(1).describe("The session id to complete."),
@@ -191,4 +118,28 @@ export const ReasoningCompleteSessionInputSchema = z
191
118
  .describe("Ids of memories that were actually used/helpful during this session (e.g. ones returned in related_memories by reasoning_start_session). The server records a 'used' usage-feedback event for each, so recall usefulness can be measured."),
192
119
  })
193
120
  .strict();
121
+ // Plain ZodObject so `.shape` works for registerTool; "exactly one of
122
+ // query / session_id" is enforced in the handler.
123
+ export const ReasoningFindInputSchema = z
124
+ .object({
125
+ query: z
126
+ .string()
127
+ .min(1)
128
+ .max(300)
129
+ .optional()
130
+ .describe("Find mode: words to look for in past sessions' titles, conclusions and steps."),
131
+ session_id: z
132
+ .string()
133
+ .min(1)
134
+ .optional()
135
+ .describe("Read mode: a session id (from a find result or a memory's source.session_id)."),
136
+ limit: z
137
+ .number()
138
+ .int()
139
+ .min(1)
140
+ .max(10)
141
+ .default(5)
142
+ .describe("Find mode: max sessions returned."),
143
+ })
144
+ .strict();
194
145
  //# sourceMappingURL=reasoning.js.map
package/dist/server.js CHANGED
@@ -9,7 +9,8 @@ export const SERVER_INSTRUCTIONS = [
9
9
  "Memory MCP: durable memory (memory_*) plus reasoning traces (reasoning_*).",
10
10
  "Call get_usage_guide for the full policy guide before first use.",
11
11
  "Core loop: reasoning_start_session at task start (skip for trivial one-step lookups); log pivotal steps with reasoning_add_step; always finish with reasoning_complete_session (conclusion + used_memory_ids).",
12
- "Every reasoning_add_step/complete_session call requires the session_id returned by reasoning_start_session; reasoning_mark_step takes the step_id returned by reasoning_add_step.",
12
+ "Every reasoning_add_step/complete_session call requires the session_id returned by reasoning_start_session.",
13
+ "To recover earlier work your context does not contain, use reasoning_find.",
13
14
  "Saving a conclusion as memory is opt-in (save_as_memory=true); memory_mode='never' requires not_saved_reason.",
14
15
  "Tool schemas are the source of truth for parameter contracts. Never store secrets, tokens, or credentials.",
15
16
  ].join(" ");