dsh-plugin-imem 0.1.0 → 0.2.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,326 +1,328 @@
1
- # iMem Remote MCP Tool Specification
2
-
3
- This is the public Agent contract for production iMem remote MCP contract
4
- `2026-11-02`.
5
-
6
- ## Production Connection
7
-
8
- ```text
9
- MCP URL: https://imem.xin/mcp
10
- Transport: Streamable HTTP
11
- Authentication: Authorization: Bearer <personal-api-key>
12
- OAuth: pending
13
- ```
14
-
15
- Create a Personal API Key at `https://imem.xin/app/api-keys`. The service
16
- derives user and workspace identity from that key. Never pass `workspace_id` in
17
- normal Agent requests.
18
-
19
- ## Canonical Resource Shape
20
-
21
- ```json
22
- {
23
- "id": "MEM-20261101-001",
24
- "revision": 1,
25
- "kind": "schedule",
26
- "title": "Product review",
27
- "content": "Review the launch scope",
28
- "category": "Work",
29
- "owner": "agent",
30
- "members": [],
31
- "tags": [],
32
- "visibility": "private",
33
- "source": {"type": "agent"},
34
- "status": "pending",
35
- "created_at": "2026-11-01T09:00:00",
36
- "updated_at": null,
37
- "deleted_at": null,
38
- "schedule_details": {
39
- "start_time": "2026-11-05T10:00:00+08:00",
40
- "end_time": "2026-11-05T11:00:00+08:00",
41
- "location": "",
42
- "participants": [],
43
- "notes": "",
44
- "recurrence": null,
45
- "timezone": "Asia/Shanghai",
46
- "next_occurrence_at": "2026-11-05T02:00:00Z"
47
- },
48
- "reminder_rules": []
49
- }
50
- ```
51
-
52
- `schedule_details` is `null` and `reminder_rules` is empty for a note Entry.
53
- Every Entry has a top-level integer `revision`. Every nested Reminder Rule also
54
- has its own integer `revision`. Reminder Rules are nested under Schedule Entries.
55
- Occurrences expose `entry_id` and `occurrence_id`, never legacy identity as the
56
- canonical key.
57
-
58
- ## Canonical Production Tools
59
-
60
- | Tool | Scope | Purpose |
61
- |---|---|---|
62
- | `imem_health` | `entries:read` | Verify authenticated service access and contract version |
63
- | `imem_get_time_context` | `entries:read` | Get authoritative server and workspace time |
64
- | `imem_create_entry` | `entries:write` | Create a note or Schedule Entry |
65
- | `imem_list_entries` | `entries:read` | List and filter Entries |
66
- | `imem_get_entry` | `entries:read` | Read one Entry by canonical ID |
67
- | `imem_update_entry` | `entries:write` | Patch one Entry |
68
- | `imem_delete_entry` | `entries:write` | Soft-delete or cancel one Entry |
69
- | `imem_list_entry_occurrences` | `entries:read` | Read Schedule occurrences for a range |
70
- | `imem_create_entry_reminder_rule` | `entries:write` | Add a Reminder Rule to a Schedule Entry |
71
- | `imem_update_entry_reminder_rule` | `entries:write` | Patch a nested Reminder Rule |
72
- | `imem_delete_entry_reminder_rule` | `entries:write` | Delete/cancel a nested Reminder Rule |
73
- | `imem_upload_artifact` | `entries:write` | Upload a private text, Markdown, or HTML Artifact |
74
-
75
- ## Tool Parameters
76
-
77
- ### `imem_health`
78
-
79
- No parameters. Verify `data.status`, `data.mcp_url`, and
80
- `data.contract_version`.
81
-
82
- ### `imem_get_time_context`
83
-
84
- No parameters. Use `data.server_time` and `data.workspace_timezone` before
85
- resolving relative dates or times.
86
-
87
- ### `imem_create_entry`
88
-
89
- ```text
90
- kind: note | schedule
91
- title: string
92
- request_id: string
93
- idempotency_key: string
94
- content?: string
95
- category?: string
96
- owner?: string
97
- members?: string[]
98
- tags?: string[]
99
- visibility?: string
100
- source?: object
101
- status?: string
102
- created_at?: ISO datetime
103
- schedule_details?: object
104
- reminder_rules?: object[]
105
- ```
106
-
107
- For `kind=schedule`, set `schedule_details.start_time` and optionally:
108
-
109
- ```text
110
- end_time?: ISO datetime
111
- location?: string
112
- participants?: string[]
113
- notes?: string
114
- recurrence?: object
115
- timezone?: IANA timezone
116
- ```
117
-
118
- For `kind=note`, omit schedule details and reminder rules. Return
119
- `data.entry`.
120
-
121
- ### `imem_list_entries`
122
-
123
- ```text
124
- kind?: note | schedule
125
- q?: string
126
- status?: string
127
- scheduled_from?: ISO datetime
128
- scheduled_to?: ISO datetime
129
- include_deleted?: boolean
130
- limit?: integer
131
- offset?: integer
132
- ```
133
-
134
- Return `data.entries`, `data.total`, `data.limit`, and `data.offset`.
135
-
136
- ### `imem_get_entry`
137
-
138
- ```text
139
- entry_id: string
140
- ```
141
-
142
- Return `data.entry` or `ENTRY_NOT_FOUND`.
143
-
144
- ### `imem_update_entry`
145
-
146
- Canonical input:
147
-
148
- ```text
149
- entry_id: string
150
- patch: object
151
- request_id: string
152
- expected_revision?: integer
153
- ```
154
-
155
- Do not set `id`, `kind`, or `revision`. Nest Schedule changes under
156
- `patch.schedule_details`. Canonical Skill callers must read `data.entry.revision`
157
- first and pass it as `expected_revision`; the parameter is optional only for
158
- legacy client compatibility. Return `data.entry` with its incremented revision.
159
- A stale value returns `REVISION_CONFLICT` without applying the patch.
160
-
161
- During migration, the tool also accepts this mutually exclusive legacy form:
162
-
163
- ```text
164
- entity_type: memory | schedule | reminder
165
- entity_id: string
166
- patch: object
167
- request_id: string
168
- ```
169
-
170
- New integrations must use `entry_id`.
171
-
172
- ### `imem_delete_entry`
173
-
174
- ```text
175
- entry_id: string
176
- reason: string
177
- request_id: string
178
- ```
179
-
180
- Perform a soft delete/cancel and return `data.entry`.
181
-
182
- ### `imem_list_entry_occurrences`
183
-
184
- ```text
185
- start: ISO datetime
186
- end: ISO datetime
187
- limit?: integer
188
- ```
189
-
190
- Return `data.occurrences`. Each item uses canonical `entry_id` plus an
191
- occurrence-specific `occurrence_id`.
192
-
193
- ### `imem_create_entry_reminder_rule`
194
-
195
- ```text
196
- entry_id: string
197
- request_id: string
198
- idempotency_key: string
199
- remind_at?: ISO datetime
200
- offset_minutes?: integer
201
- channel?: string
202
- is_default?: boolean
203
- status?: string
204
- message?: string
205
- title?: string
206
- notification_endpoint_id?: string
207
- ```
208
-
209
- Use only with a Schedule Entry and provide a valid timing rule. Return the
210
- updated `data.entry`.
211
-
212
- ### `imem_update_entry_reminder_rule`
213
-
214
- ```text
215
- entry_id: string
216
- rule_id: string
217
- patch: object
218
- request_id: string
219
- expected_revision?: integer
220
- ```
221
-
222
- Canonical Skill callers must read the selected nested Reminder Rule's `revision`
223
- and pass it as `expected_revision`; omission remains only for legacy client
224
- compatibility. Return the updated `data.entry`, including the incremented rule
225
- revision. A stale value returns `REVISION_CONFLICT` without applying the patch.
226
-
227
- ### `imem_delete_entry_reminder_rule`
228
-
229
- ```text
230
- entry_id: string
231
- rule_id: string
232
- reason: string
233
- request_id: string
234
- ```
235
-
236
- Return the updated `data.entry`.
237
-
238
- ### `imem_upload_artifact`
239
-
240
- ```text
241
- title: string
242
- content: string
243
- media_type: text/plain | text/markdown | text/html
244
- request_id: string
245
- idempotency_key: string
246
- ```
247
-
248
- The Artifact is private and returns an owner URL. The tool cannot enable a
249
- Public Link.
250
-
251
- ## Return Envelope
252
-
253
- Success:
254
-
255
- ```json
256
- {
257
- "ok": true,
258
- "data": {},
259
- "error": null,
260
- "source": "imem-remote-mcp"
261
- }
262
- ```
263
-
264
- Failure:
265
-
266
- ```json
267
- {
268
- "ok": false,
269
- "data": null,
270
- "error": {"code": "VALIDATION_FAILED", "message": "..."},
271
- "source": "imem-remote-mcp"
272
- }
273
- ```
274
-
275
- Preserve `error.code`. Never present a failed write as successful.
276
-
277
- ## Idempotency And Recovery
278
-
279
- `imem_create_entry`, `imem_create_entry_reminder_rule`, and
280
- `imem_upload_artifact` require both `request_id` and `idempotency_key`. Reuse a
281
- key only for an identical retry. Different arguments with the same key return
282
- `IDEMPOTENCY_CONFLICT`.
283
-
284
- After an uncertain update or delete, read current state before retrying. Ask
285
- the user to choose when a list returns multiple plausible targets.
286
-
287
- ## Optimistic Concurrency
288
-
289
- Before `imem_update_entry`, get the Entry and send its top-level `revision` as
290
- `expected_revision`. Before `imem_update_entry_reminder_rule`, get the owning
291
- Schedule Entry, select the rule, and send that rule's `revision`. The update
292
- returns the resource with an incremented revision.
293
-
294
- If either update returns `REVISION_CONFLICT`, do not retry automatically and do
295
- not omit `expected_revision` to force a write. Re-read current state, explain
296
- that another client changed the resource, and ask the user whether to retry the
297
- intended patch against the latest revision or merge the competing changes.
298
-
299
- ## Migration Aliases
300
-
301
- Production temporarily retains:
302
-
303
- ```text
304
- imem_search
305
- imem_create_memory
306
- imem_create_schedule
307
- imem_create_reminder
308
- imem_cancel_entry
309
- ```
310
-
311
- These aliases preserve older integrations. New Skill workflows must use the
312
- canonical Entry tools. Do not remove aliases before a separately approved
313
- deprecation and telemetry review.
314
-
315
- ## Error Handling
316
-
317
- | Error code | Required behavior |
318
- |---|---|
319
- | `UNAUTHORIZED` | Check the configured API key. |
320
- | `FORBIDDEN` | Report the missing scope. |
321
- | `ENTRY_NOT_FOUND` | List again or ask the user to identify the Entry. |
322
- | `VALIDATION_FAILED` | Correct clear fields or ask for missing information. |
323
- | `INVALID_ENTRY_KIND` | Use `note` or `schedule`. |
324
- | `IDEMPOTENCY_CONFLICT` | Do not retry with that key; confirm intent. |
325
- | `REVISION_CONFLICT` | Re-read current state, explain the concurrent change, and ask whether to retry or merge. Never force overwrite. |
326
- | `MCP_TOOL_ERROR` | Treat the outcome as failed or uncertain. |
1
+ # iMem Remote MCP Tool Specification
2
+
3
+ This is the public Agent contract for production iMem remote MCP contract
4
+ `2026-11-26`.
5
+
6
+ ## Production Connection
7
+
8
+ ```text
9
+ MCP URL: https://imem.xin/mcp
10
+ Transport: Streamable HTTP
11
+ Authentication: OAuth Authorization Code with PKCE or Authorization: Bearer <personal-api-key>
12
+ OAuth: available
13
+ ```
14
+
15
+ OAuth clients discover protected resource metadata at
16
+ `https://imem.xin/.well-known/oauth-protected-resource/mcp`. Personal API Keys
17
+ remain available at `https://imem.xin/app/api-keys`. The service derives user
18
+ and workspace identity from the active credential. Never pass `workspace_id`
19
+ in normal Agent requests.
20
+
21
+ ## Canonical Resource Shape
22
+
23
+ ```json
24
+ {
25
+ "id": "MEM-20261101-001",
26
+ "revision": 1,
27
+ "kind": "schedule",
28
+ "title": "Product review",
29
+ "content": "Review the launch scope",
30
+ "category": "Work",
31
+ "owner": "agent",
32
+ "members": [],
33
+ "tags": [],
34
+ "visibility": "private",
35
+ "source": {"type": "agent"},
36
+ "status": "pending",
37
+ "created_at": "2026-11-01T09:00:00",
38
+ "updated_at": null,
39
+ "deleted_at": null,
40
+ "schedule_details": {
41
+ "start_time": "2026-11-05T10:00:00+08:00",
42
+ "end_time": "2026-11-05T11:00:00+08:00",
43
+ "location": "",
44
+ "participants": [],
45
+ "notes": "",
46
+ "recurrence": null,
47
+ "timezone": "Asia/Shanghai",
48
+ "next_occurrence_at": "2026-11-05T02:00:00Z"
49
+ },
50
+ "reminder_rules": []
51
+ }
52
+ ```
53
+
54
+ `schedule_details` is `null` and `reminder_rules` is empty for a note Entry.
55
+ Every Entry has a top-level integer `revision`. Every nested Reminder Rule also
56
+ has its own integer `revision`. Reminder Rules are nested under Schedule Entries.
57
+ Occurrences expose `entry_id` and `occurrence_id`, never legacy identity as the
58
+ canonical key.
59
+
60
+ ## Canonical Production Tools
61
+
62
+ | Tool | Scope | Purpose |
63
+ |---|---|---|
64
+ | `imem_health` | `entries:read` | Verify authenticated service access and contract version |
65
+ | `imem_get_time_context` | `entries:read` | Get authoritative server and workspace time |
66
+ | `imem_create_entry` | `entries:write` | Create a note or Schedule Entry |
67
+ | `imem_list_entries` | `entries:read` | List and filter Entries |
68
+ | `imem_get_entry` | `entries:read` | Read one Entry by canonical ID |
69
+ | `imem_update_entry` | `entries:write` | Patch one Entry |
70
+ | `imem_delete_entry` | `entries:write` | Soft-delete or cancel one Entry |
71
+ | `imem_list_entry_occurrences` | `entries:read` | Read Schedule occurrences for a range |
72
+ | `imem_create_entry_reminder_rule` | `entries:write` | Add a Reminder Rule to a Schedule Entry |
73
+ | `imem_update_entry_reminder_rule` | `entries:write` | Patch a nested Reminder Rule |
74
+ | `imem_delete_entry_reminder_rule` | `entries:write` | Delete/cancel a nested Reminder Rule |
75
+ | `imem_upload_artifact` | `entries:write` | Upload a private text, Markdown, or HTML Artifact |
76
+
77
+ ## Tool Parameters
78
+
79
+ ### `imem_health`
80
+
81
+ No parameters. Verify `data.status`, `data.mcp_url`, and
82
+ `data.contract_version`.
83
+
84
+ ### `imem_get_time_context`
85
+
86
+ No parameters. Use `data.server_time` and `data.workspace_timezone` before
87
+ resolving relative dates or times.
88
+
89
+ ### `imem_create_entry`
90
+
91
+ ```text
92
+ kind: note | schedule
93
+ title: string
94
+ request_id: string
95
+ idempotency_key: string
96
+ content?: string
97
+ category?: string
98
+ owner?: string
99
+ members?: string[]
100
+ tags?: string[]
101
+ visibility?: string
102
+ source?: object
103
+ status?: string
104
+ created_at?: ISO datetime
105
+ schedule_details?: object
106
+ reminder_rules?: object[]
107
+ ```
108
+
109
+ For `kind=schedule`, set `schedule_details.start_time` and optionally:
110
+
111
+ ```text
112
+ end_time?: ISO datetime
113
+ location?: string
114
+ participants?: string[]
115
+ notes?: string
116
+ recurrence?: object
117
+ timezone?: IANA timezone
118
+ ```
119
+
120
+ For `kind=note`, omit schedule details and reminder rules. Return
121
+ `data.entry`.
122
+
123
+ ### `imem_list_entries`
124
+
125
+ ```text
126
+ kind?: note | schedule
127
+ q?: string
128
+ status?: string
129
+ scheduled_from?: ISO datetime
130
+ scheduled_to?: ISO datetime
131
+ include_deleted?: boolean
132
+ limit?: integer
133
+ offset?: integer
134
+ ```
135
+
136
+ Return `data.entries`, `data.total`, `data.limit`, and `data.offset`.
137
+
138
+ ### `imem_get_entry`
139
+
140
+ ```text
141
+ entry_id: string
142
+ ```
143
+
144
+ Return `data.entry` or `ENTRY_NOT_FOUND`.
145
+
146
+ ### `imem_update_entry`
147
+
148
+ Canonical input:
149
+
150
+ ```text
151
+ entry_id: string
152
+ patch: object
153
+ request_id: string
154
+ expected_revision?: integer
155
+ ```
156
+
157
+ Do not set `id`, `kind`, or `revision`. Nest Schedule changes under
158
+ `patch.schedule_details`. Canonical Skill callers must read `data.entry.revision`
159
+ first and pass it as `expected_revision`; the parameter is optional only for
160
+ legacy client compatibility. Return `data.entry` with its incremented revision.
161
+ A stale value returns `REVISION_CONFLICT` without applying the patch.
162
+
163
+ During migration, the tool also accepts this mutually exclusive legacy form:
164
+
165
+ ```text
166
+ entity_type: memory | schedule | reminder
167
+ entity_id: string
168
+ patch: object
169
+ request_id: string
170
+ ```
171
+
172
+ New integrations must use `entry_id`.
173
+
174
+ ### `imem_delete_entry`
175
+
176
+ ```text
177
+ entry_id: string
178
+ reason: string
179
+ request_id: string
180
+ ```
181
+
182
+ Perform a soft delete/cancel and return `data.entry`.
183
+
184
+ ### `imem_list_entry_occurrences`
185
+
186
+ ```text
187
+ start: ISO datetime
188
+ end: ISO datetime
189
+ limit?: integer
190
+ ```
191
+
192
+ Return `data.occurrences`. Each item uses canonical `entry_id` plus an
193
+ occurrence-specific `occurrence_id`.
194
+
195
+ ### `imem_create_entry_reminder_rule`
196
+
197
+ ```text
198
+ entry_id: string
199
+ request_id: string
200
+ idempotency_key: string
201
+ remind_at?: ISO datetime
202
+ offset_minutes?: integer
203
+ channel?: string
204
+ is_default?: boolean
205
+ status?: string
206
+ message?: string
207
+ title?: string
208
+ notification_endpoint_id?: string
209
+ ```
210
+
211
+ Use only with a Schedule Entry and provide a valid timing rule. Return the
212
+ updated `data.entry`.
213
+
214
+ ### `imem_update_entry_reminder_rule`
215
+
216
+ ```text
217
+ entry_id: string
218
+ rule_id: string
219
+ patch: object
220
+ request_id: string
221
+ expected_revision?: integer
222
+ ```
223
+
224
+ Canonical Skill callers must read the selected nested Reminder Rule's `revision`
225
+ and pass it as `expected_revision`; omission remains only for legacy client
226
+ compatibility. Return the updated `data.entry`, including the incremented rule
227
+ revision. A stale value returns `REVISION_CONFLICT` without applying the patch.
228
+
229
+ ### `imem_delete_entry_reminder_rule`
230
+
231
+ ```text
232
+ entry_id: string
233
+ rule_id: string
234
+ reason: string
235
+ request_id: string
236
+ ```
237
+
238
+ Return the updated `data.entry`.
239
+
240
+ ### `imem_upload_artifact`
241
+
242
+ ```text
243
+ title: string
244
+ content: string
245
+ media_type: text/plain | text/markdown | text/html
246
+ request_id: string
247
+ idempotency_key: string
248
+ ```
249
+
250
+ The Artifact is private and returns an owner URL. The tool cannot enable a
251
+ Public Link.
252
+
253
+ ## Return Envelope
254
+
255
+ Success:
256
+
257
+ ```json
258
+ {
259
+ "ok": true,
260
+ "data": {},
261
+ "error": null,
262
+ "source": "imem-remote-mcp"
263
+ }
264
+ ```
265
+
266
+ Failure:
267
+
268
+ ```json
269
+ {
270
+ "ok": false,
271
+ "data": null,
272
+ "error": {"code": "VALIDATION_FAILED", "message": "..."},
273
+ "source": "imem-remote-mcp"
274
+ }
275
+ ```
276
+
277
+ Preserve `error.code`. Never present a failed write as successful.
278
+
279
+ ## Idempotency And Recovery
280
+
281
+ `imem_create_entry`, `imem_create_entry_reminder_rule`, and
282
+ `imem_upload_artifact` require both `request_id` and `idempotency_key`. Reuse a
283
+ key only for an identical retry. Different arguments with the same key return
284
+ `IDEMPOTENCY_CONFLICT`.
285
+
286
+ After an uncertain update or delete, read current state before retrying. Ask
287
+ the user to choose when a list returns multiple plausible targets.
288
+
289
+ ## Optimistic Concurrency
290
+
291
+ Before `imem_update_entry`, get the Entry and send its top-level `revision` as
292
+ `expected_revision`. Before `imem_update_entry_reminder_rule`, get the owning
293
+ Schedule Entry, select the rule, and send that rule's `revision`. The update
294
+ returns the resource with an incremented revision.
295
+
296
+ If either update returns `REVISION_CONFLICT`, do not retry automatically and do
297
+ not omit `expected_revision` to force a write. Re-read current state, explain
298
+ that another client changed the resource, and ask the user whether to retry the
299
+ intended patch against the latest revision or merge the competing changes.
300
+
301
+ ## Migration Aliases
302
+
303
+ Production temporarily retains:
304
+
305
+ ```text
306
+ imem_search
307
+ imem_create_memory
308
+ imem_create_schedule
309
+ imem_create_reminder
310
+ imem_cancel_entry
311
+ ```
312
+
313
+ These aliases preserve older integrations. New Skill workflows must use the
314
+ canonical Entry tools. Do not remove aliases before a separately approved
315
+ deprecation and telemetry review.
316
+
317
+ ## Error Handling
318
+
319
+ | Error code | Required behavior |
320
+ |---|---|
321
+ | `UNAUTHORIZED` | Reconnect or check the configured credential. |
322
+ | `FORBIDDEN` | Report the missing scope. |
323
+ | `ENTRY_NOT_FOUND` | List again or ask the user to identify the Entry. |
324
+ | `VALIDATION_FAILED` | Correct clear fields or ask for missing information. |
325
+ | `INVALID_ENTRY_KIND` | Use `note` or `schedule`. |
326
+ | `IDEMPOTENCY_CONFLICT` | Do not retry with that key; confirm intent. |
327
+ | `REVISION_CONFLICT` | Re-read current state, explain the concurrent change, and ask whether to retry or merge. Never force overwrite. |
328
+ | `MCP_TOOL_ERROR` | Treat the outcome as failed or uncertain. |