@getnote/mcp 1.5.3 → 1.7.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.
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
45
45
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
46
46
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
47
47
  const client_js_1 = require("./client.js");
48
+ const membership_js_1 = require("./membership.js");
48
49
  const node_fs_1 = require("node:fs");
49
50
  const node_path_1 = require("node:path");
50
51
  const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, "..", "package.json"), "utf-8"));
@@ -125,6 +126,15 @@ function getClientId() {
125
126
  console.error("Error: Client ID required. Set GETNOTE_CLIENT_ID env var or pass --client-id <id>");
126
127
  process.exit(1);
127
128
  }
129
+ function snowflakeID(value, field) {
130
+ if (typeof value === "string" && /^\d+$/.test(value)) {
131
+ return value;
132
+ }
133
+ if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) {
134
+ return value;
135
+ }
136
+ throw new Error(`${field} must be a decimal string; only legacy integers within JavaScript's safe range are accepted`);
137
+ }
128
138
  // ─── Tool Definitions ────────────────────────────────────────────────────────
129
139
  const TOOLS = [
130
140
  // ── Notes ──
@@ -149,8 +159,8 @@ const TOOLS = [
149
159
  type: "object",
150
160
  properties: {
151
161
  id: {
152
- type: ["number", "string"],
153
- description: "笔记 ID",
162
+ type: ["string", "number"],
163
+ description: "笔记 ID。必须优先传十进制字符串;仅为兼容旧调用接受 JavaScript 安全整数",
154
164
  },
155
165
  image_quality: {
156
166
  type: "string",
@@ -161,6 +171,36 @@ const TOOLS = [
161
171
  required: ["id"],
162
172
  },
163
173
  },
174
+ {
175
+ name: "get_note_original",
176
+ description: "直接读取笔记原文。链接笔记返回网页原文,录音笔记返回转写原文,文字笔记返回正文;不要把 AI 摘要冒充原文。",
177
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
178
+ },
179
+ {
180
+ name: "get_note_transcript",
181
+ description: "直接读取录音、会议或课堂笔记的转写原文;没有转写时明确返回不可用。",
182
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
183
+ },
184
+ {
185
+ name: "get_note_attachments",
186
+ description: "直接列出笔记中的图片、音频和文件附件,不需要从完整详情中猜字段。",
187
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
188
+ },
189
+ {
190
+ name: "get_note_timeline",
191
+ description: "直接读取录音或会议笔记的结构化时间线和原文资源;没有时间线时明确返回不可用。",
192
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
193
+ },
194
+ {
195
+ name: "get_note_quick_note",
196
+ description: "直接读取录音笔记的快捷笔记;没有快捷笔记时明确返回不可用。",
197
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
198
+ },
199
+ {
200
+ name: "get_note_todos",
201
+ description: "读取从会议总结中明确的待办章节按规则解析出的条目。返回 source 和 items;空列表表示未识别到明确待办章节,不应让模型自由补写。",
202
+ inputSchema: { type: "object", properties: { id: { type: ["string", "number"], description: "笔记 ID,推荐十进制字符串" } }, required: ["id"] },
203
+ },
164
204
  {
165
205
  name: "save_note",
166
206
  description: "新建笔记(⚠️ 仅支持新建,不支持编辑已有笔记)。支持纯文本笔记(plain_text)、链接笔记(link)和图片笔记(img_text)。\n\n🔗 **笔记内链**:Get笔记正文支持链接到其他笔记,格式为 `https://biji.com/note/{note_id}`。如需在笔记正文中引用其他笔记,按此格式填写 content 中的链接。若当前笔记后续会被分享出去,则应优先调用 `share_note` 工具获取被引用笔记的分享链接,并以分享链接替代内链写入正文。\n\n**图片笔记流程**:先用 upload_image 上传图片获取 image_url,再调用此接口传入 image_urls。\n\n**返回值说明**:\n- `plain_text`:同步返回 `id`、`title`、`created_at`、`updated_at`。\n- `link`(分享链接:`biji.com/note/share_note/*` 或 `d.biji.com/*` 短链):同步返回 `id`、`title`、`created_at`、`updated_at`,**无需轮询**。\n- `link`(普通链接):返回 `tasks` 数组(每项含 `task_id` 和 `url`),需用 `get_note_task_progress` 轮询进度。",
@@ -187,8 +227,16 @@ const TOOLS = [
187
227
  description: "标签列表(最多 5 个,每个不超过 10 个汉字)",
188
228
  },
189
229
  parent_id: {
190
- type: ["number", "string"],
191
- description: "父笔记 ID(创建子笔记时填,父笔记的 is_child_note 必须为 false)",
230
+ type: ["string", "number"],
231
+ description: "父笔记 ID(优先传十进制字符串;创建子笔记时填,父笔记的 is_child_note 必须为 false)",
232
+ },
233
+ topic_id: {
234
+ type: "string",
235
+ description: "目标知识库 ID(来自 list_topics;支持 DEFAULT、BOOKSPACE、CUSTOMER、TEAMSPACE)",
236
+ },
237
+ client_request_id: {
238
+ type: "string",
239
+ description: "可选幂等键(1-128 个 ASCII 字符)。重试同一创建请求时必须复用同一个值",
192
240
  },
193
241
  link_url: {
194
242
  type: "string",
@@ -224,8 +272,8 @@ const TOOLS = [
224
272
  type: "object",
225
273
  properties: {
226
274
  note_id: {
227
- type: ["number", "string"],
228
- description: "笔记 ID",
275
+ type: ["string", "number"],
276
+ description: "笔记 ID。必须优先传十进制字符串;仅兼容 JavaScript 安全整数",
229
277
  },
230
278
  },
231
279
  required: ["note_id"],
@@ -238,8 +286,8 @@ const TOOLS = [
238
286
  type: "object",
239
287
  properties: {
240
288
  note_id: {
241
- type: ["number", "string"],
242
- description: "笔记 ID(必填)",
289
+ type: ["string", "number"],
290
+ description: "笔记 ID(必填,优先传十进制字符串)",
243
291
  },
244
292
  title: {
245
293
  type: "string",
@@ -266,8 +314,8 @@ const TOOLS = [
266
314
  type: "object",
267
315
  properties: {
268
316
  note_id: {
269
- type: ["number", "string"],
270
- description: "笔记 ID",
317
+ type: ["string", "number"],
318
+ description: "笔记 ID(优先传十进制字符串)",
271
319
  },
272
320
  tags: {
273
321
  type: "array",
@@ -285,8 +333,8 @@ const TOOLS = [
285
333
  type: "object",
286
334
  properties: {
287
335
  note_id: {
288
- type: ["number", "string"],
289
- description: "笔记 ID",
336
+ type: ["string", "number"],
337
+ description: "笔记 ID(优先传十进制字符串)",
290
338
  },
291
339
  tag_id: {
292
340
  type: "string",
@@ -299,7 +347,7 @@ const TOOLS = [
299
347
  // ── Knowledge / Topics ──
300
348
  {
301
349
  name: "list_topics",
302
- description: "获取知识库列表(每页固定 20 条)。返回 topics[]、has_more、total。每个 topic 包含 topic_id(知识库 ID,后续所有接口的 topic_id 参数均传此值)、name、description、cover、stats(笔记数、文件数、博主数、直播数)等。",
350
+ description: "获取用户创建、拥有或加入的知识库列表,包含普通、书籍、客户档案和团队知识库(TEAMSPACE)。返回 topics[]、has_more、total;保存前可按 name/scope 选择 topic_id。",
303
351
  inputSchema: {
304
352
  type: "object",
305
353
  properties: {
@@ -368,10 +416,44 @@ const TOOLS = [
368
416
  items: { type: "string" },
369
417
  description: "笔记 ID 列表(字符串格式,最多 20 个)",
370
418
  },
419
+ directory_id: {
420
+ type: "string",
421
+ description: "目标目录 ID;不传则加入知识库根目录",
422
+ },
371
423
  },
372
424
  required: ["topic_id", "note_ids"],
373
425
  },
374
426
  },
427
+ {
428
+ name: "list_topic_directories",
429
+ description: "浏览知识库文件夹结构及当前目录下的笔记等资源。支持个人、书籍、客户档案和团队知识库。",
430
+ inputSchema: { type: "object", properties: {
431
+ topic_id: { type: "string", description: "知识库 ID" },
432
+ directory_id: { type: "string", description: "目录 ID;不传表示根目录" },
433
+ }, required: ["topic_id"] },
434
+ },
435
+ {
436
+ name: "create_topic_directory",
437
+ description: "在知识库中创建文件夹。",
438
+ inputSchema: { type: "object", properties: {
439
+ topic_id: { type: "string", description: "知识库 ID" }, name: { type: "string", description: "文件夹名称" },
440
+ parent_id: { type: "string", description: "父目录 ID;不传表示根目录" },
441
+ }, required: ["topic_id", "name"] },
442
+ },
443
+ {
444
+ name: "update_topic_directory",
445
+ description: "重命名或移动知识库文件夹。未提供的字段保持不变。",
446
+ inputSchema: { type: "object", properties: {
447
+ topic_id: { type: "string" }, directory_id: { type: "string" }, name: { type: "string" }, parent_id: { type: "string" },
448
+ }, required: ["topic_id", "directory_id"] },
449
+ },
450
+ {
451
+ name: "delete_topic_directory",
452
+ description: "删除空的知识库文件夹。属于破坏性操作,调用前必须取得用户确认。",
453
+ inputSchema: { type: "object", properties: {
454
+ topic_id: { type: "string" }, directory_id: { type: "string" },
455
+ }, required: ["topic_id", "directory_id"] },
456
+ },
375
457
  {
376
458
  name: "remove_note_from_topic",
377
459
  description: "将笔记从知识库中移除。",
@@ -463,6 +545,14 @@ const TOOLS = [
463
545
  required: ["topic_id"],
464
546
  },
465
547
  },
548
+ {
549
+ name: "follow_topic_blogger",
550
+ description: "把抖音博主订阅到指定知识库,后续可读取该博主内容。",
551
+ inputSchema: { type: "object", properties: {
552
+ topic_id: { type: "string", description: "知识库 ID" }, link: { type: "string", description: "抖音博主主页或分享链接" },
553
+ platform: { type: "string", enum: ["douyin"], default: "douyin" },
554
+ }, required: ["topic_id", "link"] },
555
+ },
466
556
  {
467
557
  name: "list_topic_blogger_contents",
468
558
  description: "获取知识库中某个博主发布的内容列表(摘要,不含原文)。需要 topic.blogger.read scope。",
@@ -474,8 +564,8 @@ const TOOLS = [
474
564
  description: "知识库 ID(来自 list_topics 的 topic_id 字段)",
475
565
  },
476
566
  follow_id: {
477
- type: "number",
478
- description: "博主订阅 ID(来自 list_topic_bloggers 的 follow_id 字段)",
567
+ type: ["string", "number"],
568
+ description: "博主订阅 ID(优先使用 list_topic_bloggers 返回的 follow_id_str;兼容安全整数 follow_id)",
479
569
  },
480
570
  page: {
481
571
  type: "number",
@@ -533,8 +623,8 @@ const TOOLS = [
533
623
  description: "知识库 ID(来自 list_topics 的 topic_id 字段)",
534
624
  },
535
625
  live_id: {
536
- type: "number",
537
- description: "直播 ID(来自 list_topic_lives 的 live_id 字段)",
626
+ type: ["string", "number"],
627
+ description: "直播 ID(来自 list_topic_lives 的 live_id,优先按字符串原样传入)",
538
628
  },
539
629
  },
540
630
  required: ["topic_id", "live_id"],
@@ -542,7 +632,7 @@ const TOOLS = [
542
632
  },
543
633
  {
544
634
  name: "follow_topic_live",
545
- description: "订阅一个得到 App 直播到知识库。直播结束后经 AI 处理即可通过 list_topic_lives 查看。目前仅支持得到 App 直播链接。需要 topic.live.read scope。",
635
+ description: "订阅一个得到 App 直播到知识库。直播结束后经 AI 处理即可通过 list_topic_lives 查看。目前仅支持得到 App 直播链接。需要 topic.live.write scope。",
546
636
  inputSchema: {
547
637
  type: "object",
548
638
  properties: {
@@ -561,7 +651,7 @@ const TOOLS = [
561
651
  // ── Note / Sharing ──
562
652
  {
563
653
  name: "share_note",
564
- description: "生成笔记的公开分享链接。幂等接口,多次调用返回同一个 share_url。需要 note.content.read scope。",
654
+ description: "生成笔记的公开分享链接。幂等接口,多次调用返回同一个 share_url。需要 note.sharing.write scope。",
565
655
  inputSchema: {
566
656
  type: "object",
567
657
  properties: {
@@ -654,7 +744,46 @@ async function handleTool(name, input, client) {
654
744
  return client.listNotes({ cursor: cursor === "0" ? undefined : cursor });
655
745
  }
656
746
  case "get_note": {
657
- return client.getNote(input.id, input.image_quality);
747
+ return client.getNote(snowflakeID(input.id, "id"), input.image_quality);
748
+ }
749
+ case "get_note_original": {
750
+ const result = await client.getNote(snowflakeID(input.id, "id"));
751
+ const note = result.note;
752
+ const original = note.web_page?.content || note.audio?.original || note.content;
753
+ if (!original)
754
+ throw new Error("Original content is not available for this note");
755
+ return { id: note.id, note_type: note.note_type, title: note.title, original };
756
+ }
757
+ case "get_note_transcript": {
758
+ const result = await client.getNote(snowflakeID(input.id, "id"));
759
+ const transcript = result.note.audio?.original;
760
+ if (!transcript)
761
+ throw new Error("Audio transcript is not available for this note");
762
+ return { id: result.note.id, title: result.note.title, transcript };
763
+ }
764
+ case "get_note_attachments": {
765
+ const result = await client.getNote(snowflakeID(input.id, "id"), "original");
766
+ return { id: result.note.id, title: result.note.title, attachments: result.note.attachments || [] };
767
+ }
768
+ case "get_note_timeline": {
769
+ const result = await client.getNote(snowflakeID(input.id, "id"));
770
+ if (!result.note.timeline)
771
+ throw new Error("Timeline is not available for this note");
772
+ return { id: result.note.id, title: result.note.title, timeline: result.note.timeline };
773
+ }
774
+ case "get_note_quick_note": {
775
+ const result = await client.getNote(snowflakeID(input.id, "id"));
776
+ if (!result.note.quick_note)
777
+ throw new Error("Quick note is not available for this note");
778
+ return { id: result.note.id, title: result.note.title, quick_note: result.note.quick_note };
779
+ }
780
+ case "get_note_todos": {
781
+ const result = await client.getNote(snowflakeID(input.id, "id"));
782
+ return {
783
+ id: result.note.id,
784
+ title: result.note.title,
785
+ meeting_todos: result.note.meeting_todos || { source: "summary_markdown_rules", items: [] },
786
+ };
658
787
  }
659
788
  case "save_note": {
660
789
  const body = {};
@@ -667,7 +796,11 @@ async function handleTool(name, input, client) {
667
796
  if (input.tags !== undefined)
668
797
  body.tags = input.tags;
669
798
  if (input.parent_id !== undefined)
670
- body.parent_id = input.parent_id;
799
+ body.parent_id = snowflakeID(input.parent_id, "parent_id");
800
+ if (input.topic_id !== undefined)
801
+ body.topic_id = input.topic_id;
802
+ if (input.client_request_id !== undefined)
803
+ body.client_request_id = input.client_request_id;
671
804
  if (input.link_url !== undefined)
672
805
  body.link_url = input.link_url;
673
806
  if (input.image_urls !== undefined)
@@ -675,11 +808,11 @@ async function handleTool(name, input, client) {
675
808
  return client.saveNote(body);
676
809
  }
677
810
  case "delete_note": {
678
- return client.deleteNote(input.note_id);
811
+ return client.deleteNote(snowflakeID(input.note_id, "note_id"));
679
812
  }
680
813
  case "update_note": {
681
814
  const body = {
682
- note_id: input.note_id,
815
+ note_id: snowflakeID(input.note_id, "note_id"),
683
816
  };
684
817
  if (input.title !== undefined)
685
818
  body.title = input.title;
@@ -694,10 +827,10 @@ async function handleTool(name, input, client) {
694
827
  }
695
828
  // ── Tags ──
696
829
  case "add_note_tags": {
697
- return client.addNoteTags(input.note_id, input.tags);
830
+ return client.addNoteTags(snowflakeID(input.note_id, "note_id"), input.tags);
698
831
  }
699
832
  case "delete_note_tag": {
700
- return client.deleteNoteTag(input.note_id, input.tag_id);
833
+ return client.deleteNoteTag(snowflakeID(input.note_id, "note_id"), input.tag_id);
701
834
  }
702
835
  // ── Knowledge ──
703
836
  case "list_topics": {
@@ -721,13 +854,26 @@ async function handleTool(name, input, client) {
721
854
  case "batch_add_notes_to_topic": {
722
855
  return client.batchAddNotesToTopic({
723
856
  topic_id: input.topic_id,
724
- note_ids: input.note_ids.map(String),
857
+ directory_id: input.directory_id,
858
+ note_ids: input.note_ids.map((id) => String(snowflakeID(id, "note_ids[]"))),
725
859
  });
726
860
  }
861
+ case "list_topic_directories": {
862
+ return client.listTopicDirectories({ topic_id: input.topic_id, directory_id: input.directory_id });
863
+ }
864
+ case "create_topic_directory": {
865
+ return client.createTopicDirectory({ topic_id: input.topic_id, name: input.name, parent_id: input.parent_id });
866
+ }
867
+ case "update_topic_directory": {
868
+ return client.updateTopicDirectory({ topic_id: input.topic_id, directory_id: input.directory_id, name: input.name, parent_id: input.parent_id });
869
+ }
870
+ case "delete_topic_directory": {
871
+ return client.deleteTopicDirectory({ topic_id: input.topic_id, directory_id: input.directory_id });
872
+ }
727
873
  case "remove_note_from_topic": {
728
874
  return client.removeNoteFromTopic({
729
875
  topic_id: input.topic_id,
730
- note_ids: input.note_ids.map(String),
876
+ note_ids: input.note_ids.map((id) => String(snowflakeID(id, "note_ids[]"))),
731
877
  });
732
878
  }
733
879
  // ── Image ──
@@ -771,10 +917,13 @@ async function handleTool(name, input, client) {
771
917
  page: input.page,
772
918
  });
773
919
  }
920
+ case "follow_topic_blogger": {
921
+ return client.followTopicBlogger({ topic_id: input.topic_id, link: input.link, platform: input.platform });
922
+ }
774
923
  case "list_topic_blogger_contents": {
775
924
  return client.listTopicBloggerContents({
776
925
  topic_id: input.topic_id,
777
- follow_id: input.follow_id,
926
+ follow_id: snowflakeID(input.follow_id, "follow_id"),
778
927
  page: input.page,
779
928
  });
780
929
  }
@@ -794,7 +943,7 @@ async function handleTool(name, input, client) {
794
943
  case "get_live_detail": {
795
944
  return client.getLiveDetail({
796
945
  topic_id: input.topic_id,
797
- live_id: input.live_id,
946
+ live_id: snowflakeID(input.live_id, "live_id"),
798
947
  });
799
948
  }
800
949
  case "follow_topic_live": {
@@ -878,9 +1027,13 @@ async function main() {
878
1027
  reason: err.reason,
879
1028
  message: err.message,
880
1029
  request_id: err.requestId,
1030
+ retryable: err.retryable,
1031
+ field: err.field,
1032
+ constraint: err.constraint,
1033
+ expected_type: err.expectedType,
881
1034
  };
882
1035
  if (err.code === 10201) {
883
- errPayload.membership_url = "https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=wangye";
1036
+ errPayload.membership_url = membership_js_1.OPENAPI_MEMBERSHIP_PURCHASE_URL;
884
1037
  }
885
1038
  return {
886
1039
  content: [
@@ -0,0 +1,2 @@
1
+ export declare const OPENAPI_MEMBERSHIP_PURCHASE_URL = "https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_mcp";
2
+ //# sourceMappingURL=membership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../src/membership.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,2EAC8B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPENAPI_MEMBERSHIP_PURCHASE_URL = void 0;
4
+ exports.OPENAPI_MEMBERSHIP_PURCHASE_URL = "https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_mcp";
5
+ //# sourceMappingURL=membership.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getnote/mcp",
3
- "version": "1.5.3",
3
+ "version": "1.7.0",
4
4
  "description": "MCP server for 得到大脑(Get笔记) — manage notes and knowledge bases from AI assistants",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  "build": "tsc",
11
11
  "dev": "ts-node src/index.ts",
12
12
  "start": "node dist/index.js",
13
- "prepare": "npm run build"
13
+ "prepare": "npm run build",
14
+ "test": "npm run build && node --test test/*.test.mjs"
14
15
  },
15
16
  "keywords": [
16
17
  "mcp",
@@ -22,8 +23,8 @@
22
23
  "author": "得到大脑(Get笔记)",
23
24
  "license": "MIT",
24
25
  "dependencies": {
25
- "@modelcontextprotocol/sdk": "^1.0.0",
26
- "axios": "^1.16.1",
26
+ "@modelcontextprotocol/sdk": "^1.30.0",
27
+ "axios": "^1.19.0",
27
28
  "form-data": "^4.0.6",
28
29
  "zod": "^3.22.0"
29
30
  },
@@ -32,15 +33,17 @@
32
33
  "typescript": "^5.3.0"
33
34
  },
34
35
  "engines": {
35
- "node": ">=18.0.0"
36
+ "node": ">=20.0.0"
36
37
  },
37
38
  "overrides": {
38
39
  "express-rate-limit": "^8.2.2",
39
- "hono": "^4.12.21",
40
+ "hono": "^4.13.1",
40
41
  "path-to-regexp": "^8.4.1",
41
- "fast-uri": "^3.1.2",
42
- "ip-address": "^10.2.0",
43
- "axios": "^1.16.1",
42
+ "fast-uri": "^4.1.2",
43
+ "ip-address": "^10.5.0",
44
+ "axios": "^1.19.0",
45
+ "@hono/node-server": "^2.1.0",
46
+ "body-parser": "^2.3.0",
44
47
  "qs": "^6.15.2"
45
48
  }
46
- }
49
+ }