feishu-mcp 0.1.4 → 0.1.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.
- package/README.md +3 -2
- package/dist/mcp/feishuMcp.js +1 -1
- package/dist/services/baseService.js +14 -3
- package/dist/utils/config.js +0 -5
- package/dist/utils/error.js +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
- ~~**支持mermaid图表**:流程图、时序图等等,丰富文档内容~~ 0.1.11 ✅
|
|
80
80
|
- ~~**支持表格创建**:创建包含各种块类型的复杂表格,支持样式控制~~ 0.1.2 ✅
|
|
81
81
|
- ~~**支持飞书多用户user认证**:一人部署,可以多人使用~~ 0.1.3 ✅
|
|
82
|
+
- **支持user_access_token自动刷新**:无需频繁授权,提高使用体验
|
|
82
83
|
|
|
83
84
|
---
|
|
84
85
|
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
### 方式一:使用 NPM 快速运行
|
|
98
99
|
|
|
99
100
|
```bash
|
|
100
|
-
npx feishu-mcp@latest --feishu-app-id=<你的飞书应用ID> --feishu-app-secret=<你的飞书应用密钥> --
|
|
101
|
+
npx feishu-mcp@latest --feishu-app-id=<你的飞书应用ID> --feishu-app-secret=<你的飞书应用密钥> --feishu-auth-type=<tenant/user>
|
|
101
102
|
```
|
|
102
103
|
|
|
103
104
|
### 方式二:本地运行
|
|
@@ -154,7 +155,7 @@ npx feishu-mcp@latest --feishu-app-id=<你的飞书应用ID> --feishu-app-secret
|
|
|
154
155
|
}
|
|
155
156
|
},
|
|
156
157
|
"feishu_local": {
|
|
157
|
-
"url": "http://localhost:3333/sse
|
|
158
|
+
"url": "http://localhost:3333/sse?userKey=123456"
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
}
|
package/dist/mcp/feishuMcp.js
CHANGED
|
@@ -6,7 +6,7 @@ import { registerFeishuBlockTools } from './tools/feishuBlockTools.js';
|
|
|
6
6
|
import { registerFeishuFolderTools } from './tools/feishuFolderTools.js';
|
|
7
7
|
const serverInfo = {
|
|
8
8
|
name: "Feishu MCP Server",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.5",
|
|
10
10
|
};
|
|
11
11
|
const serverOptions = {
|
|
12
12
|
capabilities: { logging: {}, tools: {} },
|
|
@@ -130,9 +130,20 @@ export class BaseApiService {
|
|
|
130
130
|
if (error instanceof AuthRequiredError) {
|
|
131
131
|
return this.handleAuthFailure(config.authType === "tenant", clientKey, baseUrl, userKey);
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
const tokenError = new Set([
|
|
134
|
+
4001, // Invalid token, please refresh
|
|
135
|
+
20006, // 过期 User Access Token
|
|
136
|
+
20013, // get tenant access token fail
|
|
137
|
+
99991663, // Invalid access token for authorization (often tenant token)
|
|
138
|
+
99991668, // Invalid access token for authorization (user token)
|
|
139
|
+
99991677, // user token expire
|
|
140
|
+
99991669, // invalid user refresh token
|
|
141
|
+
99991664, // invalid app token
|
|
142
|
+
99991665 // invalid tenant code
|
|
143
|
+
]);
|
|
144
|
+
// 处理认证相关错误(401, 403等 或 明确的 token 错误码)
|
|
145
|
+
if (error instanceof AxiosError && error.response && tokenError.has(Number(error.response.data?.code))) {
|
|
146
|
+
Logger.warn(`认证失败 (${error.response.status}): ${endpoint} ${JSON.stringify(error.response.data)}`);
|
|
136
147
|
// 获取配置和token缓存管理器
|
|
137
148
|
const tokenCacheManager = TokenCacheManager.getInstance();
|
|
138
149
|
// 如果已经重试过,直接处理认证失败
|
package/dist/utils/config.js
CHANGED
|
@@ -347,7 +347,6 @@ export class Config {
|
|
|
347
347
|
}
|
|
348
348
|
Logger.info(`- API URL: ${this.feishu.baseUrl} (来源: ${this.configSources['feishu.baseUrl']})`);
|
|
349
349
|
Logger.info(`- 认证类型: ${this.feishu.authType} (来源: ${this.configSources['feishu.authType']})`);
|
|
350
|
-
Logger.info(`- Token获取地址: ${this.feishu.tokenEndpoint} (来源: ${this.configSources['feishu.tokenEndpoint']})`);
|
|
351
350
|
Logger.info('日志配置:');
|
|
352
351
|
Logger.info(`- 日志级别: ${LogLevel[this.log.level]} (来源: ${this.configSources['log.level']})`);
|
|
353
352
|
Logger.info(`- 显示时间戳: ${this.log.showTimestamp} (来源: ${this.configSources['log.showTimestamp']})`);
|
|
@@ -386,10 +385,6 @@ export class Config {
|
|
|
386
385
|
Logger.error('缺少飞书应用Secret,请通过环境变量FEISHU_APP_SECRET或命令行参数--feishu-app-secret提供');
|
|
387
386
|
return false;
|
|
388
387
|
}
|
|
389
|
-
if (!this.feishu.tokenEndpoint) {
|
|
390
|
-
Logger.error('缺少飞书Token获取地址,请通过环境变量FEISHU_TOKEN_ENDPOINT或命令行参数--feishu-token-endpoint提供');
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
388
|
return true;
|
|
394
389
|
}
|
|
395
390
|
}
|
package/dist/utils/error.js
CHANGED
|
@@ -47,6 +47,29 @@ export function formatErrorMessage(error, context) {
|
|
|
47
47
|
let fieldViolations = [];
|
|
48
48
|
let troubleshooter = '';
|
|
49
49
|
let logId = '';
|
|
50
|
+
// 优先处理 Axios 响应:直接读取 response.data.data.msg 或 response.data.msg
|
|
51
|
+
if (error?.response?.data && typeof error.response.data === 'object') {
|
|
52
|
+
const respData = error.response.data;
|
|
53
|
+
const msgFromResp = respData?.data?.msg ?? respData?.msg;
|
|
54
|
+
const codeFromResp = respData?.data?.code ?? respData?.code;
|
|
55
|
+
const logFromResp = respData?.log_id || respData?.error?.log_id || error.response.headers?.['x-tt-logid'] || '';
|
|
56
|
+
if (typeof msgFromResp === 'string') {
|
|
57
|
+
let formatted = '';
|
|
58
|
+
if (context) {
|
|
59
|
+
formatted += `${context}: `;
|
|
60
|
+
}
|
|
61
|
+
if (codeFromResp !== undefined) {
|
|
62
|
+
formatted += `${msgFromResp} (错误码: ${codeFromResp})`;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
formatted += msgFromResp;
|
|
66
|
+
}
|
|
67
|
+
if (logFromResp) {
|
|
68
|
+
formatted += `\n日志ID: ${logFromResp}`;
|
|
69
|
+
}
|
|
70
|
+
return formatted;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
50
73
|
// 处理飞书API标准错误格式
|
|
51
74
|
if (error.apiError) {
|
|
52
75
|
const apiError = error.apiError;
|