note-mcp-server 2.2.4 → 2.2.5

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 +8 -2
  2. package/index.js +46 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -105,8 +105,8 @@ socialite_id=eyJpdiI6I…
105
105
 
106
106
  | 工具 | 說明 |
107
107
  |------|------|
108
- | `list_notes` | GET 列表,支援 `search` 關鍵字及 `limit`(預設 3) |
109
- | `read_note` | GET 單筆,支援 `c_id` 或 `last` |
108
+ | `list_notes` | GET 列表,支援 `search` / `tag` / `page` / `limit`(預設 10),每筆附 `note_url` |
109
+ | `read_note` | GET 單筆,支援 `c_id` 或 `last`,回傳附 `note_url` |
110
110
  | `create_note` | POST 新增,`content` 必填,`title` 可選 |
111
111
  | `update_note` | POST 修改,`c_id` 必填,支援 `content`、`title`、`append`、`prepend` |
112
112
  | `delete_note` | POST 刪除,`c_id` + `action=delete` |
@@ -115,6 +115,12 @@ socialite_id=eyJpdiI6I…
115
115
 
116
116
  完整 REST 行為請對你的 API 網址加上 **`/help`** 查官方說明。
117
117
 
118
+ 前台筆記網址格式:
119
+
120
+ ```text
121
+ {notes_url}/app/notes/content/{c_id}
122
+ ```
123
+
118
124
  ---
119
125
 
120
126
  ## 常見問題
package/index.js CHANGED
@@ -109,12 +109,31 @@ function normalizeListPayload(data) {
109
109
  return [];
110
110
  }
111
111
 
112
+ function resolveNotesSiteBase() {
113
+ const fromEnv = firstEnv("notes_url", "NOTES_URL");
114
+ if (fromEnv) {
115
+ return stripTrailingSlashes(fromEnv);
116
+ }
117
+
118
+ // BASE_URL = {site}/api/notes/{socialite}/{token}
119
+ return stripTrailingSlashes(BASE_URL.replace(/\/api\/notes\/.*$/i, ""));
120
+ }
121
+
122
+ const NOTES_SITE_BASE = resolveNotesSiteBase();
123
+
124
+ function buildNoteUrl(cId) {
125
+ if (cId === undefined || cId === null || String(cId).trim() === "") {
126
+ return "";
127
+ }
128
+ return `${NOTES_SITE_BASE}/app/notes/content/${encodeURIComponent(String(cId))}`;
129
+ }
130
+
112
131
  server.setRequestHandler(ListToolsRequestSchema, async () => {
113
132
  return {
114
133
  tools: [
115
134
  {
116
135
  name: "list_notes",
117
- description: `列出或搜尋 ${APP_NAME} 中的筆記。支援關鍵字、標籤搜尋及分頁(預設每頁 10 筆)。`,
136
+ description: `列出或搜尋 ${APP_NAME} 中的筆記。支援關鍵字、標籤搜尋及分頁(預設每頁 10 筆)。回傳資料會附上 note_url(格式:${NOTES_SITE_BASE}/app/notes/content/{c_id})。`,
118
137
  inputSchema: {
119
138
  type: "object",
120
139
  properties: {
@@ -127,7 +146,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
127
146
  },
128
147
  {
129
148
  name: "read_note",
130
- description: `從 ${APP_NAME} 讀取單筆筆記(GET ?c_id=)。亦可傳 c_id=last 讀取最新一筆。`,
149
+ description: `從 ${APP_NAME} 讀取單筆筆記(GET ?c_id=)。亦可傳 c_id=last 讀取最新一筆。回傳資料會附上 note_url(格式:${NOTES_SITE_BASE}/app/notes/content/{c_id})。`,
131
150
  inputSchema: {
132
151
  type: "object",
133
152
  properties: {
@@ -229,9 +248,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
229
248
  params.limit = args.limit || 10;
230
249
 
231
250
  const response = await axios.get(BASE_URL, { params });
251
+ const payload =
252
+ response.data && typeof response.data === "object"
253
+ ? { ...response.data }
254
+ : response.data;
255
+
256
+ const notes = normalizeListPayload(payload);
257
+ if (Array.isArray(notes)) {
258
+ for (const note of notes) {
259
+ if (note && typeof note === "object" && note.c_id !== undefined) {
260
+ note.note_url = buildNoteUrl(note.c_id);
261
+ }
262
+ }
263
+ }
264
+
232
265
  return {
233
266
  content: [
234
- { type: "text", text: JSON.stringify(response.data, null, 2) },
267
+ { type: "text", text: JSON.stringify(payload, null, 2) },
235
268
  ],
236
269
  };
237
270
  }
@@ -241,8 +274,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
241
274
  const response = await axios.get(BASE_URL, {
242
275
  params: { c_id: cId },
243
276
  });
277
+ const payload =
278
+ response.data && typeof response.data === "object"
279
+ ? { ...response.data }
280
+ : response.data;
281
+ if (payload && typeof payload === "object") {
282
+ const effectiveCid =
283
+ payload.c_id !== undefined ? payload.c_id : cId === "last" ? "" : cId;
284
+ payload.note_url = buildNoteUrl(effectiveCid);
285
+ }
244
286
  return {
245
- content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }],
287
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
246
288
  };
247
289
  }
248
290
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "note-mcp-server",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "MCP (stdio) server for Notes API v2 — list/read/write notes, upload images, Web Push from Cursor and compatible clients.",
5
5
  "main": "index.js",
6
6
  "bin": {