dingtalk-mcp 1.0.2 → 1.0.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/dingtalk_robot_im_mcp_server.yaml +168 -2
- package/dist/DingTalkMCPServer.js +14 -6
- package/dist/cli.js +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
server:
|
|
2
2
|
name: dingtalk-robot-send-message
|
|
3
3
|
description: 钉钉机器人发消息和DING消息
|
|
4
|
+
default_active: true
|
|
4
5
|
securitySchemes:
|
|
5
6
|
- id: DingTalkAuth
|
|
6
7
|
type: apiKey
|
|
7
8
|
in: header
|
|
8
9
|
name: x-acs-dingtalk-access-token
|
|
9
10
|
tools:
|
|
10
|
-
- name:
|
|
11
|
+
- name: sendDINGMessageByRobot
|
|
11
12
|
description: 机器人发送DING消息
|
|
12
13
|
args:
|
|
13
14
|
- name: robotCode
|
|
@@ -43,7 +44,7 @@ tools:
|
|
|
43
44
|
id: DingTalkAuth
|
|
44
45
|
responseTemplate: {}
|
|
45
46
|
|
|
46
|
-
- name:
|
|
47
|
+
- name: recallDINGMessage
|
|
47
48
|
description: 机器人发送DING消息
|
|
48
49
|
args:
|
|
49
50
|
- name: robotCode
|
|
@@ -66,3 +67,168 @@ tools:
|
|
|
66
67
|
security:
|
|
67
68
|
id: DingTalkAuth
|
|
68
69
|
responseTemplate: { }
|
|
70
|
+
- name: sendGroupMessageByRobot
|
|
71
|
+
description: 机器人发送群消息
|
|
72
|
+
args:
|
|
73
|
+
- name: robotCode
|
|
74
|
+
description: 机器人Code
|
|
75
|
+
type: string
|
|
76
|
+
required: true
|
|
77
|
+
position: body
|
|
78
|
+
system: ROBOT_CODE
|
|
79
|
+
- name: openConversationId
|
|
80
|
+
type: string
|
|
81
|
+
description: 会话ID。
|
|
82
|
+
position: body
|
|
83
|
+
required: true
|
|
84
|
+
- name: coolAppCode
|
|
85
|
+
type: string
|
|
86
|
+
description: 群聊酷应用编码。
|
|
87
|
+
system: COOL_APP_CODE
|
|
88
|
+
position: body
|
|
89
|
+
- name: msgKey
|
|
90
|
+
type: string
|
|
91
|
+
description: 消息模板key,默认为"sampleMarkdown"。
|
|
92
|
+
position: body
|
|
93
|
+
- name: msgParam
|
|
94
|
+
type: string
|
|
95
|
+
description: 消息内容,为markdown格式。
|
|
96
|
+
position: body
|
|
97
|
+
required: true
|
|
98
|
+
|
|
99
|
+
requestTemplate:
|
|
100
|
+
url: https://api.dingtalk.com/v1.0/robot/groupMessages/send
|
|
101
|
+
method: POST
|
|
102
|
+
headers:
|
|
103
|
+
- key: Content-Type
|
|
104
|
+
value: application/json
|
|
105
|
+
security:
|
|
106
|
+
id: DingTalkAuth
|
|
107
|
+
responseTemplate: { }
|
|
108
|
+
|
|
109
|
+
- name: recallGroupMessageByRobot
|
|
110
|
+
description: 撤回机器人发送的群消息
|
|
111
|
+
args:
|
|
112
|
+
- name: robotCode
|
|
113
|
+
description: 机器人Code
|
|
114
|
+
type: string
|
|
115
|
+
required: true
|
|
116
|
+
position: body
|
|
117
|
+
system: ROBOT_CODE
|
|
118
|
+
- name: openConversationId
|
|
119
|
+
type: string
|
|
120
|
+
description: 会话ID。
|
|
121
|
+
position: body
|
|
122
|
+
required: true
|
|
123
|
+
- name: processQueryKeys
|
|
124
|
+
type: array
|
|
125
|
+
description: 要撤回的消息ID列表。
|
|
126
|
+
position: body
|
|
127
|
+
required: true
|
|
128
|
+
items:
|
|
129
|
+
type: string
|
|
130
|
+
|
|
131
|
+
requestTemplate:
|
|
132
|
+
url: https://api.dingtalk.com/v1.0/robot/groupMessages/recall
|
|
133
|
+
method: POST
|
|
134
|
+
headers:
|
|
135
|
+
- key: Content-Type
|
|
136
|
+
value: application/json
|
|
137
|
+
security:
|
|
138
|
+
id: DingTalkAuth
|
|
139
|
+
responseTemplate: { }
|
|
140
|
+
|
|
141
|
+
- name: batchSendUserMessageByRobot
|
|
142
|
+
description: 机器人批量给人发送消息
|
|
143
|
+
args:
|
|
144
|
+
- name: robotCode
|
|
145
|
+
description: 机器人Code
|
|
146
|
+
type: string
|
|
147
|
+
required: true
|
|
148
|
+
position: body
|
|
149
|
+
system: ROBOT_CODE
|
|
150
|
+
- name: userIds
|
|
151
|
+
type: array
|
|
152
|
+
description: 用户userId列表。
|
|
153
|
+
position: body
|
|
154
|
+
required: true
|
|
155
|
+
items:
|
|
156
|
+
type: string
|
|
157
|
+
- name: msgKey
|
|
158
|
+
type: string
|
|
159
|
+
description: 消息模板key,默认为"sampleMarkdown"。
|
|
160
|
+
position: body
|
|
161
|
+
- name: msgParam
|
|
162
|
+
type: string
|
|
163
|
+
description: 消息内容,为markdown格式。
|
|
164
|
+
position: body
|
|
165
|
+
required: true
|
|
166
|
+
|
|
167
|
+
requestTemplate:
|
|
168
|
+
url: https://api.dingtalk.com/v1.0/robot/oToMessages/batchSend
|
|
169
|
+
method: POST
|
|
170
|
+
headers:
|
|
171
|
+
- key: Content-Type
|
|
172
|
+
value: application/json
|
|
173
|
+
security:
|
|
174
|
+
id: DingTalkAuth
|
|
175
|
+
responseTemplate: { }
|
|
176
|
+
- name: batchRecallUserMessageByRobot
|
|
177
|
+
description: 批量撤回机器人给人发送的消息
|
|
178
|
+
args:
|
|
179
|
+
- name: robotCode
|
|
180
|
+
description: 机器人Code
|
|
181
|
+
type: string
|
|
182
|
+
required: true
|
|
183
|
+
position: body
|
|
184
|
+
system: ROBOT_CODE
|
|
185
|
+
- name: processQueryKeys
|
|
186
|
+
type: array
|
|
187
|
+
description: 要撤回的消息ID列表。
|
|
188
|
+
position: body
|
|
189
|
+
required: true
|
|
190
|
+
items:
|
|
191
|
+
type: string
|
|
192
|
+
|
|
193
|
+
requestTemplate:
|
|
194
|
+
url: https://api.dingtalk.com/v1.0/robot/oToMessages/batchRecall
|
|
195
|
+
method: POST
|
|
196
|
+
headers:
|
|
197
|
+
- key: Content-Type
|
|
198
|
+
value: application/json
|
|
199
|
+
security:
|
|
200
|
+
id: DingTalkAuth
|
|
201
|
+
responseTemplate: { }
|
|
202
|
+
- name: sendMessageByCustomRobot
|
|
203
|
+
description: 群自定义机器人发送群消息
|
|
204
|
+
args:
|
|
205
|
+
- name: markdown.title
|
|
206
|
+
type: string
|
|
207
|
+
description: 消息标题。
|
|
208
|
+
position: body
|
|
209
|
+
required: true
|
|
210
|
+
- name: markdown.text
|
|
211
|
+
type: string
|
|
212
|
+
description: 消息内容,markdown格式。
|
|
213
|
+
position: body
|
|
214
|
+
required: true
|
|
215
|
+
- name: at.isAtAll
|
|
216
|
+
type: boolean
|
|
217
|
+
default: false
|
|
218
|
+
description: 是否@所有人。
|
|
219
|
+
position: body
|
|
220
|
+
- name: at.atUserIds
|
|
221
|
+
type: array
|
|
222
|
+
items:
|
|
223
|
+
type: string
|
|
224
|
+
description: 被@的群成员userId。
|
|
225
|
+
position: body
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
requestTemplate:
|
|
229
|
+
url: https://oapi.dingtalk.com/robot/send?access_token={access_token}
|
|
230
|
+
method: POST
|
|
231
|
+
headers:
|
|
232
|
+
- key: Content-Type
|
|
233
|
+
value: application/json
|
|
234
|
+
responseTemplate: { }
|
|
@@ -36,7 +36,7 @@ export class DingTalkMCPServer {
|
|
|
36
36
|
try {
|
|
37
37
|
//激活的profile
|
|
38
38
|
const profiles = process.env.ACTIOVE_PROFILES;
|
|
39
|
-
|
|
39
|
+
let profiles_list = [];
|
|
40
40
|
if (profiles){
|
|
41
41
|
profiles_list = profiles.split(',');
|
|
42
42
|
}
|
|
@@ -52,7 +52,7 @@ export class DingTalkMCPServer {
|
|
|
52
52
|
if (!config) {
|
|
53
53
|
throw new Error('Config is empty');
|
|
54
54
|
}
|
|
55
|
-
if (profiles_list.includes(config.name) || (profiles_list.length == 0 && config.server.default_active)) {
|
|
55
|
+
if (profiles_list.includes(config.server.name) || (profiles_list.length == 0 && config.server.default_active)) {
|
|
56
56
|
|
|
57
57
|
(config.tools || []).forEach(tool => {
|
|
58
58
|
if (this.tools.includes(tool.name)) {
|
|
@@ -348,14 +348,19 @@ export class DingTalkMCPServer {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
else {
|
|
351
|
-
|
|
351
|
+
// 处理系统参数,如自动化机器人access_token
|
|
352
|
+
if (process.env[value]){
|
|
353
|
+
queryParams.set(key, process.env[value]);
|
|
354
|
+
}else {
|
|
355
|
+
queryParams.set(key, value);
|
|
356
|
+
}
|
|
352
357
|
}
|
|
353
358
|
}
|
|
354
359
|
const finalQuery = queryParams.toString();
|
|
355
360
|
return finalQuery ? `${baseUrl}?${finalQuery}` : baseUrl;
|
|
356
361
|
}
|
|
357
|
-
// 特殊处理oapi.dingtalk.com
|
|
358
|
-
if (url.includes('oapi.dingtalk.com') && this.accessToken) {
|
|
362
|
+
// 特殊处理oapi.dingtalk.com接口且配置了security(自定义机器人发消息不使用这个),将access_token作为URL参数传递
|
|
363
|
+
if (url.includes('oapi.dingtalk.com') && tool.requestTemplate.security && this.accessToken) {
|
|
359
364
|
const separator = url.includes('?') ? '&' : '?';
|
|
360
365
|
return `${url}${separator}access_token=${encodeURIComponent(this.accessToken)}`;
|
|
361
366
|
}
|
|
@@ -366,7 +371,7 @@ export class DingTalkMCPServer {
|
|
|
366
371
|
'Content-Type': 'application/json'
|
|
367
372
|
};
|
|
368
373
|
// 只有对新版API (api.dingtalk.com) 才添加token到header
|
|
369
|
-
if (tool.requestTemplate.url && !tool.requestTemplate.url.includes('oapi.dingtalk.com') && this.accessToken) {
|
|
374
|
+
if (tool.requestTemplate.url && !tool.requestTemplate.url.includes('oapi.dingtalk.com') && tool.requestTemplate.security && this.accessToken) {
|
|
370
375
|
headers['x-acs-dingtalk-access-token'] = this.accessToken;
|
|
371
376
|
}
|
|
372
377
|
if (tool.requestTemplate.headers) {
|
|
@@ -385,6 +390,9 @@ export class DingTalkMCPServer {
|
|
|
385
390
|
if (arg.position === 'body' && args[arg.name] !== undefined) {
|
|
386
391
|
// 系统参数,从环境变量读取
|
|
387
392
|
if (arg.system) {
|
|
393
|
+
if (!process.env[arg.system]){
|
|
394
|
+
throw new Error(`System parameter ${arg.system} is required, please check your environment variables`);
|
|
395
|
+
}
|
|
388
396
|
body[arg.name] = process.env[arg.system];
|
|
389
397
|
return;
|
|
390
398
|
}
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { DingTalkMCPServer } from './DingTalkMCPServer.js';
|
|
|
3
3
|
async function main() {
|
|
4
4
|
try {
|
|
5
5
|
// process.env.debug = true;
|
|
6
|
+
// process.env.ACTIOVE_PROFILES = "dingtalk-contacts,dingtalk-robot-send-message";
|
|
6
7
|
const server = new DingTalkMCPServer();
|
|
7
8
|
await server.run();
|
|
8
9
|
}
|