mcp-server-esa 1.0.0

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.
Files changed (46) hide show
  1. package/.prettierignore +4 -0
  2. package/.prettierrc +3 -0
  3. package/abc.json +8 -0
  4. package/dist/721.js +305 -0
  5. package/dist/721.mjs +304 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +7475 -0
  8. package/dist/index.js.LICENSE.txt +27 -0
  9. package/dist/index.mjs +7448 -0
  10. package/dist/index.mjs.LICENSE.txt +27 -0
  11. package/dist/tools/commit.d.ts +9 -0
  12. package/dist/tools/deploy.d.ts +17 -0
  13. package/dist/tools/deployments.d.ts +9 -0
  14. package/dist/tools/list-esa-function.d.ts +26 -0
  15. package/dist/tools/record.d.ts +25 -0
  16. package/dist/tools/route.d.ts +49 -0
  17. package/dist/tools/routine.d.ts +33 -0
  18. package/dist/tools/site.d.ts +17 -0
  19. package/dist/utils/helpers.d.ts +25 -0
  20. package/dist/utils/service.d.ts +39 -0
  21. package/dist/utils/types.d.ts +59 -0
  22. package/esa.toml +8 -0
  23. package/eslint.config.mjs +10 -0
  24. package/image/readme/1744114566511.png +0 -0
  25. package/image/readme/1744114625974.png +0 -0
  26. package/image/readme/1744165412296.png +0 -0
  27. package/image/readme/1744168230082.gif +0 -0
  28. package/image/readme/1744168440370.gif +0 -0
  29. package/image/readme/1744168966418.gif +0 -0
  30. package/package.json +46 -0
  31. package/readme.md +281 -0
  32. package/rslib.config.ts +15 -0
  33. package/src/index.ts +48 -0
  34. package/src/tools/commit.ts +90 -0
  35. package/src/tools/deploy.ts +103 -0
  36. package/src/tools/deployments.ts +37 -0
  37. package/src/tools/list-esa-function.ts +92 -0
  38. package/src/tools/record.ts +115 -0
  39. package/src/tools/route.ts +314 -0
  40. package/src/tools/routine.ts +130 -0
  41. package/src/tools/site.ts +61 -0
  42. package/src/utils/helpers.ts +181 -0
  43. package/src/utils/service.ts +337 -0
  44. package/src/utils/types.ts +71 -0
  45. package/test.js +0 -0
  46. package/tsconfig.json +16 -0
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * mime-db
3
+ * Copyright(c) 2014 Jonathan Ong
4
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ /*!
9
+ * mime-types
10
+ * Copyright(c) 2014 Jonathan Ong
11
+ * Copyright(c) 2015 Douglas Christopher Wilson
12
+ * MIT Licensed
13
+ */
14
+
15
+ /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
16
+
17
+ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
18
+
19
+ /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
20
+
21
+ /**
22
+ * @license
23
+ * web-streams-polyfill v3.3.3
24
+ * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
25
+ * This code is released under the MIT license.
26
+ * SPDX-License-Identifier: MIT
27
+ */
@@ -0,0 +1,9 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const ROUTINE_CODE_COMMIT_TOOL: Tool;
3
+ export declare const routine_code_commit: (request: CallToolRequest) => Promise<{
4
+ content: {
5
+ type: string;
6
+ text: string;
7
+ }[];
8
+ success: boolean;
9
+ }>;
@@ -0,0 +1,17 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const ROUTINE_CODE_DEPLOY_TOOL: Tool;
3
+ export declare const CANARY_AREA_LIST: Tool;
4
+ export declare const routine_code_deploy: (request: CallToolRequest) => Promise<{
5
+ content: {
6
+ type: string;
7
+ text: string;
8
+ }[];
9
+ success: boolean;
10
+ }>;
11
+ export declare const canary_area_list: () => Promise<{
12
+ content: {
13
+ type: string;
14
+ text: string;
15
+ }[];
16
+ success: boolean;
17
+ }>;
@@ -0,0 +1,9 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const DEPLOYMENT_DELETE_TOOL: Tool;
3
+ export declare const deployment_delete: (request: CallToolRequest) => Promise<{
4
+ content: {
5
+ type: string;
6
+ text: string;
7
+ }[];
8
+ success: boolean;
9
+ }>;
@@ -0,0 +1,26 @@
1
+ import { ToolHandlers } from '../utils/types';
2
+ export declare const ESA_OPENAPI_ER_LIST: {
3
+ [x: string]: unknown;
4
+ name: string;
5
+ inputSchema: {
6
+ [x: string]: unknown;
7
+ type: "object";
8
+ properties?: {
9
+ [x: string]: unknown;
10
+ } | undefined;
11
+ };
12
+ description?: string | undefined;
13
+ }[];
14
+ export declare const ESA_OPENAPI_LIST: {
15
+ [x: string]: unknown;
16
+ name: string;
17
+ inputSchema: {
18
+ [x: string]: unknown;
19
+ type: "object";
20
+ properties?: {
21
+ [x: string]: unknown;
22
+ } | undefined;
23
+ };
24
+ description?: string | undefined;
25
+ }[];
26
+ export declare const routineHandlers: ToolHandlers;
@@ -0,0 +1,25 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const RECORD_CREATE_TOOL: Tool;
3
+ export declare const RECORD_DELETE_TOOL: Tool;
4
+ export declare const RECORD_LIST_TOOL: Tool;
5
+ export declare const record_create: (request: CallToolRequest) => Promise<{
6
+ content: {
7
+ type: string;
8
+ text: string;
9
+ }[];
10
+ success: boolean;
11
+ }>;
12
+ export declare const record_delete: (request: CallToolRequest) => Promise<{
13
+ content: {
14
+ type: string;
15
+ text: string;
16
+ }[];
17
+ success: boolean;
18
+ }>;
19
+ export declare const record_list: (request: CallToolRequest) => Promise<{
20
+ content: {
21
+ type: string;
22
+ text: string;
23
+ }[];
24
+ success: boolean;
25
+ }>;
@@ -0,0 +1,49 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const ROUTE_CREATE_TOOL: Tool;
3
+ export declare const ROUTE_UPDATE_TOOL: Tool;
4
+ export declare const ROUTE_DELETE_TOOL: Tool;
5
+ export declare const ROUTE_GET_TOOL: Tool;
6
+ export declare const ROUTINE_ROUTE_LIST_TOOL: Tool;
7
+ export declare const SITE_ROUTE_LIST_TOOL: Tool;
8
+ export declare const route_create: (request: CallToolRequest) => Promise<{
9
+ content: {
10
+ type: string;
11
+ text: string;
12
+ }[];
13
+ success: boolean;
14
+ }>;
15
+ export declare const route_delete: (request: CallToolRequest) => Promise<{
16
+ content: {
17
+ type: string;
18
+ text: string;
19
+ }[];
20
+ success: boolean;
21
+ }>;
22
+ export declare const route_update: (request: CallToolRequest) => Promise<{
23
+ content: {
24
+ type: string;
25
+ text: string;
26
+ }[];
27
+ success: boolean;
28
+ }>;
29
+ export declare const route_get: (request: CallToolRequest) => Promise<{
30
+ content: {
31
+ type: string;
32
+ text: string;
33
+ }[];
34
+ success: boolean;
35
+ }>;
36
+ export declare const routine_route_list: (request: CallToolRequest) => Promise<{
37
+ content: {
38
+ type: string;
39
+ text: string;
40
+ }[];
41
+ success: boolean;
42
+ }>;
43
+ export declare const site_route_list: (request: CallToolRequest) => Promise<{
44
+ content: {
45
+ type: string;
46
+ text: string;
47
+ }[];
48
+ success: boolean;
49
+ }>;
@@ -0,0 +1,33 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const ROUTINE_CREATE_TOOL: Tool;
3
+ export declare const ROUTINE_DELETE_TOOL: Tool;
4
+ export declare const ROUTINE_LIST_TOOL: Tool;
5
+ export declare const ROUTINE_GET_TOOL: Tool;
6
+ export declare const routine_create: (request: CallToolRequest) => Promise<{
7
+ content: {
8
+ type: string;
9
+ text: string;
10
+ }[];
11
+ success: boolean;
12
+ }>;
13
+ export declare const routine_delete: (request: CallToolRequest) => Promise<{
14
+ content: {
15
+ type: string;
16
+ text: string;
17
+ }[];
18
+ success: boolean;
19
+ }>;
20
+ export declare const routine_list: () => Promise<{
21
+ content: {
22
+ type: string;
23
+ text: string;
24
+ }[];
25
+ success: boolean;
26
+ }>;
27
+ export declare const routine_get: (request: CallToolRequest) => Promise<{
28
+ content: {
29
+ type: string;
30
+ text: string;
31
+ }[];
32
+ success: boolean;
33
+ }>;
@@ -0,0 +1,17 @@
1
+ import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const SITE_ACTIVE_LIST_TOOL: Tool;
3
+ export declare const SITE_MATCH_TOOL: Tool;
4
+ export declare const site_active_list: () => Promise<{
5
+ content: {
6
+ type: string;
7
+ text: string;
8
+ }[];
9
+ success: boolean;
10
+ }>;
11
+ export declare const site_match: (request: CallToolRequest) => Promise<{
12
+ content: {
13
+ type: string;
14
+ text: string;
15
+ }[];
16
+ success: boolean;
17
+ }>;
@@ -0,0 +1,25 @@
1
+ import { GetRoutineStagingCodeUploadInfoResponse } from '@alicloud/esa20240910';
2
+ export declare function log(...args: unknown[]): void;
3
+ export declare const uploadCodeToOSS: (res: GetRoutineStagingCodeUploadInfoResponse, code: string) => Promise<boolean>;
4
+ export declare enum OPERATOR_ENUM {
5
+ Eq = "eq",
6
+ Ne = "ne",
7
+ Contains = "contains",
8
+ Negate_Contains = "negate_contains",
9
+ StartsWith = "starts_with",
10
+ Negate_StartsWith = "negate_starts_with",
11
+ EndsWith = "ends_with",
12
+ Negate_EndsWith = "negate_ends_with",
13
+ Matches = "matches",
14
+ Negate_Matches = "negate_matches",
15
+ In = "in",
16
+ Negate_In = "negate_in",
17
+ Gt = "gt",
18
+ Lt = "lt",
19
+ Ge = "ge",
20
+ Le = "le",
21
+ InList = "in_list",
22
+ Negate_InList = "negate_in_list"
23
+ }
24
+ export declare const transferRouteToRuleString: (routePath: string) => string;
25
+ export declare const transferRuleStringToRoute: (ruleStr: string) => string;
@@ -0,0 +1,39 @@
1
+ import ESA, { CommitRoutineStagingCodeRequest, CommitRoutineStagingCodeResponse, CreateRoutineRelatedRecordRequest, CreateRoutineRelatedRecordResponse, CreateRoutineRequest, CreateRoutineResponse, CreateRoutineRouteRequest, CreateRoutineRouteResponse, DeleteRoutineCodeVersionRequest, DeleteRoutineCodeVersionResponse, DeleteRoutineRelatedRecordRequest, DeleteRoutineRelatedRecordResponse, DeleteRoutineRequest, DeleteRoutineResponse, DeleteRoutineRouteRequest, DeleteRoutineRouteResponse, GetRoutineRequest, GetRoutineResponse, GetRoutineRouteRequest, GetRoutineRouteResponse, GetRoutineStagingCodeUploadInfoRequest, GetRoutineStagingCodeUploadInfoResponse, ListRoutineRoutesRequest, ListRoutineRoutesResponse, ListSiteRoutesRequest, ListSiteRoutesResponse, ListSitesRequest, ListSitesResponse, PublishRoutineCodeVersionRequest, PublishRoutineCodeVersionResponse, UpdateRoutineRouteRequest, UpdateRoutineRouteResponse } from '@alicloud/esa20240910';
2
+ import * as $Util from '@alicloud/tea-util';
3
+ import { CliConfig, GetMatchSiteRequest, ListRoutineRelatedRecordsRequest } from './types';
4
+ export interface ApiMethod<RequestType, ResponseType> {
5
+ (runtime: $Util.RuntimeOptions): Promise<ResponseType>;
6
+ (request: RequestType, runtime: $Util.RuntimeOptions): Promise<ResponseType>;
7
+ }
8
+ declare class Client {
9
+ client: ESA;
10
+ constructor();
11
+ static createClient(config: CliConfig): ESA;
12
+ callApi: <RequestType, ResponseType>(action: ApiMethod<RequestType, ResponseType>, request?: RequestType) => Promise<ResponseType>;
13
+ createRoutine(params: CreateRoutineRequest): Promise<CreateRoutineResponse>;
14
+ deleteRoutine(params: DeleteRoutineRequest): Promise<DeleteRoutineResponse>;
15
+ getRoutine(params: GetRoutineRequest): Promise<GetRoutineResponse>;
16
+ getRoutineUserInfo(): Promise<import("@alicloud/esa20240910").GetRoutineUserInfoResponse>;
17
+ getRoutineStagingCodeUploadInfo(params: GetRoutineStagingCodeUploadInfoRequest): Promise<GetRoutineStagingCodeUploadInfoResponse>;
18
+ commitRoutineStagingCode(params: CommitRoutineStagingCodeRequest): Promise<CommitRoutineStagingCodeResponse>;
19
+ publishRoutineCodeVersion(params: PublishRoutineCodeVersionRequest): Promise<PublishRoutineCodeVersionResponse>;
20
+ listRoutineCanaryAreas(): Promise<import("@alicloud/esa20240910").ListRoutineCanaryAreasResponse>;
21
+ listSites(params: ListSitesRequest): Promise<ListSitesResponse>;
22
+ deleteRoutineCodeVersion(params: DeleteRoutineCodeVersionRequest): Promise<DeleteRoutineCodeVersionResponse>;
23
+ createRoutineRelatedRecord(params: CreateRoutineRelatedRecordRequest): Promise<CreateRoutineRelatedRecordResponse>;
24
+ createRoutineRoute(params: CreateRoutineRouteRequest): Promise<CreateRoutineRouteResponse>;
25
+ deleteRoutineRoute(params: DeleteRoutineRouteRequest): Promise<DeleteRoutineRouteResponse>;
26
+ getRoutineRoute(params: GetRoutineRouteRequest): Promise<GetRoutineRouteResponse>;
27
+ listSiteRoutes(params: ListSiteRoutesRequest): Promise<ListSiteRoutesResponse>;
28
+ listRoutineRoutes(params: ListRoutineRoutesRequest): Promise<ListRoutineRoutesResponse>;
29
+ updateRoutineRoute(params: UpdateRoutineRouteRequest): Promise<UpdateRoutineRouteResponse>;
30
+ deleteRoutineRelatedRecord(params: DeleteRoutineRelatedRecordRequest): Promise<DeleteRoutineRelatedRecordResponse>;
31
+ getMatchSite(requestParams: GetMatchSiteRequest): Promise<{
32
+ [key: string]: any;
33
+ }>;
34
+ listRoutineRelatedRecords(requestParams: ListRoutineRelatedRecordsRequest): Promise<{
35
+ [key: string]: any;
36
+ }>;
37
+ }
38
+ declare const _default: Client;
39
+ export default _default;
@@ -0,0 +1,59 @@
1
+ import z from 'zod';
2
+ import { Result, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
3
+ import { CreateRoutineRouteRequest } from '@alicloud/esa20240910';
4
+ export type ToolHandlers = Record<string, (request: z.infer<typeof CallToolRequestSchema>) => Promise<Result>>;
5
+ export interface IOssConfig {
6
+ OSSAccessKeyId: string;
7
+ Signature: string;
8
+ Url: string;
9
+ callback: string;
10
+ key: string;
11
+ policy: string;
12
+ 'x:codeDescription': string;
13
+ }
14
+ export declare class CreateRoutineRouteRequestExt extends CreateRoutineRouteRequest {
15
+ mode: 'simple' | 'custom';
16
+ constructor(params: CreateRoutineRouteRequest);
17
+ }
18
+ export interface AuthConfig {
19
+ accessKeyId: string;
20
+ accessKeySecret: string;
21
+ }
22
+ export interface CliConfig {
23
+ [key: string]: unknown;
24
+ auth?: AuthConfig;
25
+ endpoint?: string;
26
+ lang?: string;
27
+ }
28
+ export interface GetMatchSiteRequest {
29
+ recordName: string;
30
+ }
31
+ export interface GetMatchSiteResponse {
32
+ code: string;
33
+ data: {
34
+ SiteId: number;
35
+ SiteName: string;
36
+ };
37
+ }
38
+ export interface ListRoutineRelatedRecordsRequest {
39
+ Name: string;
40
+ PageNumber?: number;
41
+ PageSize?: number;
42
+ SearchKeyWord?: string;
43
+ }
44
+ export interface ListRoutineRelatedRecordsResponse {
45
+ code: string;
46
+ data: {
47
+ RequestId: string;
48
+ PageNumber: number;
49
+ PageSize: number;
50
+ TotalCount: number;
51
+ RelatedRecords: {
52
+ RecordName: string;
53
+ SiteId: number;
54
+ SiteName: string;
55
+ RecordId: number;
56
+ }[];
57
+ };
58
+ }
59
+ export type Map = Record<string, unknown>;
package/esa.toml ADDED
@@ -0,0 +1,8 @@
1
+ name = "test-client"
2
+ description = "Hello World"
3
+ entry = "src/index.js"
4
+ codeVersions = [ ]
5
+
6
+ [dev]
7
+ port = 18_080
8
+ localUpstream = ""
@@ -0,0 +1,10 @@
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+ import ts from 'typescript-eslint';
4
+
5
+ export default [
6
+ { languageOptions: { globals: globals.browser } },
7
+ js.configs.recommended,
8
+ ...ts.configs.recommended,
9
+ { ignores: ['dist/'] },
10
+ ];
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "mcp-server-esa",
3
+ "version": "1.0.0",
4
+ "description": "Alibaba Cloud ESA (Edge Security Acceleration) MCP Server",
5
+ "main": "./dist/index.js",
6
+ "bin": {
7
+ "mcp-server-esa": "./dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "rslib build",
11
+ "dev": "rslib build --watch",
12
+ "format": "prettier --write .",
13
+ "lint": "eslint ."
14
+ },
15
+ "author": "",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@eslint/js": "^9.21.0",
19
+ "@rslib/core": "^0.5.5",
20
+ "@types/lodash": "^4.17.16",
21
+ "@types/node": "^22.8.1",
22
+ "eslint": "^9.21.0",
23
+ "globals": "^16.0.0",
24
+ "prettier": "^3.5.2",
25
+ "typescript": "^5.8.2",
26
+ "typescript-eslint": "^8.25.0"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/aliyun/mcp-server-esa.git"
31
+ },
32
+ "publishConfig": {
33
+ "registry": "https://registry.npmjs.org/"
34
+ },
35
+ "dependencies": {
36
+ "@alicloud/esa20240910": "^2.23.0",
37
+ "@alicloud/openapi-client": "^0.4.13",
38
+ "@alicloud/tea-util": "^1.4.10",
39
+ "@modelcontextprotocol/sdk": "^1.7.0",
40
+ "@types/semver": "^7.5.8",
41
+ "form-data": "^4.0.2",
42
+ "node-fetch": "^3.3.2",
43
+ "semver": "^7.7.1",
44
+ "zod": "^3.24.2"
45
+ }
46
+ }