yuque-mcp 0.1.2 → 0.1.4
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/CHANGELOG.md +6 -2
- package/README.md +20 -5
- package/README.zh-CN.md +20 -5
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/services/types.d.ts +30 -0
- package/dist/services/types.d.ts.map +1 -1
- package/dist/services/yuque-client.d.ts +33 -34
- package/dist/services/yuque-client.d.ts.map +1 -1
- package/dist/services/yuque-client.js +152 -194
- package/dist/services/yuque-client.js.map +1 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +14 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/format.d.ts +8 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +8 -8
- package/dist/utils/format.js.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
- Support `YUQUE_PERSONAL_TOKEN` and `YUQUE_GROUP_TOKEN` as primary environment variables (with `YUQUE_TOKEN` as fallback for backward compatibility)
|
|
12
|
+
- Update error messages to reflect new environment variable naming
|
|
13
|
+
|
|
10
14
|
## [0.1.0] - 2025-02-15
|
|
11
15
|
|
|
12
16
|
### Added
|
|
@@ -23,5 +27,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
27
|
- Docker support
|
|
24
28
|
- Documentation in English and Chinese
|
|
25
29
|
|
|
26
|
-
[Unreleased]: https://github.com/
|
|
27
|
-
[0.1.0]: https://github.com/
|
|
30
|
+
[Unreleased]: https://github.com/yuque/yuque-mcp-server/compare/v0.1.0...HEAD
|
|
31
|
+
[0.1.0]: https://github.com/yuque/yuque-mcp-server/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Yuque MCP Server
|
|
2
2
|
|
|
3
|
-
[](https://github.com/yuque/yuque-mcp-server/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/yuque-mcp)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
7
|
MCP server for [Yuque (语雀)](https://www.yuque.com/) — expose your knowledge base to AI assistants through the [Model Context Protocol](https://modelcontextprotocol.io/).
|
|
8
8
|
|
|
9
|
-
🌐 **[Website](https://
|
|
9
|
+
🌐 **[Website](https://yuque.github.io/yuque-ecosystem/)** · [中文文档](./README.zh-CN.md)
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
@@ -22,6 +22,21 @@ Visit [Yuque Developer Settings](https://www.yuque.com/settings/tokens) to creat
|
|
|
22
22
|
claude mcp add yuque-mcp -- npx -y yuque-mcp --token=YOUR_TOKEN
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
Or set environment variable (choose one):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# For personal token
|
|
29
|
+
export YUQUE_PERSONAL_TOKEN=YOUR_TOKEN
|
|
30
|
+
|
|
31
|
+
# For group/team token
|
|
32
|
+
export YUQUE_GROUP_TOKEN=YOUR_TOKEN
|
|
33
|
+
|
|
34
|
+
# Legacy (still supported)
|
|
35
|
+
export YUQUE_TOKEN=YOUR_TOKEN
|
|
36
|
+
|
|
37
|
+
claude mcp add yuque-mcp -- npx -y yuque-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
25
40
|
### 3. Done!
|
|
26
41
|
|
|
27
42
|
Ask your AI assistant to search your Yuque docs, create documents, or manage repos.
|
|
@@ -44,7 +59,7 @@ Ask your AI assistant to search your Yuque docs, create documents, or manage rep
|
|
|
44
59
|
|
|
45
60
|
| Error | Solution |
|
|
46
61
|
|-------|----------|
|
|
47
|
-
| `
|
|
62
|
+
| `YUQUE_PERSONAL_TOKEN is required` | Pass `--token=YOUR_TOKEN` or set one of: `YUQUE_PERSONAL_TOKEN`, `YUQUE_GROUP_TOKEN`, or `YUQUE_TOKEN` |
|
|
48
63
|
| `401 Unauthorized` | Token is invalid or expired — regenerate at [Yuque Settings](https://www.yuque.com/settings/tokens) |
|
|
49
64
|
| `429 Rate Limited` | Wait a moment and retry |
|
|
50
65
|
| Tool not found | Update to latest: `npx -y yuque-mcp@latest` |
|
|
@@ -52,7 +67,7 @@ Ask your AI assistant to search your Yuque docs, create documents, or manage rep
|
|
|
52
67
|
## Development
|
|
53
68
|
|
|
54
69
|
```bash
|
|
55
|
-
git clone https://github.com/
|
|
70
|
+
git clone https://github.com/yuque/yuque-mcp-server.git
|
|
56
71
|
cd yuque-mcp-server
|
|
57
72
|
npm install
|
|
58
73
|
npm test # run tests (57 tests)
|
|
@@ -66,4 +81,4 @@ npm run dev # dev mode with hot reload
|
|
|
66
81
|
|
|
67
82
|
## Links
|
|
68
83
|
|
|
69
|
-
- [Website](https://
|
|
84
|
+
- [Website](https://yuque.github.io/yuque-ecosystem/) · [Yuque API Docs](https://www.yuque.com/yuque/developer/api) · [MCP Protocol](https://modelcontextprotocol.io/) · [Contributing](./CONTRIBUTING.md)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Yuque MCP Server
|
|
2
2
|
|
|
3
|
-
[](https://github.com/yuque/yuque-mcp-server/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/yuque-mcp)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
7
|
[语雀](https://www.yuque.com/) MCP Server — 通过 [Model Context Protocol](https://modelcontextprotocol.io/) 让 AI 助手访问你的语雀知识库。
|
|
8
8
|
|
|
9
|
-
🌐 **[官网](https://
|
|
9
|
+
🌐 **[官网](https://yuque.github.io/yuque-ecosystem/)** · [English](./README.md)
|
|
10
10
|
|
|
11
11
|
## 快速开始
|
|
12
12
|
|
|
@@ -22,6 +22,21 @@
|
|
|
22
22
|
claude mcp add yuque-mcp -- npx -y yuque-mcp --token=YOUR_TOKEN
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
或设置环境变量(三选一):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 个人 Token
|
|
29
|
+
export YUQUE_PERSONAL_TOKEN=YOUR_TOKEN
|
|
30
|
+
|
|
31
|
+
# 团队 Token
|
|
32
|
+
export YUQUE_GROUP_TOKEN=YOUR_TOKEN
|
|
33
|
+
|
|
34
|
+
# 旧版(仍支持)
|
|
35
|
+
export YUQUE_TOKEN=YOUR_TOKEN
|
|
36
|
+
|
|
37
|
+
claude mcp add yuque-mcp -- npx -y yuque-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
25
40
|
### 3. 开始使用!
|
|
26
41
|
|
|
27
42
|
让 AI 助手搜索语雀文档、创建文档、管理知识库。
|
|
@@ -44,14 +59,14 @@ claude mcp add yuque-mcp -- npx -y yuque-mcp --token=YOUR_TOKEN
|
|
|
44
59
|
|
|
45
60
|
| 错误 | 解决方案 |
|
|
46
61
|
|------|----------|
|
|
47
|
-
| `
|
|
62
|
+
| `YUQUE_PERSONAL_TOKEN is required` | 传入 `--token=YOUR_TOKEN` 或设置以下环境变量之一:`YUQUE_PERSONAL_TOKEN`、`YUQUE_GROUP_TOKEN` 或 `YUQUE_TOKEN` |
|
|
48
63
|
| `401 Unauthorized` | Token 无效或过期 — 到[语雀设置](https://www.yuque.com/settings/tokens)重新生成 |
|
|
49
64
|
| `429 Rate Limited` | 请求过于频繁,等待后重试 |
|
|
50
65
|
|
|
51
66
|
## 开发
|
|
52
67
|
|
|
53
68
|
```bash
|
|
54
|
-
git clone https://github.com/
|
|
69
|
+
git clone https://github.com/yuque/yuque-mcp-server.git
|
|
55
70
|
cd yuque-mcp-server
|
|
56
71
|
npm install
|
|
57
72
|
npm test # 运行测试(57 个测试用例)
|
|
@@ -65,4 +80,4 @@ npm run dev # 开发模式
|
|
|
65
80
|
|
|
66
81
|
## 链接
|
|
67
82
|
|
|
68
|
-
- [官网](https://
|
|
83
|
+
- [官网](https://yuque.github.io/yuque-ecosystem/) · [语雀 API 文档](https://www.yuque.com/yuque/developer/api) · [MCP 协议](https://modelcontextprotocol.io/) · [贡献指南](./CONTRIBUTING.md)
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { runStdioServer } from './server.js';
|
|
3
|
-
const token = process.env.
|
|
3
|
+
const token = process.env.YUQUE_PERSONAL_TOKEN ||
|
|
4
|
+
process.env.YUQUE_GROUP_TOKEN ||
|
|
5
|
+
process.env.YUQUE_TOKEN ||
|
|
6
|
+
process.argv.find((arg) => arg.startsWith('--token='))?.split('=')[1];
|
|
4
7
|
if (!token) {
|
|
5
|
-
console.error('Error: YUQUE_TOKEN environment variable or --token argument is required');
|
|
8
|
+
console.error('Error: YUQUE_PERSONAL_TOKEN, YUQUE_GROUP_TOKEN, or YUQUE_TOKEN environment variable (or --token argument) is required');
|
|
6
9
|
process.exit(1);
|
|
7
10
|
}
|
|
8
11
|
runStdioServer(token).catch((error) => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,KAAK,GACT,OAAO,CAAC,GAAG,CAAC,oBAAoB;IAChC,OAAO,CAAC,GAAG,CAAC,iBAAiB;IAC7B,OAAO,CAAC,GAAG,CAAC,WAAW;IACvB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE,IAAI,CAAC,KAAK,EAAE,CAAC;IACX,OAAO,CAAC,KAAK,CAAC,uHAAuH,CAAC,CAAC;IACvI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACpC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { createServer as createMCPServer } from './server.js';
|
|
|
2
2
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
3
|
import { createServer } from 'node:http';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
|
-
const token = process.env.YUQUE_TOKEN;
|
|
5
|
+
const token = process.env.YUQUE_PERSONAL_TOKEN || process.env.YUQUE_GROUP_TOKEN || process.env.YUQUE_TOKEN;
|
|
6
6
|
if (!token) {
|
|
7
|
-
console.error('Error: YUQUE_TOKEN environment variable is required');
|
|
7
|
+
console.error('Error: YUQUE_PERSONAL_TOKEN, YUQUE_GROUP_TOKEN, or YUQUE_TOKEN environment variable is required');
|
|
8
8
|
process.exit(1);
|
|
9
9
|
}
|
|
10
10
|
const mcpServer = createMCPServer(token);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,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C,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QAC3B,OAAO,CAAC,GAAG,CAAC,gDAAgD,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/server.js
CHANGED
package/dist/services/types.d.ts
CHANGED
|
@@ -135,4 +135,34 @@ export interface YuqueApiError {
|
|
|
135
135
|
message: string;
|
|
136
136
|
status?: number;
|
|
137
137
|
}
|
|
138
|
+
/** Data for creating a repo/book. */
|
|
139
|
+
export interface CreateRepoData {
|
|
140
|
+
name: string;
|
|
141
|
+
slug: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
public?: number;
|
|
144
|
+
type?: string;
|
|
145
|
+
}
|
|
146
|
+
/** Data for updating a repo/book. */
|
|
147
|
+
export interface UpdateRepoData {
|
|
148
|
+
name?: string;
|
|
149
|
+
slug?: string;
|
|
150
|
+
description?: string;
|
|
151
|
+
public?: number;
|
|
152
|
+
}
|
|
153
|
+
/** Data for creating a document. */
|
|
154
|
+
export interface CreateDocData {
|
|
155
|
+
title: string;
|
|
156
|
+
slug?: string;
|
|
157
|
+
body?: string;
|
|
158
|
+
format?: string;
|
|
159
|
+
public?: number;
|
|
160
|
+
}
|
|
161
|
+
/** Data for updating a document. */
|
|
162
|
+
export interface UpdateDocData {
|
|
163
|
+
title?: string;
|
|
164
|
+
slug?: string;
|
|
165
|
+
body?: string;
|
|
166
|
+
public?: number;
|
|
167
|
+
}
|
|
138
168
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CA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KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,63 +1,62 @@
|
|
|
1
|
-
import type { YuqueUser, YuqueGroup, YuqueRepo, YuqueDoc, YuqueTocItem, YuqueSearchResult, YuqueDocVersion, YuqueGroupMember, YuqueStatistics } from './types.js';
|
|
1
|
+
import type { YuqueUser, YuqueGroup, YuqueRepo, YuqueDoc, YuqueTocItem, YuqueSearchResult, YuqueDocVersion, YuqueGroupMember, YuqueStatistics, CreateRepoData, UpdateRepoData, CreateDocData, UpdateDocData } from './types.js';
|
|
2
2
|
export declare class YuqueClient {
|
|
3
3
|
private client;
|
|
4
4
|
constructor(token: string, baseURL?: string);
|
|
5
|
+
/** Get the currently authenticated user. */
|
|
5
6
|
getUser(): Promise<YuqueUser>;
|
|
7
|
+
/** List groups/teams that a user belongs to. */
|
|
6
8
|
listGroups(userId: number): Promise<YuqueGroup[]>;
|
|
9
|
+
/** Search for documents, repos, or users. */
|
|
7
10
|
search(query: string, type?: string): Promise<YuqueSearchResult>;
|
|
11
|
+
/** List all repos for a user. */
|
|
8
12
|
listUserRepos(login: string): Promise<YuqueRepo[]>;
|
|
13
|
+
/** List all repos for a group. */
|
|
9
14
|
listGroupRepos(login: string): Promise<YuqueRepo[]>;
|
|
15
|
+
/** Get a repo by ID or namespace (e.g. "group/book"). */
|
|
10
16
|
getRepo(idOrNamespace: string | number): Promise<YuqueRepo>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
createGroupRepo(login: string, data: {
|
|
19
|
-
name: string;
|
|
20
|
-
slug: string;
|
|
21
|
-
description?: string;
|
|
22
|
-
public?: number;
|
|
23
|
-
type?: string;
|
|
24
|
-
}): Promise<YuqueRepo>;
|
|
25
|
-
updateRepo(idOrNamespace: string | number, data: {
|
|
26
|
-
name?: string;
|
|
27
|
-
slug?: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
public?: number;
|
|
30
|
-
}): Promise<YuqueRepo>;
|
|
17
|
+
/** Create a new repo under a user. */
|
|
18
|
+
createUserRepo(login: string, data: CreateRepoData): Promise<YuqueRepo>;
|
|
19
|
+
/** Create a new repo under a group. */
|
|
20
|
+
createGroupRepo(login: string, data: CreateRepoData): Promise<YuqueRepo>;
|
|
21
|
+
/** Update a repo by ID or namespace. */
|
|
22
|
+
updateRepo(idOrNamespace: string | number, data: UpdateRepoData): Promise<YuqueRepo>;
|
|
23
|
+
/** Delete a repo by ID or namespace. */
|
|
31
24
|
deleteRepo(idOrNamespace: string | number): Promise<void>;
|
|
25
|
+
/** List all documents in a repo. */
|
|
32
26
|
listDocs(repoId: string | number): Promise<YuqueDoc[]>;
|
|
27
|
+
/** Get a single document by repo and doc ID/slug. */
|
|
33
28
|
getDoc(repoId: string | number, docId: string | number): Promise<YuqueDoc>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
public?: number;
|
|
40
|
-
}): Promise<YuqueDoc>;
|
|
41
|
-
updateDoc(repoId: string | number, docId: string | number, data: {
|
|
42
|
-
title?: string;
|
|
43
|
-
slug?: string;
|
|
44
|
-
body?: string;
|
|
45
|
-
public?: number;
|
|
46
|
-
}): Promise<YuqueDoc>;
|
|
29
|
+
/** Create a new document in a repo. */
|
|
30
|
+
createDoc(repoId: string | number, data: CreateDocData): Promise<YuqueDoc>;
|
|
31
|
+
/** Update an existing document. */
|
|
32
|
+
updateDoc(repoId: string | number, docId: string | number, data: UpdateDocData): Promise<YuqueDoc>;
|
|
33
|
+
/** Delete a document. */
|
|
47
34
|
deleteDoc(repoId: string | number, docId: string | number): Promise<void>;
|
|
35
|
+
/** Get the table of contents for a repo. */
|
|
48
36
|
getToc(repoId: string | number): Promise<YuqueTocItem[]>;
|
|
37
|
+
/** Update the table of contents for a repo. */
|
|
49
38
|
updateToc(repoId: string | number, data: string): Promise<YuqueTocItem[]>;
|
|
39
|
+
/** List all versions of a document. */
|
|
50
40
|
listDocVersions(docId: number): Promise<YuqueDocVersion[]>;
|
|
41
|
+
/** Get a specific version of a document. */
|
|
51
42
|
getDocVersion(versionId: number): Promise<YuqueDocVersion>;
|
|
43
|
+
/** List all members of a group. */
|
|
52
44
|
listGroupMembers(login: string): Promise<YuqueGroupMember[]>;
|
|
45
|
+
/** Update a group member's role. */
|
|
53
46
|
updateGroupMember(login: string, userId: number, data: {
|
|
54
47
|
role: number;
|
|
55
48
|
}): Promise<YuqueGroupMember>;
|
|
49
|
+
/** Remove a member from a group. */
|
|
56
50
|
removeGroupMember(login: string, userId: number): Promise<void>;
|
|
51
|
+
/** Get overall statistics for a group. */
|
|
57
52
|
getGroupStats(login: string): Promise<YuqueStatistics>;
|
|
53
|
+
/** Get member statistics for a group. */
|
|
58
54
|
getGroupMemberStats(login: string): Promise<unknown>;
|
|
55
|
+
/** Get book/repo statistics for a group. */
|
|
59
56
|
getGroupBookStats(login: string): Promise<unknown>;
|
|
57
|
+
/** Get document statistics for a group. */
|
|
60
58
|
getGroupDocStats(login: string): Promise<unknown>;
|
|
59
|
+
/** Test API connectivity. */
|
|
61
60
|
hello(): Promise<{
|
|
62
61
|
message: string;
|
|
63
62
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yuque-client.d.ts","sourceRoot":"","sources":["../../src/services/yuque-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"yuque-client.d.ts","sourceRoot":"","sources":["../../src/services/yuque-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,Q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C,gBAAgB,CAAC;IAOzG,oCAAoC;IAC9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrE,0CAA0C;IACpC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO5D,yCAAyC;IACnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO1D,4CAA4C;IACtC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOxD,2CAA2C;IACrC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASvD,6BAA6B;IACvB,KAAK,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAM5C"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { handleYuqueError } from '../utils/error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps an async operation with standardized Yuque error handling.
|
|
5
|
+
* Every API call goes through this so error handling stays consistent.
|
|
6
|
+
*/
|
|
7
|
+
async function withErrorHandling(fn) {
|
|
8
|
+
try {
|
|
9
|
+
return await fn();
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
handleYuqueError(error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
3
15
|
export class YuqueClient {
|
|
4
16
|
client;
|
|
5
17
|
constructor(token, baseURL = 'https://www.yuque.com/api/v2') {
|
|
@@ -11,259 +23,205 @@ export class YuqueClient {
|
|
|
11
23
|
},
|
|
12
24
|
});
|
|
13
25
|
}
|
|
14
|
-
// User APIs
|
|
26
|
+
// ── User APIs ──────────────────────────────────────────────
|
|
27
|
+
/** Get the currently authenticated user. */
|
|
15
28
|
async getUser() {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
handleYuqueError(error);
|
|
22
|
-
}
|
|
29
|
+
return withErrorHandling(async () => {
|
|
30
|
+
const r = await this.client.get('/user');
|
|
31
|
+
return r.data.data;
|
|
32
|
+
});
|
|
23
33
|
}
|
|
34
|
+
/** List groups/teams that a user belongs to. */
|
|
24
35
|
async listGroups(userId) {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
handleYuqueError(error);
|
|
31
|
-
}
|
|
36
|
+
return withErrorHandling(async () => {
|
|
37
|
+
const r = await this.client.get(`/users/${userId}/groups`);
|
|
38
|
+
return r.data.data;
|
|
39
|
+
});
|
|
32
40
|
}
|
|
33
|
-
// Search API
|
|
41
|
+
// ── Search API ─────────────────────────────────────────────
|
|
42
|
+
/** Search for documents, repos, or users. */
|
|
34
43
|
async search(query, type) {
|
|
35
|
-
|
|
44
|
+
return withErrorHandling(async () => {
|
|
36
45
|
const params = { q: query };
|
|
37
46
|
if (type)
|
|
38
47
|
params.type = type;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return response.data.data;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
handleYuqueError(error);
|
|
46
|
-
}
|
|
48
|
+
const r = await this.client.get('/search', { params });
|
|
49
|
+
return r.data.data;
|
|
50
|
+
});
|
|
47
51
|
}
|
|
48
|
-
// Repo APIs
|
|
52
|
+
// ── Repo APIs ──────────────────────────────────────────────
|
|
53
|
+
/** List all repos for a user. */
|
|
49
54
|
async listUserRepos(login) {
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
handleYuqueError(error);
|
|
56
|
-
}
|
|
55
|
+
return withErrorHandling(async () => {
|
|
56
|
+
const r = await this.client.get(`/users/${login}/repos`);
|
|
57
|
+
return r.data.data;
|
|
58
|
+
});
|
|
57
59
|
}
|
|
60
|
+
/** List all repos for a group. */
|
|
58
61
|
async listGroupRepos(login) {
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
handleYuqueError(error);
|
|
65
|
-
}
|
|
62
|
+
return withErrorHandling(async () => {
|
|
63
|
+
const r = await this.client.get(`/groups/${login}/repos`);
|
|
64
|
+
return r.data.data;
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
|
+
/** Get a repo by ID or namespace (e.g. "group/book"). */
|
|
67
68
|
async getRepo(idOrNamespace) {
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
handleYuqueError(error);
|
|
74
|
-
}
|
|
69
|
+
return withErrorHandling(async () => {
|
|
70
|
+
const r = await this.client.get(`/repos/${idOrNamespace}`);
|
|
71
|
+
return r.data.data;
|
|
72
|
+
});
|
|
75
73
|
}
|
|
74
|
+
/** Create a new repo under a user. */
|
|
76
75
|
async createUserRepo(login, data) {
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
handleYuqueError(error);
|
|
83
|
-
}
|
|
76
|
+
return withErrorHandling(async () => {
|
|
77
|
+
const r = await this.client.post(`/users/${login}/repos`, data);
|
|
78
|
+
return r.data.data;
|
|
79
|
+
});
|
|
84
80
|
}
|
|
81
|
+
/** Create a new repo under a group. */
|
|
85
82
|
async createGroupRepo(login, data) {
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
handleYuqueError(error);
|
|
92
|
-
}
|
|
83
|
+
return withErrorHandling(async () => {
|
|
84
|
+
const r = await this.client.post(`/groups/${login}/repos`, data);
|
|
85
|
+
return r.data.data;
|
|
86
|
+
});
|
|
93
87
|
}
|
|
88
|
+
/** Update a repo by ID or namespace. */
|
|
94
89
|
async updateRepo(idOrNamespace, data) {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
handleYuqueError(error);
|
|
101
|
-
}
|
|
90
|
+
return withErrorHandling(async () => {
|
|
91
|
+
const r = await this.client.put(`/repos/${idOrNamespace}`, data);
|
|
92
|
+
return r.data.data;
|
|
93
|
+
});
|
|
102
94
|
}
|
|
95
|
+
/** Delete a repo by ID or namespace. */
|
|
103
96
|
async deleteRepo(idOrNamespace) {
|
|
104
|
-
|
|
97
|
+
return withErrorHandling(async () => {
|
|
105
98
|
await this.client.delete(`/repos/${idOrNamespace}`);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
handleYuqueError(error);
|
|
109
|
-
}
|
|
99
|
+
});
|
|
110
100
|
}
|
|
111
|
-
// Doc APIs
|
|
101
|
+
// ── Doc APIs ───────────────────────────────────────────────
|
|
102
|
+
/** List all documents in a repo. */
|
|
112
103
|
async listDocs(repoId) {
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
handleYuqueError(error);
|
|
119
|
-
}
|
|
104
|
+
return withErrorHandling(async () => {
|
|
105
|
+
const r = await this.client.get(`/repos/${repoId}/docs`);
|
|
106
|
+
return r.data.data;
|
|
107
|
+
});
|
|
120
108
|
}
|
|
109
|
+
/** Get a single document by repo and doc ID/slug. */
|
|
121
110
|
async getDoc(repoId, docId) {
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
handleYuqueError(error);
|
|
128
|
-
}
|
|
111
|
+
return withErrorHandling(async () => {
|
|
112
|
+
const r = await this.client.get(`/repos/${repoId}/docs/${docId}`);
|
|
113
|
+
return r.data.data;
|
|
114
|
+
});
|
|
129
115
|
}
|
|
116
|
+
/** Create a new document in a repo. */
|
|
130
117
|
async createDoc(repoId, data) {
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
handleYuqueError(error);
|
|
137
|
-
}
|
|
118
|
+
return withErrorHandling(async () => {
|
|
119
|
+
const r = await this.client.post(`/repos/${repoId}/docs`, data);
|
|
120
|
+
return r.data.data;
|
|
121
|
+
});
|
|
138
122
|
}
|
|
123
|
+
/** Update an existing document. */
|
|
139
124
|
async updateDoc(repoId, docId, data) {
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
handleYuqueError(error);
|
|
146
|
-
}
|
|
125
|
+
return withErrorHandling(async () => {
|
|
126
|
+
const r = await this.client.put(`/repos/${repoId}/docs/${docId}`, data);
|
|
127
|
+
return r.data.data;
|
|
128
|
+
});
|
|
147
129
|
}
|
|
130
|
+
/** Delete a document. */
|
|
148
131
|
async deleteDoc(repoId, docId) {
|
|
149
|
-
|
|
132
|
+
return withErrorHandling(async () => {
|
|
150
133
|
await this.client.delete(`/repos/${repoId}/docs/${docId}`);
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
handleYuqueError(error);
|
|
154
|
-
}
|
|
134
|
+
});
|
|
155
135
|
}
|
|
156
|
-
// TOC APIs
|
|
136
|
+
// ── TOC APIs ───────────────────────────────────────────────
|
|
137
|
+
/** Get the table of contents for a repo. */
|
|
157
138
|
async getToc(repoId) {
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
handleYuqueError(error);
|
|
164
|
-
}
|
|
139
|
+
return withErrorHandling(async () => {
|
|
140
|
+
const r = await this.client.get(`/repos/${repoId}/toc`);
|
|
141
|
+
return r.data.data;
|
|
142
|
+
});
|
|
165
143
|
}
|
|
144
|
+
/** Update the table of contents for a repo. */
|
|
166
145
|
async updateToc(repoId, data) {
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
handleYuqueError(error);
|
|
173
|
-
}
|
|
146
|
+
return withErrorHandling(async () => {
|
|
147
|
+
const r = await this.client.put(`/repos/${repoId}/toc`, data);
|
|
148
|
+
return r.data.data;
|
|
149
|
+
});
|
|
174
150
|
}
|
|
175
|
-
// Doc Version APIs
|
|
151
|
+
// ── Doc Version APIs ───────────────────────────────────────
|
|
152
|
+
/** List all versions of a document. */
|
|
176
153
|
async listDocVersions(docId) {
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
154
|
+
return withErrorHandling(async () => {
|
|
155
|
+
const r = await this.client.get('/doc_versions', {
|
|
156
|
+
params: { doc_id: docId },
|
|
157
|
+
});
|
|
158
|
+
return r.data.data;
|
|
159
|
+
});
|
|
184
160
|
}
|
|
161
|
+
/** Get a specific version of a document. */
|
|
185
162
|
async getDocVersion(versionId) {
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
handleYuqueError(error);
|
|
192
|
-
}
|
|
163
|
+
return withErrorHandling(async () => {
|
|
164
|
+
const r = await this.client.get(`/doc_versions/${versionId}`);
|
|
165
|
+
return r.data.data;
|
|
166
|
+
});
|
|
193
167
|
}
|
|
194
|
-
// Group Member APIs
|
|
168
|
+
// ── Group Member APIs ──────────────────────────────────────
|
|
169
|
+
/** List all members of a group. */
|
|
195
170
|
async listGroupMembers(login) {
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
handleYuqueError(error);
|
|
202
|
-
}
|
|
171
|
+
return withErrorHandling(async () => {
|
|
172
|
+
const r = await this.client.get(`/groups/${login}/users`);
|
|
173
|
+
return r.data.data;
|
|
174
|
+
});
|
|
203
175
|
}
|
|
176
|
+
/** Update a group member's role. */
|
|
204
177
|
async updateGroupMember(login, userId, data) {
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
handleYuqueError(error);
|
|
211
|
-
}
|
|
178
|
+
return withErrorHandling(async () => {
|
|
179
|
+
const r = await this.client.put(`/groups/${login}/users/${userId}`, data);
|
|
180
|
+
return r.data.data;
|
|
181
|
+
});
|
|
212
182
|
}
|
|
183
|
+
/** Remove a member from a group. */
|
|
213
184
|
async removeGroupMember(login, userId) {
|
|
214
|
-
|
|
185
|
+
return withErrorHandling(async () => {
|
|
215
186
|
await this.client.delete(`/groups/${login}/users/${userId}`);
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
handleYuqueError(error);
|
|
219
|
-
}
|
|
187
|
+
});
|
|
220
188
|
}
|
|
221
|
-
// Statistics APIs
|
|
189
|
+
// ── Statistics APIs ────────────────────────────────────────
|
|
190
|
+
/** Get overall statistics for a group. */
|
|
222
191
|
async getGroupStats(login) {
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
handleYuqueError(error);
|
|
229
|
-
}
|
|
192
|
+
return withErrorHandling(async () => {
|
|
193
|
+
const r = await this.client.get(`/groups/${login}/statistics`);
|
|
194
|
+
return r.data.data;
|
|
195
|
+
});
|
|
230
196
|
}
|
|
197
|
+
/** Get member statistics for a group. */
|
|
231
198
|
async getGroupMemberStats(login) {
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
handleYuqueError(error);
|
|
238
|
-
}
|
|
199
|
+
return withErrorHandling(async () => {
|
|
200
|
+
const r = await this.client.get(`/groups/${login}/statistics/members`);
|
|
201
|
+
return r.data.data;
|
|
202
|
+
});
|
|
239
203
|
}
|
|
204
|
+
/** Get book/repo statistics for a group. */
|
|
240
205
|
async getGroupBookStats(login) {
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
return
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
handleYuqueError(error);
|
|
247
|
-
}
|
|
206
|
+
return withErrorHandling(async () => {
|
|
207
|
+
const r = await this.client.get(`/groups/${login}/statistics/books`);
|
|
208
|
+
return r.data.data;
|
|
209
|
+
});
|
|
248
210
|
}
|
|
211
|
+
/** Get document statistics for a group. */
|
|
249
212
|
async getGroupDocStats(login) {
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
return
|
|
253
|
-
}
|
|
254
|
-
catch (error) {
|
|
255
|
-
handleYuqueError(error);
|
|
256
|
-
}
|
|
213
|
+
return withErrorHandling(async () => {
|
|
214
|
+
const r = await this.client.get(`/groups/${login}/statistics/docs`);
|
|
215
|
+
return r.data.data;
|
|
216
|
+
});
|
|
257
217
|
}
|
|
258
|
-
// Hello API
|
|
218
|
+
// ── Hello API ──────────────────────────────────────────────
|
|
219
|
+
/** Test API connectivity. */
|
|
259
220
|
async hello() {
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
handleYuqueError(error);
|
|
266
|
-
}
|
|
221
|
+
return withErrorHandling(async () => {
|
|
222
|
+
const r = await this.client.get('/hello');
|
|
223
|
+
return r.data.data;
|
|
224
|
+
});
|
|
267
225
|
}
|
|
268
226
|
}
|
|
269
227
|
//# sourceMappingURL=yuque-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yuque-client.js","sourceRoot":"","sources":["../../src/services/yuque-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"yuque-client.js","sourceRoot":"","sources":["../../src/services/yuque-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,C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,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,OAAO,YAAA;CAKjC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IAG1B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,OAAO;gBAF9B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,OAAO,YAAA;CAKjC;AAcD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAsBtD"}
|
package/dist/utils/error.js
CHANGED
|
@@ -8,6 +8,17 @@ export class YuqueError extends Error {
|
|
|
8
8
|
this.name = 'YuqueError';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
/** Map common HTTP status codes to human-readable hints for better AI diagnostics. */
|
|
12
|
+
function statusHint(status) {
|
|
13
|
+
switch (status) {
|
|
14
|
+
case 400: return 'Bad request — check the parameters';
|
|
15
|
+
case 401: return 'Unauthorized — the API token (YUQUE_PERSONAL_TOKEN, YUQUE_GROUP_TOKEN, or YUQUE_TOKEN) may be invalid or expired';
|
|
16
|
+
case 403: return 'Forbidden — insufficient permissions for this resource';
|
|
17
|
+
case 404: return 'Not found — the resource does not exist or is not accessible';
|
|
18
|
+
case 429: return 'Rate limited — too many requests, try again later';
|
|
19
|
+
default: return status >= 500 ? 'Yuque server error — try again later' : '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
11
22
|
export function handleYuqueError(error) {
|
|
12
23
|
if (error instanceof YuqueError) {
|
|
13
24
|
throw error;
|
|
@@ -16,7 +27,9 @@ export function handleYuqueError(error) {
|
|
|
16
27
|
const err = error;
|
|
17
28
|
if (err.response) {
|
|
18
29
|
const status = err.response.status;
|
|
19
|
-
const
|
|
30
|
+
const apiMessage = err.response.data?.message || err.message || 'Unknown Yuque API error';
|
|
31
|
+
const hint = status ? statusHint(status) : '';
|
|
32
|
+
const message = hint ? `${apiMessage} (${hint})` : apiMessage;
|
|
20
33
|
throw new YuqueError(message, status, error);
|
|
21
34
|
}
|
|
22
35
|
if (err.message) {
|
package/dist/utils/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAG1B;IACA;IAHT,YACE,OAAe,EACR,UAAmB,EACnB,aAAuB;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAV,UAAU,CAAS;QACnB,kBAAa,GAAb,aAAa,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,KAA0F,CAAC;QAEvG,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACnC,MAAM,
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAG1B;IACA;IAHT,YACE,OAAe,EACR,UAAmB,EACnB,aAAuB;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAV,UAAU,CAAS;QACnB,kBAAa,GAAb,aAAa,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,sFAAsF;AACtF,SAAS,UAAU,CAAC,MAAc;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CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,UAAU,CAAC,wBAAwB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/utils/format.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { YuqueUser, YuqueGroup, YuqueRepo, YuqueDoc, YuqueTocItem, YuqueDocVersion, YuqueGroupMember } from '../services/types.js';
|
|
2
|
+
/** Format user data — strips fields that are noisy for AI consumption. */
|
|
2
3
|
export declare function formatUser(user: YuqueUser): {
|
|
3
4
|
id: number;
|
|
4
5
|
login: string;
|
|
@@ -8,6 +9,7 @@ export declare function formatUser(user: YuqueUser): {
|
|
|
8
9
|
books_count: number;
|
|
9
10
|
followers_count: number;
|
|
10
11
|
};
|
|
12
|
+
/** Format group data for concise AI-friendly output. */
|
|
11
13
|
export declare function formatGroup(group: YuqueGroup): {
|
|
12
14
|
id: number;
|
|
13
15
|
login: string;
|
|
@@ -16,6 +18,7 @@ export declare function formatGroup(group: YuqueGroup): {
|
|
|
16
18
|
books_count: number;
|
|
17
19
|
members_count: number;
|
|
18
20
|
};
|
|
21
|
+
/** Format repo data — converts numeric `public` field to boolean. */
|
|
19
22
|
export declare function formatRepo(repo: YuqueRepo): {
|
|
20
23
|
id: number;
|
|
21
24
|
slug: string;
|
|
@@ -26,6 +29,7 @@ export declare function formatRepo(repo: YuqueRepo): {
|
|
|
26
29
|
items_count: number;
|
|
27
30
|
updated_at: string;
|
|
28
31
|
};
|
|
32
|
+
/** Format doc summary — excludes body to reduce token usage. */
|
|
29
33
|
export declare function formatDocSummary(doc: YuqueDoc): {
|
|
30
34
|
id: number;
|
|
31
35
|
slug: string;
|
|
@@ -35,6 +39,7 @@ export declare function formatDocSummary(doc: YuqueDoc): {
|
|
|
35
39
|
word_count: number;
|
|
36
40
|
updated_at: string;
|
|
37
41
|
};
|
|
42
|
+
/** Format full doc data including body content. */
|
|
38
43
|
export declare function formatDoc(doc: YuqueDoc): {
|
|
39
44
|
body: string;
|
|
40
45
|
body_html: string;
|
|
@@ -47,6 +52,7 @@ export declare function formatDoc(doc: YuqueDoc): {
|
|
|
47
52
|
word_count: number;
|
|
48
53
|
updated_at: string;
|
|
49
54
|
};
|
|
55
|
+
/** Format TOC items — flattens to essential navigation fields. */
|
|
50
56
|
export declare function formatToc(items: YuqueTocItem[]): {
|
|
51
57
|
title: string;
|
|
52
58
|
uuid: string;
|
|
@@ -54,6 +60,7 @@ export declare function formatToc(items: YuqueTocItem[]): {
|
|
|
54
60
|
level: number;
|
|
55
61
|
visible: boolean;
|
|
56
62
|
}[];
|
|
63
|
+
/** Format doc version — excludes body for list views. */
|
|
57
64
|
export declare function formatDocVersion(version: YuqueDocVersion): {
|
|
58
65
|
id: number;
|
|
59
66
|
doc_id: number;
|
|
@@ -61,6 +68,7 @@ export declare function formatDocVersion(version: YuqueDocVersion): {
|
|
|
61
68
|
format: string;
|
|
62
69
|
created_at: string;
|
|
63
70
|
};
|
|
71
|
+
/** Format group member with optional nested user info. */
|
|
64
72
|
export declare function formatGroupMember(member: YuqueGroupMember): {
|
|
65
73
|
id: number;
|
|
66
74
|
user_id: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS;;;;;;;;EAUzC;AAED,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU;;;;;;;EAS5C;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS;;;;;;;;;EAWzC;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ;;;;;;;;EAU7C;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ;;;;;;;;;;;EAOtC;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE;;;;;;IAQ9C;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe;;;;;;EAQxD;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;;;;;;;;;EAOzD"}
|
package/dist/utils/format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** Format user data — strips fields that are noisy for AI consumption. */
|
|
2
2
|
export function formatUser(user) {
|
|
3
3
|
return {
|
|
4
4
|
id: user.id,
|
|
@@ -10,7 +10,7 @@ export function formatUser(user) {
|
|
|
10
10
|
followers_count: user.followers_count,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
/** Format group data for concise AI-friendly output. */
|
|
14
14
|
export function formatGroup(group) {
|
|
15
15
|
return {
|
|
16
16
|
id: group.id,
|
|
@@ -21,7 +21,7 @@ export function formatGroup(group) {
|
|
|
21
21
|
members_count: group.members_count,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/** Format repo data — converts numeric `public` field to boolean. */
|
|
25
25
|
export function formatRepo(repo) {
|
|
26
26
|
return {
|
|
27
27
|
id: repo.id,
|
|
@@ -34,7 +34,7 @@ export function formatRepo(repo) {
|
|
|
34
34
|
updated_at: repo.updated_at,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/** Format doc summary — excludes body to reduce token usage. */
|
|
38
38
|
export function formatDocSummary(doc) {
|
|
39
39
|
return {
|
|
40
40
|
id: doc.id,
|
|
@@ -46,7 +46,7 @@ export function formatDocSummary(doc) {
|
|
|
46
46
|
updated_at: doc.updated_at,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
/** Format full doc data including body content. */
|
|
50
50
|
export function formatDoc(doc) {
|
|
51
51
|
return {
|
|
52
52
|
...formatDocSummary(doc),
|
|
@@ -55,7 +55,7 @@ export function formatDoc(doc) {
|
|
|
55
55
|
description: doc.description,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
/** Format TOC items — flattens to essential navigation fields. */
|
|
59
59
|
export function formatToc(items) {
|
|
60
60
|
return items.map((item) => ({
|
|
61
61
|
title: item.title,
|
|
@@ -65,7 +65,7 @@ export function formatToc(items) {
|
|
|
65
65
|
visible: item.visible === 1,
|
|
66
66
|
}));
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
/** Format doc version — excludes body for list views. */
|
|
69
69
|
export function formatDocVersion(version) {
|
|
70
70
|
return {
|
|
71
71
|
id: version.id,
|
|
@@ -75,7 +75,7 @@ export function formatDocVersion(version) {
|
|
|
75
75
|
created_at: version.created_at,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
/** Format group member with optional nested user info. */
|
|
79
79
|
export function formatGroupMember(member) {
|
|
80
80
|
return {
|
|
81
81
|
id: member.id,
|
package/dist/utils/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAUA,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAUA,0EAA0E;AAC1E,MAAM,UAAU,UAAU,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MAAM,CAAC,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuque-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "MCP server for Yuque (语雀) — expose Yuque knowledge base to AI assistants via Model Context Protocol",
|
|
5
|
+
"mcpName": "io.github.yuque/yuque-mcp",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/cli.js",
|
|
7
8
|
"bin": {
|
|
@@ -36,16 +37,16 @@
|
|
|
36
37
|
"claude",
|
|
37
38
|
"cursor"
|
|
38
39
|
],
|
|
39
|
-
"author": "
|
|
40
|
+
"author": "yuque",
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/
|
|
44
|
+
"url": "https://github.com/yuque/yuque-mcp-server.git"
|
|
44
45
|
},
|
|
45
46
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/
|
|
47
|
+
"url": "https://github.com/yuque/yuque-mcp-server/issues"
|
|
47
48
|
},
|
|
48
|
-
"homepage": "https://github.com/
|
|
49
|
+
"homepage": "https://github.com/yuque/yuque-mcp-server#readme",
|
|
49
50
|
"engines": {
|
|
50
51
|
"node": ">=18.0.0"
|
|
51
52
|
},
|