dingtalk-mcp 1.0.3 → 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.
@@ -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: sendDINGByRobot
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: recallDING
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: { }
@@ -348,14 +348,19 @@ export class DingTalkMCPServer {
348
348
  }
349
349
  }
350
350
  else {
351
- queryParams.set(key, value);
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接口,将access_token作为URL参数传递
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dingtalk-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "DingTalk MCP Server - A TypeScript-based MCP server for DingTalk integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",