mcp-server-esa 1.0.6 → 1.0.8
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/LICENSE +21 -0
- package/dist/index.js +230 -110
- package/dist/index.mjs +226 -106
- package/dist/tools/list-esa-function.d.ts +17 -1
- package/dist/tools/routine.d.ts +8 -0
- package/dist/tools/site.d.ts +4 -4
- package/package.json +2 -2
- package/readme.md +54 -261
- package/readme_zh.md +63 -266
- package/src/index.ts +2 -2
- package/src/tools/commit.ts +1 -1
- package/src/tools/deploy.ts +1 -10
- package/src/tools/deployments.ts +2 -1
- package/src/tools/list-esa-function.ts +13 -9
- package/src/tools/record.ts +4 -3
- package/src/tools/route.ts +11 -9
- package/src/tools/routine.ts +158 -4
- package/src/tools/site.ts +10 -12
- package/src/utils/service.ts +0 -2
- package/abc.json +0 -8
- package/esa.toml +0 -8
- package/test.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alibaba Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -29,71 +29,6 @@ const esa20240910_namespaceObject = require("@alicloud/esa20240910");
|
|
|
29
29
|
var esa20240910_default = /*#__PURE__*/ __webpack_require__.n(esa20240910_namespaceObject);
|
|
30
30
|
const openapi_client_namespaceObject = require("@alicloud/openapi-client");
|
|
31
31
|
const tea_util_namespaceObject = require("@alicloud/tea-util");
|
|
32
|
-
const external_form_data_namespaceObject = require("form-data");
|
|
33
|
-
var external_form_data_default = /*#__PURE__*/ __webpack_require__.n(external_form_data_namespaceObject);
|
|
34
|
-
const external_node_fetch_namespaceObject = require("node-fetch");
|
|
35
|
-
var external_node_fetch_default = /*#__PURE__*/ __webpack_require__.n(external_node_fetch_namespaceObject);
|
|
36
|
-
function log(...args) {
|
|
37
|
-
const msg = `[DEBUG ${new Date().toISOString()}] ${args.join(' ')}\n`;
|
|
38
|
-
process.stderr.write(msg);
|
|
39
|
-
}
|
|
40
|
-
const uploadCodeToOSS = async (res, code)=>{
|
|
41
|
-
var _res_body;
|
|
42
|
-
const ossConfig = null == res ? void 0 : null === (_res_body = res.body) || void 0 === _res_body ? void 0 : _res_body.ossPostConfig;
|
|
43
|
-
if (200 !== res.statusCode || !ossConfig) return false;
|
|
44
|
-
const { OSSAccessKeyId, Signature, callback, Url, key, policy } = ossConfig;
|
|
45
|
-
const formData = new (external_form_data_default())();
|
|
46
|
-
formData.append('OSSAccessKeyId', OSSAccessKeyId);
|
|
47
|
-
formData.append('Signature', Signature);
|
|
48
|
-
formData.append('callback', callback);
|
|
49
|
-
formData.append("x:codeDescription", ossConfig["x:codeDescription"]);
|
|
50
|
-
formData.append('policy', policy);
|
|
51
|
-
formData.append('key', key);
|
|
52
|
-
formData.append('file', code);
|
|
53
|
-
const ossRes = await external_node_fetch_default()(Url, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
body: formData,
|
|
56
|
-
headers: formData.getHeaders()
|
|
57
|
-
});
|
|
58
|
-
return ossRes && 200 === ossRes.status;
|
|
59
|
-
};
|
|
60
|
-
const RuleMatchTypeHost = 'http.host';
|
|
61
|
-
const RuleMatchTypeUriPath = 'http.request.uri.path';
|
|
62
|
-
const RuleMatchOperatorEq = "eq";
|
|
63
|
-
const RuleMatchOperatorStartsWith = "starts_with";
|
|
64
|
-
const RuleMatchOperatorEndsWith = "ends_with";
|
|
65
|
-
const transferRouteToRuleString = (routePath)=>{
|
|
66
|
-
if (!routePath) return '';
|
|
67
|
-
const index = routePath.indexOf('/');
|
|
68
|
-
let host = '';
|
|
69
|
-
let uriPath = '';
|
|
70
|
-
if (index < 0) {
|
|
71
|
-
host = routePath;
|
|
72
|
-
uriPath = '/';
|
|
73
|
-
} else {
|
|
74
|
-
host = routePath.substring(0, index);
|
|
75
|
-
uriPath = routePath.substring(index);
|
|
76
|
-
}
|
|
77
|
-
let hostOperator = RuleMatchOperatorEq;
|
|
78
|
-
if (host.startsWith('*')) {
|
|
79
|
-
hostOperator = RuleMatchOperatorEndsWith;
|
|
80
|
-
host = host.replace(/\*/g, '');
|
|
81
|
-
}
|
|
82
|
-
let uriPathOperator = RuleMatchOperatorEq;
|
|
83
|
-
if (uriPath.endsWith('*')) {
|
|
84
|
-
uriPathOperator = RuleMatchOperatorStartsWith;
|
|
85
|
-
uriPath = uriPath.replace(/\*$/, '');
|
|
86
|
-
}
|
|
87
|
-
let ruleStr = '';
|
|
88
|
-
if (hostOperator === RuleMatchOperatorEq) {
|
|
89
|
-
if (uriPathOperator === RuleMatchOperatorEq) ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
90
|
-
else if (uriPathOperator === RuleMatchOperatorStartsWith) ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
91
|
-
} else if (hostOperator === RuleMatchOperatorEndsWith) {
|
|
92
|
-
if (uriPathOperator === RuleMatchOperatorEq) ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
93
|
-
else if (uriPathOperator === RuleMatchOperatorStartsWith) ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
94
|
-
}
|
|
95
|
-
return ruleStr;
|
|
96
|
-
};
|
|
97
32
|
function _define_property(obj, key, value) {
|
|
98
33
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
99
34
|
value: value,
|
|
@@ -117,7 +52,6 @@ class Client {
|
|
|
117
52
|
}
|
|
118
53
|
createRoutine(params) {
|
|
119
54
|
const request = new esa20240910_namespaceObject.CreateRoutineRequest(params);
|
|
120
|
-
log('Creating routine with parameters:', JSON.stringify(params));
|
|
121
55
|
return this.callApi(this.client.createRoutine.bind(this.client), request);
|
|
122
56
|
}
|
|
123
57
|
deleteRoutine(params) {
|
|
@@ -275,9 +209,74 @@ class Client {
|
|
|
275
209
|
}
|
|
276
210
|
}
|
|
277
211
|
const service = new Client();
|
|
212
|
+
const external_form_data_namespaceObject = require("form-data");
|
|
213
|
+
var external_form_data_default = /*#__PURE__*/ __webpack_require__.n(external_form_data_namespaceObject);
|
|
214
|
+
const external_node_fetch_namespaceObject = require("node-fetch");
|
|
215
|
+
var external_node_fetch_default = /*#__PURE__*/ __webpack_require__.n(external_node_fetch_namespaceObject);
|
|
216
|
+
function log(...args) {
|
|
217
|
+
const msg = `[DEBUG ${new Date().toISOString()}] ${args.join(' ')}\n`;
|
|
218
|
+
process.stderr.write(msg);
|
|
219
|
+
}
|
|
220
|
+
const uploadCodeToOSS = async (res, code)=>{
|
|
221
|
+
var _res_body;
|
|
222
|
+
const ossConfig = null == res ? void 0 : null === (_res_body = res.body) || void 0 === _res_body ? void 0 : _res_body.ossPostConfig;
|
|
223
|
+
if (200 !== res.statusCode || !ossConfig) return false;
|
|
224
|
+
const { OSSAccessKeyId, Signature, callback, Url, key, policy } = ossConfig;
|
|
225
|
+
const formData = new (external_form_data_default())();
|
|
226
|
+
formData.append('OSSAccessKeyId', OSSAccessKeyId);
|
|
227
|
+
formData.append('Signature', Signature);
|
|
228
|
+
formData.append('callback', callback);
|
|
229
|
+
formData.append("x:codeDescription", ossConfig["x:codeDescription"]);
|
|
230
|
+
formData.append('policy', policy);
|
|
231
|
+
formData.append('key', key);
|
|
232
|
+
formData.append('file', code);
|
|
233
|
+
const ossRes = await external_node_fetch_default()(Url, {
|
|
234
|
+
method: 'POST',
|
|
235
|
+
body: formData,
|
|
236
|
+
headers: formData.getHeaders()
|
|
237
|
+
});
|
|
238
|
+
return ossRes && 200 === ossRes.status;
|
|
239
|
+
};
|
|
240
|
+
const RuleMatchTypeHost = 'http.host';
|
|
241
|
+
const RuleMatchTypeUriPath = 'http.request.uri.path';
|
|
242
|
+
const RuleMatchOperatorEq = "eq";
|
|
243
|
+
const RuleMatchOperatorStartsWith = "starts_with";
|
|
244
|
+
const RuleMatchOperatorEndsWith = "ends_with";
|
|
245
|
+
const transferRouteToRuleString = (routePath)=>{
|
|
246
|
+
if (!routePath) return '';
|
|
247
|
+
const index = routePath.indexOf('/');
|
|
248
|
+
let host = '';
|
|
249
|
+
let uriPath = '';
|
|
250
|
+
if (index < 0) {
|
|
251
|
+
host = routePath;
|
|
252
|
+
uriPath = '/';
|
|
253
|
+
} else {
|
|
254
|
+
host = routePath.substring(0, index);
|
|
255
|
+
uriPath = routePath.substring(index);
|
|
256
|
+
}
|
|
257
|
+
let hostOperator = RuleMatchOperatorEq;
|
|
258
|
+
if (host.startsWith('*')) {
|
|
259
|
+
hostOperator = RuleMatchOperatorEndsWith;
|
|
260
|
+
host = host.replace(/\*/g, '');
|
|
261
|
+
}
|
|
262
|
+
let uriPathOperator = RuleMatchOperatorEq;
|
|
263
|
+
if (uriPath.endsWith('*')) {
|
|
264
|
+
uriPathOperator = RuleMatchOperatorStartsWith;
|
|
265
|
+
uriPath = uriPath.replace(/\*$/, '');
|
|
266
|
+
}
|
|
267
|
+
let ruleStr = '';
|
|
268
|
+
if (hostOperator === RuleMatchOperatorEq) {
|
|
269
|
+
if (uriPathOperator === RuleMatchOperatorEq) ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
270
|
+
else if (uriPathOperator === RuleMatchOperatorStartsWith) ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
271
|
+
} else if (hostOperator === RuleMatchOperatorEndsWith) {
|
|
272
|
+
if (uriPathOperator === RuleMatchOperatorEq) ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
273
|
+
else if (uriPathOperator === RuleMatchOperatorStartsWith) ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
274
|
+
}
|
|
275
|
+
return ruleStr;
|
|
276
|
+
};
|
|
278
277
|
const ROUTINE_CODE_COMMIT_TOOL = {
|
|
279
278
|
name: 'routine_code_commit',
|
|
280
|
-
description: '
|
|
279
|
+
description: 'Save a code version for future modifications or release within an Edge Routine (ER).',
|
|
281
280
|
inputSchema: {
|
|
282
281
|
type: 'object',
|
|
283
282
|
properties: {
|
|
@@ -348,7 +347,7 @@ const routine_code_commit = async (request)=>{
|
|
|
348
347
|
};
|
|
349
348
|
const ROUTINE_CODE_DEPLOY_TOOL = {
|
|
350
349
|
name: 'routine_code_deploy',
|
|
351
|
-
description: 'Deploy a
|
|
350
|
+
description: 'Deploy a selected code version to the staging or production environment. If version is not exist, should call routine_code_commit first',
|
|
352
351
|
inputSchema: {
|
|
353
352
|
type: 'object',
|
|
354
353
|
properties: {
|
|
@@ -363,14 +362,6 @@ const ROUTINE_CODE_DEPLOY_TOOL = {
|
|
|
363
362
|
env: {
|
|
364
363
|
type: 'string',
|
|
365
364
|
description: 'Environment of the routine, must be "production" or "staging". If the user has no special requirements, it will be deployed to the production environment by default'
|
|
366
|
-
},
|
|
367
|
-
canaryAreaList: {
|
|
368
|
-
type: 'array',
|
|
369
|
-
description: 'The regions for canary release, must be a valid region name. Need to call ListRoutineCanaryAreas method to get'
|
|
370
|
-
},
|
|
371
|
-
canaryCodeVersion: {
|
|
372
|
-
type: 'string',
|
|
373
|
-
description: 'Version of the routine, must be a valid semantic version'
|
|
374
365
|
}
|
|
375
366
|
},
|
|
376
367
|
required: [
|
|
@@ -433,7 +424,7 @@ const canary_area_list = async ()=>{
|
|
|
433
424
|
};
|
|
434
425
|
const DEPLOYMENT_DELETE_TOOL = {
|
|
435
426
|
name: 'deployment_delete',
|
|
436
|
-
description: 'Delete a
|
|
427
|
+
description: 'Delete a specified code version associated with an Edge Routine (ER).',
|
|
437
428
|
inputSchema: {
|
|
438
429
|
type: 'object',
|
|
439
430
|
properties: {
|
|
@@ -466,7 +457,7 @@ const deployment_delete = async (request)=>{
|
|
|
466
457
|
};
|
|
467
458
|
const ER_RECORD_CREATE_TOOL = {
|
|
468
459
|
name: 'er_record_create',
|
|
469
|
-
description: 'Create a record',
|
|
460
|
+
description: 'Create a new record associated with an Edge Routine (ER)',
|
|
470
461
|
inputSchema: {
|
|
471
462
|
type: 'object',
|
|
472
463
|
properties: {
|
|
@@ -492,7 +483,7 @@ const ER_RECORD_CREATE_TOOL = {
|
|
|
492
483
|
};
|
|
493
484
|
const ER_RECORD_DELETE_TOOL = {
|
|
494
485
|
name: 'er_record_delete',
|
|
495
|
-
description: 'Delete a record',
|
|
486
|
+
description: 'Delete a specified record associated with an Edge Routine (ER).',
|
|
496
487
|
inputSchema: {
|
|
497
488
|
type: 'object',
|
|
498
489
|
properties: {
|
|
@@ -522,7 +513,7 @@ const ER_RECORD_DELETE_TOOL = {
|
|
|
522
513
|
};
|
|
523
514
|
const ER_RECORD_LIST_TOOL = {
|
|
524
515
|
name: 'er_record_list',
|
|
525
|
-
description: 'List all records',
|
|
516
|
+
description: 'List all records associated with a specific Edge Routine (ER).',
|
|
526
517
|
inputSchema: {
|
|
527
518
|
type: 'object',
|
|
528
519
|
properties: {
|
|
@@ -586,7 +577,7 @@ const er_record_list = async (request)=>{
|
|
|
586
577
|
};
|
|
587
578
|
const ROUTE_CREATE_TOOL = {
|
|
588
579
|
name: 'route_create',
|
|
589
|
-
description: 'Create a
|
|
580
|
+
description: 'Create a new route associated with an Edge Routine (ER).',
|
|
590
581
|
inputSchema: {
|
|
591
582
|
type: 'object',
|
|
592
583
|
properties: {
|
|
@@ -604,7 +595,7 @@ const ROUTE_CREATE_TOOL = {
|
|
|
604
595
|
},
|
|
605
596
|
route: {
|
|
606
597
|
type: 'string',
|
|
607
|
-
description: 'The route of the route, if mode is simple, this field is required'
|
|
598
|
+
description: 'The route of the route, if mode is simple, this field is required. For example: test.example.com/*'
|
|
608
599
|
},
|
|
609
600
|
rule: {
|
|
610
601
|
type: 'string',
|
|
@@ -616,7 +607,7 @@ const ROUTE_CREATE_TOOL = {
|
|
|
616
607
|
},
|
|
617
608
|
routeName: {
|
|
618
609
|
type: 'string',
|
|
619
|
-
description: 'The name of the route, use to identify the route'
|
|
610
|
+
description: 'The name of the route, use to identify the route. For example: test-route'
|
|
620
611
|
},
|
|
621
612
|
bypass: {
|
|
622
613
|
type: 'enum',
|
|
@@ -652,7 +643,7 @@ const ROUTE_CREATE_TOOL = {
|
|
|
652
643
|
};
|
|
653
644
|
const ROUTE_UPDATE_TOOL = {
|
|
654
645
|
name: 'route_update',
|
|
655
|
-
description: '
|
|
646
|
+
description: 'Modify the configuration of an existing Edge Routine route.',
|
|
656
647
|
inputSchema: {
|
|
657
648
|
type: 'object',
|
|
658
649
|
properties: {
|
|
@@ -666,7 +657,7 @@ const ROUTE_UPDATE_TOOL = {
|
|
|
666
657
|
},
|
|
667
658
|
routeName: {
|
|
668
659
|
type: 'string',
|
|
669
|
-
description: 'The name of the route, use to identify the route'
|
|
660
|
+
description: 'The name of the route, use to identify the route.'
|
|
670
661
|
},
|
|
671
662
|
routeEnable: {
|
|
672
663
|
type: 'enum',
|
|
@@ -710,7 +701,7 @@ const ROUTE_UPDATE_TOOL = {
|
|
|
710
701
|
};
|
|
711
702
|
const ROUTE_DELETE_TOOL = {
|
|
712
703
|
name: 'route_delete',
|
|
713
|
-
description: 'Delete a
|
|
704
|
+
description: 'Delete a specified route associated with an Edge Routine (ER).',
|
|
714
705
|
inputSchema: {
|
|
715
706
|
type: 'object',
|
|
716
707
|
properties: {
|
|
@@ -731,7 +722,7 @@ const ROUTE_DELETE_TOOL = {
|
|
|
731
722
|
};
|
|
732
723
|
const ROUTE_GET_TOOL = {
|
|
733
724
|
name: 'route_get',
|
|
734
|
-
description: 'Get a
|
|
725
|
+
description: 'Get details of a specific route associated with an Edge Routine (ER).',
|
|
735
726
|
inputSchema: {
|
|
736
727
|
type: 'object',
|
|
737
728
|
properties: {
|
|
@@ -752,7 +743,7 @@ const ROUTE_GET_TOOL = {
|
|
|
752
743
|
};
|
|
753
744
|
const ROUTINE_ROUTE_LIST_TOOL = {
|
|
754
745
|
name: 'routine_route_list',
|
|
755
|
-
description: 'List all routes
|
|
746
|
+
description: 'List all routes associated with a specific Edge Routine (ER).',
|
|
756
747
|
inputSchema: {
|
|
757
748
|
type: 'object',
|
|
758
749
|
properties: {
|
|
@@ -780,7 +771,7 @@ const ROUTINE_ROUTE_LIST_TOOL = {
|
|
|
780
771
|
};
|
|
781
772
|
const SITE_ROUTE_LIST_TOOL = {
|
|
782
773
|
name: 'site_route_list',
|
|
783
|
-
description: 'List all routes
|
|
774
|
+
description: 'List all routes associated with a specific site.',
|
|
784
775
|
inputSchema: {
|
|
785
776
|
type: 'object',
|
|
786
777
|
properties: {
|
|
@@ -914,9 +905,34 @@ const site_route_list = async (request)=>{
|
|
|
914
905
|
success: true
|
|
915
906
|
};
|
|
916
907
|
};
|
|
908
|
+
const HTML_DEPLOY_TOOL = {
|
|
909
|
+
name: 'html_deploy',
|
|
910
|
+
description: 'Quickly deploy an HTML page to ESA Edge Routine (ER) and return a default access URL to the user.',
|
|
911
|
+
inputSchema: {
|
|
912
|
+
type: 'object',
|
|
913
|
+
properties: {
|
|
914
|
+
name: {
|
|
915
|
+
type: 'string',
|
|
916
|
+
description: 'The name of the routine, supports lowercase English letters, numbers, and hyphens, must start with a lowercase letter, and must be at least 2 characters long. For example: hello-world'
|
|
917
|
+
},
|
|
918
|
+
html: {
|
|
919
|
+
type: 'string',
|
|
920
|
+
description: 'An HTML string which user want to deploy. For example: <html><body>Hello World</body></html>'
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
required: [
|
|
924
|
+
'name',
|
|
925
|
+
'html'
|
|
926
|
+
]
|
|
927
|
+
},
|
|
928
|
+
annotations: {
|
|
929
|
+
readOnlyHint: false,
|
|
930
|
+
idempotentHint: false
|
|
931
|
+
}
|
|
932
|
+
};
|
|
917
933
|
const ROUTINE_CREATE_TOOL = {
|
|
918
934
|
name: 'routine_create',
|
|
919
|
-
description: 'Create a
|
|
935
|
+
description: 'Create a new Edge Routine (ER) in your Alibaba Cloud account.',
|
|
920
936
|
inputSchema: {
|
|
921
937
|
type: 'object',
|
|
922
938
|
properties: {
|
|
@@ -941,7 +957,7 @@ const ROUTINE_CREATE_TOOL = {
|
|
|
941
957
|
};
|
|
942
958
|
const ROUTINE_DELETE_TOOL = {
|
|
943
959
|
name: 'routine_delete',
|
|
944
|
-
description: 'Delete
|
|
960
|
+
description: 'Delete an existing Edge Routine (ER) from your Alibaba Cloud account.',
|
|
945
961
|
inputSchema: {
|
|
946
962
|
type: 'object',
|
|
947
963
|
properties: {
|
|
@@ -957,7 +973,7 @@ const ROUTINE_DELETE_TOOL = {
|
|
|
957
973
|
};
|
|
958
974
|
const ROUTINE_LIST_TOOL = {
|
|
959
975
|
name: 'routine_list',
|
|
960
|
-
description: 'List all
|
|
976
|
+
description: 'List all Edge Routines (ERs) in your Alibaba Cloud account.',
|
|
961
977
|
inputSchema: {
|
|
962
978
|
type: 'object',
|
|
963
979
|
properties: {}
|
|
@@ -965,7 +981,7 @@ const ROUTINE_LIST_TOOL = {
|
|
|
965
981
|
};
|
|
966
982
|
const ROUTINE_GET_TOOL = {
|
|
967
983
|
name: 'routine_get',
|
|
968
|
-
description: 'Get a
|
|
984
|
+
description: 'Get a the details of a Edge Routine (ER).',
|
|
969
985
|
inputSchema: {
|
|
970
986
|
type: 'object',
|
|
971
987
|
properties: {
|
|
@@ -979,6 +995,108 @@ const ROUTINE_GET_TOOL = {
|
|
|
979
995
|
]
|
|
980
996
|
}
|
|
981
997
|
};
|
|
998
|
+
const html_deploy = async (request)=>{
|
|
999
|
+
var _request_params_arguments, _request_params, _request_params_arguments1, _request_params1, _createRoutineRes_body;
|
|
1000
|
+
const html = (null == request ? void 0 : null === (_request_params = request.params) || void 0 === _request_params ? void 0 : null === (_request_params_arguments = _request_params.arguments) || void 0 === _request_params_arguments ? void 0 : _request_params_arguments.html).replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
1001
|
+
const code = `const html = \`${html}\`;
|
|
1002
|
+
|
|
1003
|
+
async function handleRequest(request) {
|
|
1004
|
+
return new Response(html, {
|
|
1005
|
+
headers: {
|
|
1006
|
+
"content-type": "text/html;charset=UTF-8",
|
|
1007
|
+
},
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
export default {
|
|
1012
|
+
async fetch(request) {
|
|
1013
|
+
return handleRequest(request);
|
|
1014
|
+
},
|
|
1015
|
+
};
|
|
1016
|
+
`;
|
|
1017
|
+
const createRoutineRes = await service.createRoutine({
|
|
1018
|
+
name: (null == request ? void 0 : null === (_request_params1 = request.params) || void 0 === _request_params1 ? void 0 : null === (_request_params_arguments1 = _request_params1.arguments) || void 0 === _request_params_arguments1 ? void 0 : _request_params_arguments1.name) || '',
|
|
1019
|
+
code: code
|
|
1020
|
+
});
|
|
1021
|
+
if (200 !== createRoutineRes.statusCode || (null === (_createRoutineRes_body = createRoutineRes.body) || void 0 === _createRoutineRes_body ? void 0 : _createRoutineRes_body.status) !== 'OK') return {
|
|
1022
|
+
content: [
|
|
1023
|
+
{
|
|
1024
|
+
type: 'text',
|
|
1025
|
+
text: `Failed to create routine. ${JSON.stringify(createRoutineRes)}`
|
|
1026
|
+
}
|
|
1027
|
+
],
|
|
1028
|
+
success: false
|
|
1029
|
+
};
|
|
1030
|
+
{
|
|
1031
|
+
var _getOssInfoRes_body_ossPostConfig, _getOssInfoRes_body;
|
|
1032
|
+
const getOssInfoRes = await service.getRoutineStagingCodeUploadInfo(request.params.arguments);
|
|
1033
|
+
if (!getOssInfoRes || (null == getOssInfoRes ? void 0 : getOssInfoRes.statusCode) !== 200 || !(null == getOssInfoRes ? void 0 : null === (_getOssInfoRes_body = getOssInfoRes.body) || void 0 === _getOssInfoRes_body ? void 0 : null === (_getOssInfoRes_body_ossPostConfig = _getOssInfoRes_body.ossPostConfig) || void 0 === _getOssInfoRes_body_ossPostConfig ? void 0 : _getOssInfoRes_body_ossPostConfig.OSSAccessKeyId)) return {
|
|
1034
|
+
content: [
|
|
1035
|
+
{
|
|
1036
|
+
type: 'text',
|
|
1037
|
+
text: `Failed to get routine staging code upload info. ${JSON.stringify(getOssInfoRes)}`
|
|
1038
|
+
}
|
|
1039
|
+
],
|
|
1040
|
+
success: false
|
|
1041
|
+
};
|
|
1042
|
+
{
|
|
1043
|
+
const uploadRes = await uploadCodeToOSS(getOssInfoRes, code);
|
|
1044
|
+
if (true !== uploadRes) return {
|
|
1045
|
+
content: [
|
|
1046
|
+
{
|
|
1047
|
+
type: 'text',
|
|
1048
|
+
text: `Failed to upload code to OSS. ${uploadRes}`
|
|
1049
|
+
}
|
|
1050
|
+
],
|
|
1051
|
+
success: false
|
|
1052
|
+
};
|
|
1053
|
+
{
|
|
1054
|
+
const commitRes = await service.commitRoutineStagingCode(request.params.arguments);
|
|
1055
|
+
if (200 !== commitRes.statusCode) return {
|
|
1056
|
+
content: [
|
|
1057
|
+
{
|
|
1058
|
+
type: 'text',
|
|
1059
|
+
text: `Failed to commit routine staging code. ${JSON.stringify(commitRes)}`
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
success: false
|
|
1063
|
+
};
|
|
1064
|
+
{
|
|
1065
|
+
var _request_params_arguments2, _request_params2, _commitRes_body;
|
|
1066
|
+
const deployRes = await service.publishRoutineCodeVersion({
|
|
1067
|
+
name: (null == request ? void 0 : null === (_request_params2 = request.params) || void 0 === _request_params2 ? void 0 : null === (_request_params_arguments2 = _request_params2.arguments) || void 0 === _request_params_arguments2 ? void 0 : _request_params_arguments2.name) || '',
|
|
1068
|
+
env: 'production',
|
|
1069
|
+
codeVersion: null == commitRes ? void 0 : null === (_commitRes_body = commitRes.body) || void 0 === _commitRes_body ? void 0 : _commitRes_body.codeVersion
|
|
1070
|
+
});
|
|
1071
|
+
if (200 !== deployRes.statusCode) return {
|
|
1072
|
+
content: [
|
|
1073
|
+
{
|
|
1074
|
+
type: 'text',
|
|
1075
|
+
text: `Failed to get routine. ${JSON.stringify(deployRes)}`
|
|
1076
|
+
}
|
|
1077
|
+
],
|
|
1078
|
+
success: false
|
|
1079
|
+
};
|
|
1080
|
+
{
|
|
1081
|
+
var _request_params_arguments3, _request_params3;
|
|
1082
|
+
const res = await service.getRoutine({
|
|
1083
|
+
name: (null == request ? void 0 : null === (_request_params3 = request.params) || void 0 === _request_params3 ? void 0 : null === (_request_params_arguments3 = _request_params3.arguments) || void 0 === _request_params_arguments3 ? void 0 : _request_params_arguments3.name) || ''
|
|
1084
|
+
});
|
|
1085
|
+
return {
|
|
1086
|
+
content: [
|
|
1087
|
+
{
|
|
1088
|
+
type: 'text',
|
|
1089
|
+
text: JSON.stringify(res)
|
|
1090
|
+
}
|
|
1091
|
+
],
|
|
1092
|
+
success: true
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
982
1100
|
const routine_create = async (request)=>{
|
|
983
1101
|
const res = await service.createRoutine(request.params.arguments);
|
|
984
1102
|
return {
|
|
@@ -1037,7 +1155,7 @@ const SITE_ACTIVE_LIST_TOOL = {
|
|
|
1037
1155
|
};
|
|
1038
1156
|
const SITE_MATCH_TOOL = {
|
|
1039
1157
|
name: 'site_match',
|
|
1040
|
-
description: '
|
|
1158
|
+
description: 'Identify which site in the account matches the provided input criteria.',
|
|
1041
1159
|
inputSchema: {
|
|
1042
1160
|
type: 'object',
|
|
1043
1161
|
properties: {
|
|
@@ -1051,9 +1169,9 @@ const SITE_MATCH_TOOL = {
|
|
|
1051
1169
|
]
|
|
1052
1170
|
}
|
|
1053
1171
|
};
|
|
1054
|
-
const
|
|
1055
|
-
name: '
|
|
1056
|
-
description: 'Create
|
|
1172
|
+
const SITE_DNS_A_RECORD_CREATE_TOOL = {
|
|
1173
|
+
name: 'site_dns_a_record_create',
|
|
1174
|
+
description: 'Create an A DNS record for a specified site.',
|
|
1057
1175
|
inputSchema: {
|
|
1058
1176
|
type: 'object',
|
|
1059
1177
|
properties: {
|
|
@@ -1093,9 +1211,9 @@ const SITE_DNS_TYPE_A_RECORD_CREATE_TOOL = {
|
|
|
1093
1211
|
]
|
|
1094
1212
|
}
|
|
1095
1213
|
};
|
|
1096
|
-
const
|
|
1097
|
-
name: '
|
|
1098
|
-
description: 'Create a CNAME
|
|
1214
|
+
const SITE_DNS_CNAME_RECORD_CREATE_TOOL = {
|
|
1215
|
+
name: 'site_dns_cname_record_create',
|
|
1216
|
+
description: 'Create a CNAME DNS record for a specified site.',
|
|
1099
1217
|
inputSchema: {
|
|
1100
1218
|
type: 'object',
|
|
1101
1219
|
properties: {
|
|
@@ -1137,7 +1255,7 @@ const SITE_DNS_CNAME_DOMAIN_RECORD_CREATE_TOOL = {
|
|
|
1137
1255
|
};
|
|
1138
1256
|
const SITE_RECORD_LIST_TOOL = {
|
|
1139
1257
|
name: 'site_record_list',
|
|
1140
|
-
description: 'List
|
|
1258
|
+
description: 'List DNS records associated with a specific site.',
|
|
1141
1259
|
inputSchema: {
|
|
1142
1260
|
type: 'object',
|
|
1143
1261
|
properties: {
|
|
@@ -1148,7 +1266,7 @@ const SITE_RECORD_LIST_TOOL = {
|
|
|
1148
1266
|
}
|
|
1149
1267
|
}
|
|
1150
1268
|
};
|
|
1151
|
-
const
|
|
1269
|
+
const site_dns_a_record_create = async (request)=>{
|
|
1152
1270
|
const res = await service.createRecord({
|
|
1153
1271
|
ttl: 1,
|
|
1154
1272
|
proxied: true,
|
|
@@ -1166,7 +1284,7 @@ const site_dns_type_a_record_create = async (request)=>{
|
|
|
1166
1284
|
success: true
|
|
1167
1285
|
};
|
|
1168
1286
|
};
|
|
1169
|
-
const
|
|
1287
|
+
const site_dns_cname_record_create = async (request)=>{
|
|
1170
1288
|
const res = await service.createRecord({
|
|
1171
1289
|
ttl: 1,
|
|
1172
1290
|
proxied: true,
|
|
@@ -1234,6 +1352,7 @@ const site_match = async (request)=>{
|
|
|
1234
1352
|
};
|
|
1235
1353
|
};
|
|
1236
1354
|
const ESA_OPENAPI_ER_LIST = [
|
|
1355
|
+
HTML_DEPLOY_TOOL,
|
|
1237
1356
|
ROUTINE_CREATE_TOOL,
|
|
1238
1357
|
ROUTINE_DELETE_TOOL,
|
|
1239
1358
|
ROUTINE_LIST_TOOL,
|
|
@@ -1253,16 +1372,16 @@ const ESA_OPENAPI_ER_LIST = [
|
|
|
1253
1372
|
ER_RECORD_CREATE_TOOL,
|
|
1254
1373
|
ER_RECORD_DELETE_TOOL,
|
|
1255
1374
|
ER_RECORD_LIST_TOOL,
|
|
1256
|
-
|
|
1257
|
-
|
|
1375
|
+
SITE_DNS_A_RECORD_CREATE_TOOL,
|
|
1376
|
+
SITE_DNS_CNAME_RECORD_CREATE_TOOL,
|
|
1258
1377
|
SITE_RECORD_LIST_TOOL
|
|
1259
1378
|
];
|
|
1260
1379
|
const ESA_OPENAPI_LIST = [
|
|
1261
1380
|
...ESA_OPENAPI_ER_LIST
|
|
1262
1381
|
];
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1382
|
+
const esaHandlers = {
|
|
1383
|
+
site_dns_a_record_create: site_dns_a_record_create,
|
|
1384
|
+
site_dns_cname_record_create: site_dns_cname_record_create,
|
|
1266
1385
|
site_active_list: site_active_list,
|
|
1267
1386
|
site_match: site_match,
|
|
1268
1387
|
site_route_list: site_route_list,
|
|
@@ -1282,7 +1401,8 @@ const routineHandlers = {
|
|
|
1282
1401
|
route_get: route_get,
|
|
1283
1402
|
er_record_create: er_record_create,
|
|
1284
1403
|
er_record_delete: er_record_delete,
|
|
1285
|
-
er_record_list: er_record_list
|
|
1404
|
+
er_record_list: er_record_list,
|
|
1405
|
+
html_deploy: html_deploy
|
|
1286
1406
|
};
|
|
1287
1407
|
const server = new index_js_namespaceObject.Server({
|
|
1288
1408
|
name: 'esa-server',
|
|
@@ -1298,7 +1418,7 @@ server.setRequestHandler(types_js_namespaceObject.ListToolsRequestSchema, async
|
|
|
1298
1418
|
server.setRequestHandler(types_js_namespaceObject.CallToolRequestSchema, async (request)=>{
|
|
1299
1419
|
const toolName = request.params.name;
|
|
1300
1420
|
log('Received tool call:', toolName, 'Params:', JSON.stringify(request.params));
|
|
1301
|
-
return await
|
|
1421
|
+
return await esaHandlers[toolName](request);
|
|
1302
1422
|
});
|
|
1303
1423
|
async function main() {
|
|
1304
1424
|
const transport = new stdio_js_namespaceObject.StdioServerTransport();
|