# Directory Structure
```
├── .gitignore
├── .prettierignore
├── .prettierrc
├── eslint.config.mjs
├── image
│   └── readme
│       ├── 1744114566511.png
│       ├── 1744114625974.png
│       ├── 1744165412296.png
│       ├── 1744168230082.gif
│       ├── 1744168440370.gif
│       └── 1744168966418.gif
├── LICENSE
├── package.json
├── readme_zh.md
├── readme.md
├── rslib.config.ts
├── src
│   ├── index.ts
│   ├── tools
│   │   ├── er
│   │   │   ├── commit.ts
│   │   │   ├── deploy.ts
│   │   │   ├── deployments.ts
│   │   │   ├── record.ts
│   │   │   ├── route.ts
│   │   │   └── routine.ts
│   │   ├── list-esa-function.ts
│   │   └── site
│   │       ├── certificate.ts
│   │       ├── ipv6.ts
│   │       ├── managedTransform.ts
│   │       ├── record.ts
│   │       └── site.ts
│   └── utils
│       ├── helpers.ts
│       ├── service.ts
│       └── types.ts
└── tsconfig.json
```
# Files
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
```
{
  "singleQuote": true
}
```
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
```
# Lock files
package-lock.json
pnpm-lock.yaml
yarn.lock
```
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
```
# Local
.DS_Store
*.local
*.log*
# Dist
node_modules
dist/
# IDE
.vscode/*
!.vscode/extensions.json
.idea
```
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
```markdown
-
# ESA MCP Server
An MCP server to conveniently use various Alibaba Cloud ESA services.
---
[English](./readme.md) | [中文](./readme_zh.md)
## Installation
1. **Apply for Alibaba Cloud's AK and SK on the Accesskey page**
https://ram.console.aliyun.com/profile/access-keys
2. **Enable Edge Routine service**
https://esa.console.aliyun.com/edge/function/list
3. **Configure in your MCP-enabled client config:**
```
{
  "mcpServers": {
    "esa-mcp-server": {
      "command": "npx",
      "args": ["-y", "mcp-server-esa"],
      "env": {
        "ALIBABA_CLOUD_ACCESS_KEY_ID": "your AK",
        "ALIBABA_CLOUD_ACCESS_KEY_SECRET": "your SK",
        "ALIBABA_CLOUD_SECURITY_TOKEN": "sts_security_token optional, required when using STS Token (By default, no need to pass)"
      }
    }
  }
}
```
## Demo Videos
**Claude Demo**


**Cline Demo**

**Cline configured successfully:**

**Claude configured successfully:**

## Tools List
**The server provides the following ESA tools callable via the MCP protocol:**
| Category        | Tool                         | Description                                                                                 |
| --------------- | ---------------------------- | ------------------------------------------------------------------------------------------- |
| **HTML**        | html_deploy                  | Quick deploy a HTML in a new Edge Routine (ER)                                              |
| **Routines**    | routine_create               | Create a new Edge Routine (ER) in your Alibaba Cloud account.                               |
|                 | routine_delete               | Delete an existing Edge Routine (ER) from your Alibaba Cloud account.                       |
|                 | routine_list                 | List all Edge Routines (ERs) in your Alibaba Cloud account.                                 |
|                 | routine_get                  | Get a the details of a Edge Routine (ER).                                                   |
| **Deployments** | routine_code_commit          | Save a code version for future modifications or release within an Edge Routine (ER).        |
|                 | routine_code_deploy          | Deploy a selected code version to the staging or production environment.                    |
|                 | deployment_delete            | Delete a specified code version associated with an Edge Routine (ER).                       |
| **Routes**      | route_create                 | Create a new route associated with an Edge Routine (ER).                                    |
|                 | route_update                 | Modify the configuration of an existing Edge Routine route.                                 |
|                 | route_delete                 | Delete a specified route associated with an Edge Routine (ER).                              |
|                 | route_get                    | Get details of a specific route associated with an Edge Routine (ER).                       |
|                 | routine_route_list           | List all routes associated with a specific Edge Routine (ER).                               |
|                 | site_route_list              | List all routes associated with a specific site.                                            |
| **Records**     | er_record_create             | Create a new record related to an Edge Routine (ER).                                        |
|                 | er_record_delete             | Delete a specified record associated with an Edge Routine (ER).                             |
|                 | er_record_list               | List all records associated with a specific Edge Routine (ER).                              |
| **Sites**       | site_active_list             | List all active sites registered in your Alibaba Cloud account.                             |
|                 | site_match                   | Identify which site in the account matches the provided input criteria.                     |
|                 | site_record_list             | List DNS records associated with a specific site.                                           |
|                 | create_site_a_or_aaaa_record | Creates an A or AAAA DNS record for a specific website.                                     |
|                 | create_site_cname_record     | Creates a CNAME DNS record for a specific website.                                          |
|                 | create_site_txt_record       | Creates a TXT DNS record for a specific website.                                            |
|                 | create_site_ns_record        | Creates an NS DNS record for a specific website.                                            |
|                 | create_site_mx_record        | Creates an MX DNS record for a specific website.                                            |
|                 | get_site_pause               | Queries the ESA proxy configuration of a website.                                           |
|                 | update_site_pause            | Modifies the ESA proxy configuration of a website.                                          |
|                 | create_site                  | Adds a website.                                                                             |
|                 | update_record                | This operation allows you to update multiple types of DNS records.                          |
|                 | get_record                   | Queries the configuration of a single DNS record.                                           |
|                 | list_record                  | Queries a list of Domain Name System (DNS) records of a website.                            |
|                 | delete_record                | Deletes a DNS record of a website based on the specified RecordId.                          |
|                 | update_ipv6                  | Modifies the IPv6 configuration of a website.                                               |
|                 | get_ipv6                     | Queries the IPv6 configuration of a website.                                                |
|                 | update_managed_transform     | Modifies the configuration of managed transforms for your website.                          |
|                 | get_managed_transform        | Query Managed Transform Configuration.                                                      |
|                 | list_sites                   | List all sites registered in your Alibaba Cloud account.                                    |
| **Certificate** | set_certificate              | Configures whether to enable certificates and update certificate information for a website. |
|                 | apply_certificate            | Applies for a free SSL certificate.                                                         |
|                 | get_certificate              | Retrieve the certificate, private key, and certificate information                          |
|                 | delete_certificate           | Deletes a certificate for a website.                                                        |
|                 | list_certificates            | Lists certificates of a website.                                                            |
|                 | get_certificate_quota        | Query certificate quota and usage.                                                          |
## Prompt Examples
- Write a 2048 game and deploy it on Edge Routine, and display the default access URL provided by the Edge Routine.
- Delete Edge routines created after May 2025.
- List all Edge routines are under my account.
- What is the default access address for my Edge Routine named "hello-world"?
- Create a CNAME record for `test.example.com` with the value set to `example2.com`
- Create a A record for `test.example.com` with the value set to `1.1.1.1`
## License
MIT
```
--------------------------------------------------------------------------------
/rslib.config.ts:
--------------------------------------------------------------------------------
```typescript
import { defineConfig } from '@rslib/core';
export default defineConfig({
  lib: [
    {
      format: 'esm',
      syntax: 'es2021',
      dts: true,
    },
    {
      format: 'cjs',
      syntax: 'es2021',
    },
  ],
});
```
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
```
import js from '@eslint/js';
import globals from 'globals';
import ts from 'typescript-eslint';
export default [
  { languageOptions: { globals: globals.browser } },
  js.configs.recommended,
  ...ts.configs.recommended,
  { ignores: ['dist/'] },
];
```
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
```json
{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["ES2021"],
    "module": "ESNext",
    "noEmit": true,
    "strict": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "resolveJsonModule": true,
    "moduleResolution": "bundler",
    "useDefineForClassFields": true,
    "allowImportingTsExtensions": true
  },
  "include": ["src"]
}
```
--------------------------------------------------------------------------------
/src/tools/er/deployments.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import { DeleteRoutineCodeVersionRequest } from '@alicloud/esa20240910';
export const DEPLOYMENT_DELETE_TOOL: Tool = {
  name: 'deployment_delete',
  description:
    'Delete a specified code version associated with an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description: 'The name of the deployment to delete',
      },
      codeVersion: {
        type: 'string',
        description: 'The version of the code to delete',
      },
    },
    required: ['name', 'codeVersion'],
  },
};
export const deployment_delete = async (request: CallToolRequest) => {
  const res = await api.deleteRoutineCodeVersion(
    request.params.arguments as DeleteRoutineCodeVersionRequest,
  );
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
```typescript
#!/usr/bin/env node
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { ESA_OPENAPI_LIST, esaHandlers } from './tools/list-esa-function';
import { log } from './utils/helpers';
const server = new Server(
  {
    name: 'esa-server',
    version: '1.0.0',
  },
  {
    capabilities: {
      tools: {},
    },
  },
);
// Define available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return { tools: ESA_OPENAPI_LIST };
});
// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  const toolName = request.params.name;
  log(
    'Received tool call:',
    toolName,
    'Params:',
    JSON.stringify(request.params),
  );
  return await esaHandlers[toolName](request);
});
async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error('ESA MCP Server running on stdio');
}
main().catch((error) => {
  console.error('Fatal error in main():', error);
  process.exit(1);
});
```
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
```json
{
  "name": "mcp-server-esa",
  "version": "1.0.10",
  "description": "Alibaba Cloud ESA (Edge Security Acceleration) MCP Server",
  "main": "./dist/index.js",
  "type": "commonjs",
  "bin": {
    "mcp-server-esa": "./dist/index.js"
  },
  "scripts": {
    "build": "rslib build",
    "dev": "rslib build --watch",
    "format": "prettier --write .",
    "lint": "eslint ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@eslint/js": "^9.21.0",
    "@rslib/core": "^0.5.5",
    "@types/lodash": "^4.17.16",
    "@types/node": "^22.8.1",
    "@types/node-fetch": "^2.6.12",
    "eslint": "^9.21.0",
    "globals": "^16.0.0",
    "prettier": "^3.5.2",
    "typescript": "^5.8.2",
    "typescript-eslint": "^8.25.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/aliyun/mcp-server-esa.git"
  },
  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },
  "dependencies": {
    "@alicloud/esa20240910": "^2.25.0",
    "@alicloud/openapi-client": "^0.4.13",
    "@alicloud/tea-util": "^1.4.10",
    "@modelcontextprotocol/sdk": "^1.13.2",
    "@types/semver": "^7.5.8",
    "form-data": "^4.0.2",
    "node-fetch": "^2.7.0",
    "semver": "^7.7.1",
    "zod": "^3.24.2"
  }
}
```
--------------------------------------------------------------------------------
/src/utils/types.ts:
--------------------------------------------------------------------------------
```typescript
import z from 'zod';
import {
  Result,
  CallToolRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { CreateRoutineRouteRequest } from '@alicloud/esa20240910';
export type ToolHandlers = Record<
  string,
  (request: z.infer<typeof CallToolRequestSchema>) => Promise<Result>
>;
export interface IOssConfig {
  OSSAccessKeyId: string;
  Signature: string;
  Url: string;
  callback: string;
  key: string;
  policy: string;
  'x:codeDescription': string;
}
export class CreateRoutineRouteRequestExt extends CreateRoutineRouteRequest {
  mode: 'simple' | 'custom';
  constructor(params: CreateRoutineRouteRequest) {
    super(params);
    this.mode = params.mode;
  }
}
export interface AuthConfig {
  accessKeyId?: string;
  accessKeySecret?: string;
  securityToken?: string;
}
export interface CliConfig {
  [key: string]: unknown;
  auth?: AuthConfig;
  endpoint?: string;
  lang?: string;
}
export interface GetMatchSiteRequest {
  recordName: string;
}
export interface GetMatchSiteResponse {
  code: string;
  data: { SiteId: number; SiteName: string };
}
export interface ListRoutineRelatedRecordsRequest {
  Name: string;
  PageNumber?: number;
  PageSize?: number;
  SearchKeyWord?: string;
}
export interface ListRoutineRelatedRecordsResponse {
  code: string;
  data: {
    RequestId: string;
    PageNumber: number;
    PageSize: number;
    TotalCount: number;
    RelatedRecords: {
      RecordName: string;
      SiteId: number;
      SiteName: string;
      RecordId: number;
    }[];
  };
}
export type Map = Record<string, unknown>;
```
--------------------------------------------------------------------------------
/src/tools/er/deploy.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import { PublishRoutineCodeVersionRequest } from '@alicloud/esa20240910';
export const ROUTINE_CODE_DEPLOY_TOOL: Tool = {
  name: 'routine_code_deploy',
  description:
    'Deploy a selected code version to the staging or production environment. If version is not exist, should call routine_code_commit first',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description:
          'The name of the routine, support lowercase English, numbers, and hyphens, must start with lowercase English, length cannot be less than 2 characters',
      },
      codeVersion: {
        type: 'string',
        description: 'Version of the routine, must be a valid semantic version',
      },
      env: {
        type: 'string',
        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',
      },
    },
    required: ['name', 'codeVersion', 'env'],
  },
};
export const routine_code_deploy = async (request: CallToolRequest) => {
  const res = await api.publishRoutineCodeVersion(
    request.params.arguments as PublishRoutineCodeVersionRequest,
  );
  if (!res) {
    return {
      content: [
        {
          type: 'text',
          text: `Failed to publish routine code version. ${JSON.stringify(res)}`,
        },
      ],
      success: false,
    };
  } else {
    return {
      content: [
        {
          type: 'text',
          text: JSON.stringify(res),
        },
      ],
      success: true,
    };
  }
};
```
--------------------------------------------------------------------------------
/src/tools/site/ipv6.ts:
--------------------------------------------------------------------------------
```typescript
import { UpdateIPv6Request, GetIPv6Request } from '@alicloud/esa20240910';
import api from '../../utils/service.js';
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
export const UPDATE_IPV6_TOOL: Tool = {
  name: 'update_ipv6',
  description: 'Modifies the IPv6 configuration of a website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the ListSites operation.',
        example: [12228828888],
      },
      enable: {
        type: 'string',
        description: 'Specifies whether to enable IPv6.',
        enum: ['on', 'off'],
      },
      region: {
        type: 'string',
        description: 'Enable IPV6 in the region.',
        enum: ['x.x', 'cn.cn'],
      },
    },
    required: ['siteId', 'enable'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const GET_IPV6_TOOL: Tool = {
  name: 'get_ipv6',
  description: 'Queries the IPv6 configuration of a website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the ListSites operation.',
        example: [12228828888],
      },
    },
    required: ['siteId'],
    annotations: {
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const update_ipv6 = async (request: CallToolRequest) => {
  const res = await api.updateIPv6(
    request.params.arguments as UpdateIPv6Request,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const get_ipv6 = async (request: CallToolRequest) => {
  const res = await api.getIPv6(request.params.arguments as GetIPv6Request);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/tools/er/commit.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import {
  CommitRoutineStagingCodeRequest,
  GetRoutineStagingCodeUploadInfoRequest,
} from '@alicloud/esa20240910';
import { uploadCodeToOSS } from '../../utils/helpers.js';
export const ROUTINE_CODE_COMMIT_TOOL: Tool = {
  name: 'routine_code_commit',
  description:
    'Save a code version for future modifications or release within an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description:
          'The name of the routine, support lowercase English, numbers, and hyphens, must start with lowercase English, length cannot be less than 2 characters',
      },
      description: {
        type: 'string',
        description: 'Description of the routine, no spaces',
      },
      code: {
        type: 'string',
        description:
          'Source Code of the routine, export default { async fetch(request) { return handleRequest(request); } }',
      },
    },
    required: ['name', 'code'],
  },
};
export const routine_code_commit = async (request: CallToolRequest) => {
  const res = await api.getRoutineStagingCodeUploadInfo(
    request.params.arguments as GetRoutineStagingCodeUploadInfoRequest,
  );
  if (!res) {
    return {
      content: [
        {
          type: 'text',
          text: `Failed to get routine staging code upload info. ${JSON.stringify(res)}`,
        },
      ],
      success: false,
    };
  } else {
    const uploadRes = await uploadCodeToOSS(
      res,
      request?.params?.arguments?.code as string,
    );
    if (uploadRes !== true) {
      return {
        content: [
          {
            type: 'text',
            text: `Failed to upload code to OSS. ${uploadRes}`,
          },
        ],
        success: false,
      };
    } else {
      const commitRes = await api.commitRoutineStagingCode(
        request.params.arguments as CommitRoutineStagingCodeRequest,
      );
      if (commitRes.statusCode !== 200) {
        return {
          content: [
            {
              type: 'text',
              text: `Failed to commit routine staging code. ${JSON.stringify(commitRes)}`,
            },
          ],
          success: false,
        };
      } else {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(commitRes),
            },
          ],
          success: true,
        };
      }
    }
  }
};
```
--------------------------------------------------------------------------------
/src/tools/er/record.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import {
  CreateRoutineRelatedRecordRequest,
  DeleteRoutineRelatedRecordRequest,
} from '@alicloud/esa20240910';
import { ListRoutineRelatedRecordsRequest } from '../../utils/types.js';
export const ER_RECORD_CREATE_TOOL: Tool = {
  name: 'er_record_create',
  description: 'Create a new record associated with an Edge Routine (ER)',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description: 'The name of the routine',
      },
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      recordName: {
        type: 'string',
        description: 'The name of the record',
      },
    },
    required: ['name', 'siteId', 'recordName'],
  },
};
export const ER_RECORD_DELETE_TOOL: Tool = {
  name: 'er_record_delete',
  description:
    'Delete a specified record associated with an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description: 'The name of the routine',
      },
      recordId: {
        type: 'number',
        description: 'The ID of the record',
      },
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      recordName: {
        type: 'string',
        description: 'The name of the record',
      },
    },
    required: ['name', 'siteId', 'recordName'],
  },
};
export const ER_RECORD_LIST_TOOL: Tool = {
  name: 'er_record_list',
  description: 'List all records associated with a specific Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      Name: {
        type: 'string',
        description: 'The name of the routine',
      },
      PageNumber: {
        type: 'number',
        description: 'The page number of the records',
      },
      PageSize: {
        type: 'number',
        description: 'The page size of the records',
      },
      SearchKeyWord: {
        type: 'string',
        description: 'The search key word of the records',
      },
    },
    required: ['Name'],
  },
};
export const er_record_create = async (request: CallToolRequest) => {
  const res = await api.createRoutineRelatedRecord(
    request.params.arguments as CreateRoutineRelatedRecordRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const er_record_delete = async (request: CallToolRequest) => {
  const res = await api.deleteRoutineRelatedRecord(
    request.params.arguments as DeleteRoutineRelatedRecordRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const er_record_list = async (request: CallToolRequest) => {
  const res = await api.listRoutineRelatedRecords(
    request.params.arguments as unknown as ListRoutineRelatedRecordsRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/tools/site/managedTransform.ts:
--------------------------------------------------------------------------------
```typescript
import {
  UpdateManagedTransformRequest,
  GetManagedTransformRequest,
} from '@alicloud/esa20240910';
import api from '../../utils/service.js';
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
export const UPDATE_MANAGED_TRANSFORM_TOOL: Tool = {
  name: 'update_managed_transform',
  description:
    'Modifies the configuration of managed transforms for your website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the ListSites operation.',
        example: [12228828888],
      },
      addClientGeolocationHeader: {
        type: 'string',
        description:
          'Specifies whether to include the header that indicates the geographical location of a client in an origin request.',
        enum: ['on', 'off'],
      },
      siteVersion: {
        type: 'number',
        description:
          'The version number of the website. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.',
        example: [0],
      },
      addRealClientIpHeader: {
        type: 'string',
        description:
          "Specifies whether to include the 'ali-real-client-ip' header that indicates the 's real IP address in an origin request.",
        enum: ['on', 'off'],
      },
      realClientIpHeaderName: {
        type: 'string',
        description: 'The actual client IP header name.',
        example: ['test_header'],
      },
    },
    required: ['siteId'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const GET_MANAGED_TRANSFORM_TOOL: Tool = {
  name: 'get_managed_transform',
  description: 'Query Managed Transform Configuration.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'Site ID, which can be obtained by calling ListSites.',
        example: [12228828888],
      },
      siteVersion: {
        type: 'number',
        description:
          'The version number of the site. For sites with version management enabled, you can use this parameter to specify the effective version of the configuration, defaulting to version 0.',
        example: [0],
      },
    },
    required: ['siteId'],
    annotations: {
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const update_managed_transform = async (request: CallToolRequest) => {
  const res = await api.updateManagedTransform(
    request.params.arguments as UpdateManagedTransformRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const get_managed_transform = async (request: CallToolRequest) => {
  const res = await api.getManagedTransform(
    request.params.arguments as GetManagedTransformRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/tools/list-esa-function.ts:
--------------------------------------------------------------------------------
```typescript
import {
  er_record_create,
  ER_RECORD_CREATE_TOOL,
  er_record_delete,
  ER_RECORD_DELETE_TOOL,
  er_record_list,
  ER_RECORD_LIST_TOOL,
} from './er/record';
import {
  route_create,
  ROUTE_CREATE_TOOL,
  route_delete,
  ROUTE_DELETE_TOOL,
  route_get,
  ROUTE_GET_TOOL,
  route_update,
  ROUTE_UPDATE_TOOL,
  routine_route_list,
  ROUTINE_ROUTE_LIST_TOOL,
  site_route_list,
  SITE_ROUTE_LIST_TOOL,
} from './er/route';
import {
  ROUTINE_CREATE_TOOL,
  ROUTINE_DELETE_TOOL,
  ROUTINE_LIST_TOOL,
  ROUTINE_GET_TOOL,
  routine_delete,
  routine_create,
  routine_list,
  routine_get,
  HTML_DEPLOY_TOOL,
  html_deploy,
} from './er/routine';
import {
  site_active_list,
  SITE_ACTIVE_LIST_TOOL,
  site_match,
  SITE_MATCH_TOOL,
  create_site,
  CREATE_SITE_TOOL,
  update_site_pause,
  UPDATE_SITE_PAUSE_TOOL,
  get_site_pause,
  GET_SITE_PAUSE_TOOL,
  LIST_SITES_TOOL,
  list_sites,
} from './site/site';
import {
  site_record_list,
  create_site_mx_record,
  CREATE_SITE_MX_RECORD_TOOL,
  create_site_ns_record,
  CREATE_SITE_NS_RECORD_TOOL,
  create_site_txt_record,
  CREATE_SITE_TXT_RECORD_TOOL,
  create_site_cname_record,
  CREATE_SITE_CNAME_RECORD_TOOL,
  create_site_a_or_aaaa_record,
  CREATE_SITE_A_OR_AAAA_RECORD_TOOL,
  update_record,
  UPDATE_RECORD_TOOL,
  DELETE_RECORD_TOOL,
  LIST_RECORDS_TOOL,
  GET_RECORD_TOOL,
  list_records,
  get_record,
  delete_record,
} from './site/record';
import {
  get_ipv6,
  GET_IPV6_TOOL,
  update_ipv6,
  UPDATE_IPV6_TOOL,
} from './site/ipv6';
import {
  get_managed_transform,
  GET_MANAGED_TRANSFORM_TOOL,
  update_managed_transform,
  UPDATE_MANAGED_TRANSFORM_TOOL,
} from './site/managedTransform';
import { ToolHandlers } from '../utils/types';
import { routine_code_deploy, ROUTINE_CODE_DEPLOY_TOOL } from './er/deploy';
import { deployment_delete, DEPLOYMENT_DELETE_TOOL } from './er/deployments';
import { routine_code_commit, ROUTINE_CODE_COMMIT_TOOL } from './er/commit';
import {
  apply_certificate,
  APPLY_CERTIFICATE_TOOL,
  delete_certificate,
  DELETE_CERTIFICATE_TOOL,
  get_certificate,
  get_certificate_quota,
  GET_CERTIFICATE_QUOTA_TOOL,
  GET_CERTIFICATE_TOOL,
  list_certificates,
  LIST_CERTIFICATES_TOOL,
  set_certificate,
  SET_CERTIFICATE_TOOL,
} from './site/certificate';
export const ESA_OPENAPI_ER_LIST = [
  HTML_DEPLOY_TOOL,
  ROUTINE_CREATE_TOOL,
  ROUTINE_DELETE_TOOL,
  ROUTINE_LIST_TOOL,
  ROUTINE_GET_TOOL,
  ROUTINE_CODE_COMMIT_TOOL,
  ROUTINE_CODE_DEPLOY_TOOL,
  ROUTINE_ROUTE_LIST_TOOL,
  DEPLOYMENT_DELETE_TOOL,
  SITE_ACTIVE_LIST_TOOL,
  SITE_ROUTE_LIST_TOOL,
  ROUTE_CREATE_TOOL,
  ROUTE_DELETE_TOOL,
  ROUTE_UPDATE_TOOL,
  ROUTE_GET_TOOL,
  SITE_MATCH_TOOL,
  ER_RECORD_CREATE_TOOL,
  ER_RECORD_DELETE_TOOL,
  ER_RECORD_LIST_TOOL,
];
export const ESA_OPENAPI_SITE_LIST = [
  LIST_SITES_TOOL,
  CREATE_SITE_TOOL,
  UPDATE_SITE_PAUSE_TOOL,
  GET_SITE_PAUSE_TOOL,
  UPDATE_RECORD_TOOL,
  CREATE_SITE_MX_RECORD_TOOL,
  CREATE_SITE_NS_RECORD_TOOL,
  CREATE_SITE_TXT_RECORD_TOOL,
  CREATE_SITE_CNAME_RECORD_TOOL,
  CREATE_SITE_A_OR_AAAA_RECORD_TOOL,
  DELETE_RECORD_TOOL,
  LIST_RECORDS_TOOL,
  GET_RECORD_TOOL,
];
export const IPV6_LIST = [UPDATE_IPV6_TOOL, GET_IPV6_TOOL];
export const CERTIFICATE_LIST = [
  SET_CERTIFICATE_TOOL,
  APPLY_CERTIFICATE_TOOL,
  GET_CERTIFICATE_TOOL,
  DELETE_CERTIFICATE_TOOL,
  LIST_CERTIFICATES_TOOL,
  GET_CERTIFICATE_QUOTA_TOOL,
];
export const MANAGED_TRANSFORM_LIST = [
  UPDATE_MANAGED_TRANSFORM_TOOL,
  GET_MANAGED_TRANSFORM_TOOL,
];
export const ESA_OPENAPI_LIST = [
  ...ESA_OPENAPI_ER_LIST,
  ...ESA_OPENAPI_SITE_LIST,
  ...IPV6_LIST,
  ...CERTIFICATE_LIST,
  ...MANAGED_TRANSFORM_LIST,
];
export const esaHandlers: ToolHandlers = {
  site_active_list,
  site_match,
  site_route_list,
  site_record_list,
  routine_create,
  routine_code_commit,
  routine_delete,
  routine_list,
  routine_get,
  routine_code_deploy,
  routine_route_list,
  deployment_delete,
  route_create,
  route_delete,
  route_update,
  route_get,
  er_record_create,
  er_record_delete,
  er_record_list,
  html_deploy,
  create_site,
  update_site_pause,
  get_site_pause,
  create_site_mx_record,
  create_site_ns_record,
  create_site_txt_record,
  create_site_cname_record,
  create_site_a_or_aaaa_record,
  update_record,
  list_records,
  get_record,
  delete_record,
  update_ipv6,
  get_ipv6,
  update_managed_transform,
  get_managed_transform,
  set_certificate,
  apply_certificate,
  get_certificate,
  delete_certificate,
  list_certificates,
  get_certificate_quota,
  list_sites,
};
```
--------------------------------------------------------------------------------
/src/utils/helpers.ts:
--------------------------------------------------------------------------------
```typescript
import { GetRoutineStagingCodeUploadInfoResponse } from '@alicloud/esa20240910';
import { IOssConfig } from './types';
import FormData from 'form-data';
import fetch from 'node-fetch';
export function log(...args: unknown[]) {
  const msg = `[DEBUG ${new Date().toISOString()}] ${args.join(' ')}\n`;
  process.stderr.write(msg);
}
export const uploadCodeToOSS = async (
  res: GetRoutineStagingCodeUploadInfoResponse,
  code: string,
) => {
  const ossConfig = res?.body?.ossPostConfig as IOssConfig;
  if (res.statusCode !== 200 || !ossConfig) {
    return false;
  }
  const { OSSAccessKeyId, Signature, callback, Url, key, policy }: IOssConfig =
    ossConfig;
  const formData = new FormData();
  formData.append('OSSAccessKeyId', OSSAccessKeyId);
  formData.append('Signature', Signature);
  formData.append('callback', callback);
  formData.append('x:codeDescription', ossConfig['x:codeDescription']);
  formData.append('policy', policy);
  formData.append('key', key);
  formData.append('file', code);
  const ossRes = await fetch(Url, {
    method: 'POST',
    body: formData,
    headers: formData.getHeaders(),
  });
  return ossRes && ossRes.status === 200;
};
/* 操作符号枚举 */
export enum OPERATOR_ENUM {
  Eq = 'eq',
  Ne = 'ne',
  Contains = 'contains',
  Negate_Contains = 'negate_contains',
  StartsWith = 'starts_with',
  Negate_StartsWith = 'negate_starts_with',
  EndsWith = 'ends_with',
  Negate_EndsWith = 'negate_ends_with',
  Matches = 'matches',
  Negate_Matches = 'negate_matches',
  In = 'in',
  Negate_In = 'negate_in',
  Gt = 'gt',
  Lt = 'lt',
  Ge = 'ge',
  Le = 'le',
  InList = 'in_list',
  Negate_InList = 'negate_in_list',
}
const RuleMatchTypeHost = 'http.host';
const RuleMatchTypeUriPath = 'http.request.uri.path';
const RuleMatchOperatorEq = OPERATOR_ENUM.Eq;
const RuleMatchOperatorStartsWith = OPERATOR_ENUM.StartsWith;
const RuleMatchOperatorEndsWith = OPERATOR_ENUM.EndsWith;
export const transferRouteToRuleString = (routePath: string): string => {
  if (!routePath) {
    return '';
  }
  const index = routePath.indexOf('/');
  let host = '';
  let uriPath = '';
  if (index < 0) {
    host = routePath;
    uriPath = '/';
  } else {
    host = routePath.substring(0, index);
    uriPath = routePath.substring(index);
  }
  let hostOperator = RuleMatchOperatorEq;
  if (host.startsWith('*')) {
    hostOperator = RuleMatchOperatorEndsWith;
    host = host.replace(/\*/g, '');
  }
  let uriPathOperator = RuleMatchOperatorEq;
  if (uriPath.endsWith('*')) {
    uriPathOperator = RuleMatchOperatorStartsWith;
    uriPath = uriPath.replace(/\*$/, '');
  }
  let ruleStr = '';
  if (hostOperator === RuleMatchOperatorEq) {
    if (uriPathOperator === RuleMatchOperatorEq) {
      ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
    } else if (uriPathOperator === RuleMatchOperatorStartsWith) {
      ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
    }
  } else if (hostOperator === RuleMatchOperatorEndsWith) {
    if (uriPathOperator === RuleMatchOperatorEq) {
      ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
    } else if (uriPathOperator === RuleMatchOperatorStartsWith) {
      ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
    }
  }
  return ruleStr;
};
export const transferRuleStringToRoute = (ruleStr: string): string => {
  if (!ruleStr) {
    return '';
  }
  // 去掉外层括号并按 " and " 分割
  const cleanedRule = ruleStr.replace(/^\(|\)$/g, '');
  const parts = cleanedRule.split(' and ');
  if (parts.length !== 2) {
    return '';
  }
  let host = '';
  let uriPath = '';
  // 处理host部分
  const hostPart = parts[0].trim();
  if (
    hostPart.startsWith(`${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost},`)
  ) {
    // host匹配eq时的逻辑
    // ends_with(http.host, "value")
    const match = hostPart.match(/ends_with\(http\.host,\s*"([^"]+)"\)/);
    if (match) {
      host = `*${match[1]}`; // 加前缀 *
    }
  } else if (
    hostPart.startsWith(`${RuleMatchTypeHost} ${RuleMatchOperatorEq}`)
  ) {
    // host匹配eq时的逻辑
    // http.host eq "value"
    const match = hostPart.match(/http\.host eq "([^"]+)"/);
    if (match) {
      host = match[1];
    }
  }
  // 处理uriPath 部分
  const uriPathPart = parts[1].trim();
  if (
    uriPathPart.startsWith(
      `${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath},`,
    )
  ) {
    // uriPath匹配startsWith时的逻辑
    // starts_with(http.request.uri.path, "value")
    const match = uriPathPart.match(
      /starts_with\(http\.request\.uri\.path,\s*"([^"]+)"\)/,
    );
    if (match) {
      uriPath = `${match[1]}*`; // 加后缀 *
    }
  } else if (
    uriPathPart.startsWith(`${RuleMatchTypeUriPath} ${RuleMatchOperatorEq}`)
  ) {
    // uriPath匹配eq时的逻辑
    // http.request.uri.path eq "value"
    const match = uriPathPart.match(/http\.request\.uri\.path eq "([^"]+)"/);
    if (match) {
      uriPath = match[1];
    }
  }
  if (!host || !uriPath) {
    return '';
  }
  return `${host}${uriPath}`;
};
```
--------------------------------------------------------------------------------
/src/tools/site/certificate.ts:
--------------------------------------------------------------------------------
```typescript
import {
  ApplyCertificateRequest,
  GetCertificateRequest,
  DeleteCertificateRequest,
  ListCertificatesRequest,
  GetCertificateQuotaRequest,
  SetCertificateRequest,
} from '@alicloud/esa20240910';
import api from '../../utils/service.js';
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
// Prompt:
export const SET_CERTIFICATE_TOOL: Tool = {
  name: 'set_certificate',
  description:
    'Configures whether to enable certificates and update certificate information for a website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The website ID. Reference Value Source: list_sites',
        examples: ['123456****'],
      },
      name: {
        type: 'string',
        description: 'The name of the certificate.',
      },
      casId: {
        type: 'number',
        description: 'The ID of the cloud certificate.',
      },
      type: {
        type: 'string',
        description:
          'The type of certificate. Possible values: - cas (Cloud Certificate) - upload (Custom Upload Certificate)',
        enum: ['cas', 'upload'],
      },
      certificate: {
        type: 'string',
        description: 'The content of the certificate.',
      },
      privateKey: {
        type: 'string',
        description: 'The private key of the certificate.',
      },
      region: {
        type: 'string',
        description: 'The region.',
        example: 'cn-hangzhou',
      },
      id: {
        type: 'string',
        description: 'The ID of the certificate.',
        example: '30001303',
      },
    },
    required: ['siteId', 'type'],
    annotations: {},
  },
};
// Prompt:
export const APPLY_CERTIFICATE_TOOL: Tool = {
  name: 'apply_certificate',
  description: 'Applies for a free SSL certificate.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'Site ID. Example: 1234567890123. Reference Value Source: list_sites',
      },
      domains: {
        type: 'string',
        description:
          'The list of domain names, separated by commas. Example: "example.com,www.example.com"',
      },
      type: {
        type: 'string',
        description:
          "The type of certificate. Possible values: - lets_encrypt (Let's Encrypt certificate) - digicert_single (Digicert single-domain certificate) - digicert_wildcard (Digicert wildcard certificate)  ",
      },
    },
    required: ['siteId', 'domains', 'type'],
    annotations: {},
  },
};
// Prompt:
export const GET_CERTIFICATE_TOOL: Tool = {
  name: 'get_certificate',
  description:
    'Retrieve the certificate, private key, and certificate information',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The website ID. Reference Value Source: list_sites',
      },
      id: {
        type: 'string',
        description:
          'Certificate ID. Example: babaded901474b9693acf530e0fb1d95',
      },
    },
    required: ['siteId', 'id'],
    annotations: {},
  },
};
// Prompt:
export const DELETE_CERTIFICATE_TOOL: Tool = {
  name: 'delete_certificate',
  description: 'Deletes a certificate for a website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the ListSites operation. Example: 1234567890123',
      },
      id: {
        type: 'string',
        description: 'The ID of the certificate. Example: 30001303',
      },
    },
    required: ['siteId', 'id'],
    annotations: {},
  },
};
// Prompt:
export const LIST_CERTIFICATES_TOOL: Tool = {
  name: 'list_certificates',
  description: 'Lists certificates of a website.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID. Reference Value Source: list_sites. Example: 1234567890123',
      },
      keyword: {
        type: 'string',
        description: 'The search keyword.',
      },
      validOnly: {
        type: 'boolean',
        description: 'Whether to return only valid certificates.',
      },
      pageNumber: {
        type: 'number',
        description: 'The page number of the returned data.',
      },
      pageSize: {
        type: 'number',
        description: 'The number of records per page.',
      },
    },
    required: ['siteId'],
    annotations: {},
  },
};
// Prompt:
export const GET_CERTIFICATE_QUOTA_TOOL: Tool = {
  name: 'get_certificate_quota',
  description: 'Query certificate quota and usage.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID. Reference Value Source: list_sites. Example: 1234567890123',
      },
      type: {
        type: 'string',
        description: 'The type of certificate quota. Example: free',
      },
    },
    required: ['siteId', 'type'],
    annotations: {},
  },
};
export const set_certificate = async (request: CallToolRequest) => {
  const res = await api.setCertificate(
    request.params.arguments as SetCertificateRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const apply_certificate = async (request: CallToolRequest) => {
  const res = await api.applyCertificate(
    request.params.arguments as ApplyCertificateRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const get_certificate = async (request: CallToolRequest) => {
  const res = await api.getCertificate(
    request.params.arguments as GetCertificateRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const delete_certificate = async (request: CallToolRequest) => {
  const res = await api.deleteCertificate(
    request.params.arguments as DeleteCertificateRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const list_certificates = async (request: CallToolRequest) => {
  const res = await api.listCertificates(
    request.params.arguments as ListCertificatesRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const get_certificate_quota = async (request: CallToolRequest) => {
  const res = await api.getCertificateQuota(
    request.params.arguments as GetCertificateQuotaRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/tools/er/routine.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import {
  CommitRoutineStagingCodeRequest,
  CreateRoutineRequest,
  DeleteRoutineRequest,
  GetRoutineRequest,
  GetRoutineStagingCodeUploadInfoRequest,
  PublishRoutineCodeVersionRequest,
} from '@alicloud/esa20240910';
import { uploadCodeToOSS } from '../../utils/helpers.js';
// Prompt:帮我写个HTML部署在ER上
export const HTML_DEPLOY_TOOL: Tool = {
  name: 'html_deploy',
  description:
    'Quickly deploy an HTML page to ESA Edge Routine (ER) and return a default access URL to the user.',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        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',
      },
      html: {
        type: 'string',
        description:
          'An HTML string which user want to deploy. For example: <html><body>Hello World</body></html>',
      },
    },
    required: ['name', 'html'],
  },
  annotations: {
    readOnlyHint: false,
    idempotentHint: false,
  },
};
// Prompt: 帮我创建一个er名称是test-kl-2 描述是test 代码是helloworld
export const ROUTINE_CREATE_TOOL: Tool = {
  name: 'routine_create',
  description: 'Create a new Edge Routine (ER) in your Alibaba Cloud account.',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description:
          'The name of the routine, support lowercase English, numbers, and hyphens, must start with lowercase English, length cannot be less than 2 characters',
      },
      description: {
        type: 'string',
        description: 'Description of the routine, no spaces',
      },
    },
    required: ['name'],
  },
};
export const ROUTINE_DELETE_TOOL: Tool = {
  name: 'routine_delete',
  description:
    'Delete an existing Edge Routine (ER) from your Alibaba Cloud account.',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description: 'The name of the routine to delete',
      },
    },
    required: ['name'],
  },
};
export const ROUTINE_LIST_TOOL: Tool = {
  name: 'routine_list',
  description: 'List all Edge Routines (ERs) in your Alibaba Cloud account.',
  inputSchema: {
    type: 'object',
    properties: {},
  },
};
export const ROUTINE_GET_TOOL: Tool = {
  name: 'routine_get',
  description: 'Get a the details of a Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        description: 'The name of the routine to get details for',
      },
    },
    required: ['name'],
  },
};
export const html_deploy = async (request: CallToolRequest) => {
  // Escape backticks and dollar signs in the HTML string
  const html = (request?.params?.arguments?.html as string)
    .replace(/`/g, '\\`')
    .replace(/\$/g, '\\$');
  const code = `const html = \`${html}\`;
async function handleRequest(request) {
  return new Response(html, {
    headers: {
      "content-type": "text/html;charset=UTF-8",
    },
  });
}
export default {
  async fetch(request) {
    return handleRequest(request);
  },
};
  `;
  const createRoutineRes = await api.createRoutine({
    name: request?.params?.arguments?.name || '',
    code: code,
  } as unknown as CreateRoutineRequest);
  // Create Edge Routine
  if (
    createRoutineRes.statusCode === 200 &&
    createRoutineRes.body?.status === 'OK'
  ) {
    const getOssInfoRes = await api.getRoutineStagingCodeUploadInfo(
      request.params.arguments as GetRoutineStagingCodeUploadInfoRequest,
    );
    if (
      !getOssInfoRes ||
      getOssInfoRes?.statusCode !== 200 ||
      !getOssInfoRes?.body?.ossPostConfig?.OSSAccessKeyId
    ) {
      return {
        content: [
          {
            type: 'text',
            text: `Failed to get routine staging code upload info. ${JSON.stringify(getOssInfoRes)}`,
          },
        ],
        success: false,
      };
    } else {
      const uploadRes = await uploadCodeToOSS(getOssInfoRes, code as string);
      if (uploadRes !== true) {
        return {
          content: [
            {
              type: 'text',
              text: `Failed to upload code to OSS. ${uploadRes}`,
            },
          ],
          success: false,
        };
      } else {
        const commitRes = await api.commitRoutineStagingCode(
          request.params.arguments as CommitRoutineStagingCodeRequest,
        );
        if (commitRes.statusCode !== 200) {
          return {
            content: [
              {
                type: 'text',
                text: `Failed to commit routine staging code. ${JSON.stringify(commitRes)}`,
              },
            ],
            success: false,
          };
        } else {
          const deployRes = await api.publishRoutineCodeVersion({
            name: request?.params?.arguments?.name || '',
            env: 'production',
            codeVersion: commitRes?.body?.codeVersion,
          } as PublishRoutineCodeVersionRequest);
          if (deployRes.statusCode === 200) {
            const res = await api.getRoutine({
              name: request?.params?.arguments?.name || '',
            } as GetRoutineRequest);
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify(res),
                },
              ],
              success: true,
            };
          } else {
            return {
              content: [
                {
                  type: 'text',
                  text: `Failed to get routine. ${JSON.stringify(deployRes)}`,
                },
              ],
              success: false,
            };
          }
        }
      }
    }
  } else {
    return {
      content: [
        {
          type: 'text',
          text: `Failed to create routine. ${JSON.stringify(createRoutineRes)}`,
        },
      ],
      success: false,
    };
  }
};
export const routine_create = async (request: CallToolRequest) => {
  const res = await api.createRoutine(
    request.params.arguments as CreateRoutineRequest,
  );
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
export const routine_delete = async (request: CallToolRequest) => {
  const res = await api.deleteRoutine(
    request.params.arguments as DeleteRoutineRequest,
  );
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
export const routine_list = async () => {
  const res = await api.getRoutineUserInfo();
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
export const routine_get = async (request: CallToolRequest) => {
  const res = await api.getRoutine(
    request.params.arguments as GetRoutineRequest,
  );
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/tools/er/route.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import {
  CreateRoutineRouteRequest,
  DeleteRoutineRouteRequest,
  GetRoutineRouteRequest,
  ListRoutineRoutesRequest,
  ListSiteRoutesRequest,
  UpdateRoutineRouteRequest,
} from '@alicloud/esa20240910';
import { transferRouteToRuleString } from '../../utils/helpers.js';
export const ROUTE_CREATE_TOOL: Tool = {
  name: 'route_create',
  description: 'Create a new route associated with an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      mode: {
        type: 'enum',
        enum: ['simple', 'custom'],
        description: 'The mode of the route, default is simple',
      },
      route: {
        type: 'string',
        description:
          'The route of the route, if mode is simple, this field is required. For example: test.example.com/*',
      },
      rule: {
        type: 'string',
        description:
          'The rule of the route, if mode is custom, this field is required',
      },
      routineName: {
        type: 'string',
        description: 'The name of the routine',
      },
      routeName: {
        type: 'string',
        description:
          'The name of the route, use to identify the route. For example: test-route',
      },
      bypass: {
        type: 'enum',
        enum: ['on', 'off'],
        description: 'The bypass of the route, default is off',
      },
      routeEnable: {
        type: 'enum',
        enum: ['on', 'off'],
        description: 'The enable of the route, default is on',
      },
      sequence: {
        type: 'number',
        description:
          'The sequence of the route, if not passed, default is the current number of routes',
      },
    },
    required: [
      'siteId',
      'mode',
      'rule',
      'routineName',
      'routeName',
      'bypass',
      'routeEnable',
    ],
  },
};
export const ROUTE_UPDATE_TOOL: Tool = {
  name: 'route_update',
  description: 'Modify the configuration of an existing Edge Routine route.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      configId: {
        type: 'number',
        description: 'The ID of the config',
      },
      routeName: {
        type: 'string',
        description: 'The name of the route, use to identify the route.',
      },
      routeEnable: {
        type: 'enum',
        enum: ['on', 'off'],
        description: 'The enable of the route',
      },
      rule: {
        type: 'string',
        description: 'The rule of the route',
      },
      routineName: {
        type: 'string',
        description: 'The name of the routine',
      },
      bypass: {
        type: 'enum',
        enum: ['on', 'off'],
        description: 'The bypass of the route ',
      },
      sequence: {
        type: 'number',
        description:
          'The sequence of the route, if not passed, default is the current number of routes',
      },
    },
    required: [
      'siteId',
      'configId',
      'routeName',
      'routeEnable',
      'rule',
      'routineName',
      'bypass',
    ],
  },
};
export const ROUTE_DELETE_TOOL: Tool = {
  name: 'route_delete',
  description: 'Delete a specified route associated with an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      configId: {
        type: 'number',
        description: 'The ID of the config',
      },
    },
    required: ['siteId', 'configId'],
  },
};
export const ROUTE_GET_TOOL: Tool = {
  name: 'route_get',
  description:
    'Get details of a specific route associated with an Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      configId: {
        type: 'number',
        description: 'The ID of the config',
      },
    },
    required: ['siteId', 'configId'],
  },
};
export const ROUTINE_ROUTE_LIST_TOOL: Tool = {
  name: 'routine_route_list',
  description: 'List all routes associated with a specific Edge Routine (ER).',
  inputSchema: {
    type: 'object',
    properties: {
      routineName: {
        type: 'string',
        description: 'The name of the routine',
      },
      routeName: {
        type: 'string',
        description: 'The name of the route, use to filter list results',
      },
      pageNumber: {
        type: 'number',
        description: 'The page number of the routes',
      },
      pageSize: {
        type: 'number',
        description: 'The page size of the routes',
      },
    },
    required: ['routineName'],
  },
};
// export interface ListSiteRoutesReq {
//     SiteId: number;
//     ConfigId?: number;
//     ConfigType?: string;
//     RouteName?: string;
//     PageNumber?: number;
//     PageSize?: number;
//     RegionId?: string;
//   }
export const SITE_ROUTE_LIST_TOOL: Tool = {
  name: 'site_route_list',
  description: 'List all routes associated with a specific site.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The ID of the site',
      },
      routeName: {
        type: 'string',
        description: 'The name of the route, use to filter list results',
      },
      pageNumber: {
        type: 'number',
        description: 'The page number of the routes',
      },
      pageSize: {
        type: 'number',
        description: 'The page size of the routes',
      },
    },
    required: ['siteId'],
  },
};
export const route_create = async (request: CallToolRequest) => {
  const { mode, route } = request.params.arguments as CreateRoutineRouteRequest;
  if (mode === 'simple') {
    const res = await api.createRoutineRoute({
      ...request.params.arguments,
      rule: transferRouteToRuleString(route),
    } as unknown as CreateRoutineRouteRequest);
    return {
      content: [{ type: 'text', text: JSON.stringify(res) }],
      success: true,
    };
  } else {
    const res = await api.createRoutineRoute(
      request.params.arguments as CreateRoutineRouteRequest,
    );
    return {
      content: [{ type: 'text', text: JSON.stringify(res) }],
      success: true,
    };
  }
};
export const route_delete = async (request: CallToolRequest) => {
  const res = await api.deleteRoutineRoute(
    request.params.arguments as DeleteRoutineRouteRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const route_update = async (request: CallToolRequest) => {
  const { mode, route } = request.params.arguments as CreateRoutineRouteRequest;
  if (mode === 'simple') {
    const res = await api.updateRoutineRoute({
      ...request.params.arguments,
      rule: transferRouteToRuleString(route),
    } as unknown as UpdateRoutineRouteRequest);
    return {
      content: [{ type: 'text', text: JSON.stringify(res) }],
      success: true,
    };
  } else {
    const res = await api.updateRoutineRoute(
      request.params.arguments as UpdateRoutineRouteRequest,
    );
    return {
      content: [{ type: 'text', text: JSON.stringify(res) }],
      success: true,
    };
  }
};
export const route_get = async (request: CallToolRequest) => {
  const res = await api.getRoutineRoute(
    request.params.arguments as GetRoutineRouteRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const routine_route_list = async (request: CallToolRequest) => {
  const res = await api.listRoutineRoutes(
    request.params.arguments as ListRoutineRoutesRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const site_route_list = async (request: CallToolRequest) => {
  const res = await api.listSiteRoutes(
    request.params.arguments as ListSiteRoutesRequest,
  );
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```
--------------------------------------------------------------------------------
/src/utils/service.ts:
--------------------------------------------------------------------------------
```typescript
import ESA, {
  SetCertificateRequest,
  SetCertificateResponse,
  ApplyCertificateRequest,
  ApplyCertificateResponse,
  GetCertificateRequest,
  GetCertificateResponse,
  DeleteCertificateRequest,
  DeleteCertificateResponse,
  ListCertificatesRequest,
  ListCertificatesResponse,
  GetCertificateQuotaRequest,
  GetCertificateQuotaResponse,
  CommitRoutineStagingCodeRequest,
  CommitRoutineStagingCodeResponse,
  CreateRecordRequest,
  CreateRecordResponse,
  CreateRoutineRelatedRecordRequest,
  CreateRoutineRelatedRecordResponse,
  CreateRoutineRequest,
  CreateRoutineResponse,
  CreateRoutineRouteRequest,
  CreateRoutineRouteResponse,
  DeleteRoutineCodeVersionRequest,
  DeleteRoutineCodeVersionResponse,
  DeleteRoutineRelatedRecordRequest,
  DeleteRoutineRelatedRecordResponse,
  DeleteRoutineRequest,
  DeleteRoutineResponse,
  DeleteRoutineRouteRequest,
  DeleteRoutineRouteResponse,
  GetRoutineRequest,
  GetRoutineResponse,
  GetRoutineRouteRequest,
  GetRoutineRouteResponse,
  GetRoutineStagingCodeUploadInfoRequest,
  GetRoutineStagingCodeUploadInfoResponse,
  ListRecordsRequest,
  ListRecordsResponse,
  ListRoutineRoutesRequest,
  ListRoutineRoutesResponse,
  ListSiteRoutesRequest,
  ListSiteRoutesResponse,
  ListSitesRequest,
  ListSitesResponse,
  PublishRoutineCodeVersionRequest,
  PublishRoutineCodeVersionResponse,
  UpdateRoutineRouteRequest,
  UpdateRoutineRouteResponse,
  CreateSiteRequest,
  CreateSiteResponse,
  UpdateSitePauseRequest,
  UpdateSitePauseResponse,
  GetSitePauseRequest,
  GetSitePauseResponse,
  UpdateRecordRequest,
  UpdateRecordResponse,
  DeleteRecordRequest,
  DeleteRecordResponse,
  GetRecordRequest,
  GetRecordResponse,
  GetIPv6Request,
  GetIPv6Response,
  UpdateIPv6Request,
  UpdateIPv6Response,
  UpdateManagedTransformRequest,
  UpdateManagedTransformResponse,
  GetManagedTransformRequest,
  GetManagedTransformResponse,
} from '@alicloud/esa20240910';
import * as $OpenApi from '@alicloud/openapi-client';
import * as $Util from '@alicloud/tea-util';
import {
  CliConfig,
  GetMatchSiteRequest,
  ListRoutineRelatedRecordsRequest,
} from './types';
export interface ApiMethod<RequestType, ResponseType> {
  (runtime: $Util.RuntimeOptions): Promise<ResponseType>;
  (request: RequestType, runtime: $Util.RuntimeOptions): Promise<ResponseType>;
}
class Client {
  client: ESA;
  constructor() {
    const config = {
      auth: {
        accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID || '',
        accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET || '',
        securityToken: process.env.ALIBABA_CLOUD_SECURITY_TOKEN,
      },
      endpoint: 'esa.cn-hangzhou.aliyuncs.com',
    };
    this.client = Client.createClient(config);
  }
  static createClient(config: CliConfig) {
    const apiConfig = new $OpenApi.Config({
      accessKeyId: config.auth?.accessKeyId || '',
      accessKeySecret: config.auth?.accessKeySecret || '',
      securityToken: config.auth?.securityToken || '',
      endpoint: config.endpoint,
    });
    return new ESA(apiConfig);
  }
  callApi = async <RequestType, ResponseType>(
    action: ApiMethod<RequestType, ResponseType>,
    request?: RequestType,
  ): Promise<ResponseType> => {
    const runtime = new $Util.RuntimeOptions({
      connectTimeout: 10000,
      readTimeout: 10000,
      autoretry: true,
      maxAttempts: 3,
    });
    const response = request
      ? await action(request, runtime)
      : await action(runtime);
    return response;
  };
  createRoutine(params: CreateRoutineRequest) {
    const request = new CreateRoutineRequest(params);
    return this.callApi(
      this.client.createRoutine.bind(this.client) as ApiMethod<
        CreateRoutineRequest,
        CreateRoutineResponse
      >,
      request,
    );
  }
  deleteRoutine(params: DeleteRoutineRequest) {
    const request = new DeleteRoutineRequest(params);
    return this.callApi(
      this.client.deleteRoutineWithOptions.bind(this.client) as ApiMethod<
        DeleteRoutineRequest,
        DeleteRoutineResponse
      >,
      request,
    );
  }
  getRoutine(params: GetRoutineRequest) {
    const request = new GetRoutineRequest(params);
    return this.callApi(
      this.client.getRoutineWithOptions.bind(this.client) as ApiMethod<
        GetRoutineRequest,
        GetRoutineResponse
      >,
      request,
    );
  }
  getRoutineUserInfo() {
    return this.callApi(this.client.getRoutineUserInfo.bind(this.client));
  }
  async getRoutineStagingCodeUploadInfo(
    params: GetRoutineStagingCodeUploadInfoRequest,
  ) {
    const request = new GetRoutineStagingCodeUploadInfoRequest(params);
    return this.callApi(
      this.client.getRoutineStagingCodeUploadInfo.bind(
        this.client,
      ) as ApiMethod<
        GetRoutineStagingCodeUploadInfoRequest,
        GetRoutineStagingCodeUploadInfoResponse
      >,
      request,
    );
  }
  commitRoutineStagingCode(params: CommitRoutineStagingCodeRequest) {
    const request = new CommitRoutineStagingCodeRequest(params);
    return this.callApi(
      this.client.commitRoutineStagingCode.bind(this.client) as ApiMethod<
        CommitRoutineStagingCodeRequest,
        CommitRoutineStagingCodeResponse
      >,
      request,
    );
  }
  publishRoutineCodeVersion(params: PublishRoutineCodeVersionRequest) {
    const request = new PublishRoutineCodeVersionRequest(params);
    return this.callApi(
      this.client.publishRoutineCodeVersion.bind(this.client) as ApiMethod<
        PublishRoutineCodeVersionRequest,
        PublishRoutineCodeVersionResponse
      >,
      request,
    );
  }
  listSites(params: ListSitesRequest) {
    const request = new ListSitesRequest(params);
    return this.callApi(
      this.client.listSites.bind(this.client) as ApiMethod<
        ListSitesRequest,
        ListSitesResponse
      >,
      request,
    );
  }
  deleteRoutineCodeVersion(params: DeleteRoutineCodeVersionRequest) {
    const request = new DeleteRoutineCodeVersionRequest(params);
    return this.callApi(
      this.client.deleteRoutineCodeVersion.bind(this.client) as ApiMethod<
        DeleteRoutineCodeVersionRequest,
        DeleteRoutineCodeVersionResponse
      >,
      request,
    );
  }
  createRoutineRelatedRecord(params: CreateRoutineRelatedRecordRequest) {
    const request = new CreateRoutineRelatedRecordRequest(params);
    return this.callApi(
      this.client.createRoutineRelatedRecord.bind(this.client) as ApiMethod<
        CreateRoutineRelatedRecordRequest,
        CreateRoutineRelatedRecordResponse
      >,
      request,
    );
  }
  createRoutineRoute(params: CreateRoutineRouteRequest) {
    const request = new CreateRoutineRouteRequest(params);
    return this.callApi(
      this.client.createRoutineRoute.bind(this.client) as ApiMethod<
        CreateRoutineRouteRequest,
        CreateRoutineRouteResponse
      >,
      request,
    );
  }
  deleteRoutineRoute(params: DeleteRoutineRouteRequest) {
    const request = new DeleteRoutineRouteRequest(params);
    return this.callApi(
      this.client.deleteRoutineRoute.bind(this.client) as ApiMethod<
        DeleteRoutineRouteRequest,
        DeleteRoutineRouteResponse
      >,
      request,
    );
  }
  getRoutineRoute(params: GetRoutineRouteRequest) {
    const request = new GetRoutineRouteRequest(params);
    return this.callApi(
      this.client.getRoutineRoute.bind(this.client) as ApiMethod<
        GetRoutineRouteRequest,
        GetRoutineRouteResponse
      >,
      request,
    );
  }
  listSiteRoutes(params: ListSiteRoutesRequest) {
    const request = new ListSiteRoutesRequest(params);
    return this.callApi(
      this.client.listSiteRoutes.bind(this.client) as ApiMethod<
        ListSiteRoutesRequest,
        ListSiteRoutesResponse
      >,
      request,
    );
  }
  listRoutineRoutes(params: ListRoutineRoutesRequest) {
    const request = new ListRoutineRoutesRequest(params);
    return this.callApi(
      this.client.listRoutineRoutes.bind(this.client) as ApiMethod<
        ListRoutineRoutesRequest,
        ListRoutineRoutesResponse
      >,
      request,
    );
  }
  updateRoutineRoute(params: UpdateRoutineRouteRequest) {
    const request = new UpdateRoutineRouteRequest(params);
    return this.callApi(
      this.client.updateRoutineRoute.bind(this.client) as ApiMethod<
        UpdateRoutineRouteRequest,
        UpdateRoutineRouteResponse
      >,
      request,
    );
  }
  deleteRoutineRelatedRecord(params: DeleteRoutineRelatedRecordRequest) {
    const request = new DeleteRoutineRelatedRecordRequest(params);
    return this.callApi(
      this.client.deleteRoutineRelatedRecord.bind(this.client) as ApiMethod<
        DeleteRoutineRelatedRecordRequest,
        DeleteRoutineRelatedRecordResponse
      >,
      request,
    );
  }
  getMatchSite(requestParams: GetMatchSiteRequest) {
    const params = {
      action: 'GetMatchSite',
      version: '2024-09-10',
      protocol: 'https',
      method: 'GET',
      authType: 'AK',
      bodyType: 'json',
      reqBodyType: 'json',
      style: 'RPC',
      pathname: '/',
      toMap: function () {
        return this;
      },
    };
    const request = new $OpenApi.OpenApiRequest({
      query: {
        RecordName: requestParams.recordName,
      },
    });
    const runtime = {
      toMap: function () {
        return this;
      },
    };
    return this.client.callApi(params, request, runtime);
  }
  listRoutineRelatedRecords(requestParams: ListRoutineRelatedRecordsRequest) {
    const params = {
      action: 'ListRoutineRelatedRecords',
      version: '2024-09-10',
      protocol: 'https',
      method: 'GET',
      authType: 'AK',
      bodyType: 'json',
      reqBodyType: 'json',
      style: 'RPC',
      pathname: '/',
      toMap: function () {
        return this;
      },
    };
    const request = new $OpenApi.OpenApiRequest({
      query: {
        Name: requestParams.Name,
        PageNumber: requestParams.PageNumber,
        PageSize: requestParams.PageSize,
        SearchKeyWord: requestParams.SearchKeyWord,
      },
    });
    const runtime = {
      toMap: function () {
        return this;
      },
    };
    return this.client.callApi(params, request, runtime);
  }
  createRecord(params: CreateRecordRequest) {
    const request = new CreateRecordRequest(params);
    return this.callApi(
      this.client.createRecord.bind(this.client) as ApiMethod<
        CreateRecordRequest,
        CreateRecordResponse
      >,
      request,
    );
  }
  listRecords(params: ListRecordsRequest) {
    const request = new ListRecordsRequest(params);
    return this.callApi(
      this.client.listRecords.bind(this.client) as ApiMethod<
        ListRecordsRequest,
        ListRecordsResponse
      >,
      request,
    );
  }
  createSite(params: CreateSiteRequest) {
    const request = new CreateSiteRequest(params);
    return this.callApi(
      this.client.createSite.bind(this.client) as ApiMethod<
        CreateSiteRequest,
        CreateSiteResponse
      >,
      request,
    );
  }
  updateSitePause(params: UpdateSitePauseRequest) {
    params.pause = params.pause || false;
    const request = new UpdateSitePauseRequest(params);
    return this.callApi(
      this.client.updateSitePause.bind(this.client) as ApiMethod<
        UpdateSitePauseRequest,
        UpdateSitePauseResponse
      >,
      request,
    );
  }
  getSitePause(params: GetSitePauseRequest) {
    const request = new GetSitePauseRequest(params);
    return this.callApi(
      this.client.getSitePause.bind(this.client) as ApiMethod<
        GetSitePauseRequest,
        GetSitePauseResponse
      >,
      request,
    );
  }
  updateRecord(params: UpdateRecordRequest) {
    const request = new UpdateRecordRequest(params);
    return this.callApi(
      this.client.updateRecord.bind(this.client) as ApiMethod<
        UpdateRecordRequest,
        UpdateRecordResponse
      >,
      request,
    );
  }
  deleteRecord(params: DeleteRecordRequest) {
    const request = new DeleteRecordRequest(params);
    return this.callApi(
      this.client.deleteRecord.bind(this.client) as ApiMethod<
        DeleteRecordRequest,
        DeleteRecordResponse
      >,
      request,
    );
  }
  getRecord(params: GetRecordRequest) {
    const request = new GetRecordRequest(params);
    return this.callApi(
      this.client.getRecord.bind(this.client) as ApiMethod<
        GetRecordRequest,
        GetRecordResponse
      >,
      request,
    );
  }
  updateIPv6(params: UpdateIPv6Request) {
    const request = new UpdateIPv6Request(params);
    return this.callApi(
      this.client.updateIPv6.bind(this.client) as ApiMethod<
        UpdateIPv6Request,
        UpdateIPv6Response
      >,
      request,
    );
  }
  getIPv6(params: GetIPv6Request) {
    const request = new GetIPv6Request(params);
    return this.callApi(
      this.client.getIPv6.bind(this.client) as ApiMethod<
        GetIPv6Request,
        GetIPv6Response
      >,
      request,
    );
  }
  updateManagedTransform(params: UpdateManagedTransformRequest) {
    const request = new UpdateManagedTransformRequest(params);
    return this.callApi(
      this.client.updateManagedTransform.bind(this.client) as ApiMethod<
        UpdateManagedTransformRequest,
        UpdateManagedTransformResponse
      >,
      request,
    );
  }
  getManagedTransform(params: GetManagedTransformRequest) {
    const request = new GetManagedTransformRequest(params);
    return this.callApi(
      this.client.getManagedTransform.bind(this.client) as ApiMethod<
        GetManagedTransformRequest,
        GetManagedTransformResponse
      >,
      request,
    );
  }
  setCertificate(params: SetCertificateRequest) {
    const request = new SetCertificateRequest(params);
    return this.callApi(
      this.client.setCertificate.bind(this.client) as ApiMethod<
        SetCertificateRequest,
        SetCertificateResponse
      >,
      request,
    );
  }
  applyCertificate(params: ApplyCertificateRequest) {
    const request = new ApplyCertificateRequest(params);
    return this.callApi(
      this.client.applyCertificate.bind(this.client) as ApiMethod<
        ApplyCertificateRequest,
        ApplyCertificateResponse
      >,
      request,
    );
  }
  getCertificate(params: GetCertificateRequest) {
    const request = new GetCertificateRequest(params);
    return this.callApi(
      this.client.getCertificate.bind(this.client) as ApiMethod<
        GetCertificateRequest,
        GetCertificateResponse
      >,
      request,
    );
  }
  deleteCertificate(params: DeleteCertificateRequest) {
    const request = new DeleteCertificateRequest(params);
    return this.callApi(
      this.client.deleteCertificate.bind(this.client) as ApiMethod<
        DeleteCertificateRequest,
        DeleteCertificateResponse
      >,
      request,
    );
  }
  listCertificates(params: ListCertificatesRequest) {
    const request = new ListCertificatesRequest(params);
    return this.callApi(
      this.client.listCertificates.bind(this.client) as ApiMethod<
        ListCertificatesRequest,
        ListCertificatesResponse
      >,
      request,
    );
  }
  getCertificateQuota(params: GetCertificateQuotaRequest) {
    const request = new GetCertificateQuotaRequest(params);
    return this.callApi(
      this.client.getCertificateQuota.bind(this.client) as ApiMethod<
        GetCertificateQuotaRequest,
        GetCertificateQuotaResponse
      >,
      request,
    );
  }
}
export default new Client();
```
--------------------------------------------------------------------------------
/src/tools/site/record.ts:
--------------------------------------------------------------------------------
```typescript
import { CallToolRequest, Tool } from '@modelcontextprotocol/sdk/types.js';
import api from '../../utils/service.js';
import { CreateRecordRequest, UpdateRecordRequest, DeleteRecordRequest, GetRecordRequest, ListRecordsRequest } from '@alicloud/esa20240910';
export const SITE_RECORD_LIST_TOOL: Tool = {
  name: 'site_record_list',
  description: 'List DNS records associated with a specific site.',
  inputSchema: {
    type: 'object',
    properties: {
      SiteId: {
        type: 'number',
        description:
          'The ID of the site, obtained from the ListSites operation. Required.',
      },
    },
  },
};
export const CREATE_SITE_A_OR_AAAA_RECORD_TOOL: Tool = {
  name: 'create_site_a_or_aaaa_record',
  description:
    'Creates a DNS record for a specific website. Only A/AAAA records are supported.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the [ListSites] operation.',
        examples: [1234567890123],
      },
      recordName: {
        type: 'string',
        description: 'The record name.',
        examples: ['www.example.com'],
      },
      proxied: {
        type: 'boolean',
        description:
          'Specifies whether to proxy the record. Only CNAME and A/AAAA records can be proxied. Valid values:\n- true\n- false',
        examples: [true],
      },
      bizName: {
        type: 'string',
        description:
          'The business scenario of the record for acceleration. The parameter cannot be empty if your record is proxied. Valid values:\n- image_video\n- api\n- web',
        enum: ['image_video', 'api', 'web'],
        examples: ['web'],
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.',
        examples: [1],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description:
              'The IP address(es). Separate IP addresses with commas (,). You must have at least one IPv4 address. Required.',
            examples: [
              '123.123.123.123,2001:0db8:86a3:08d3:1319:8a2e:0370:7344',
            ],
          },
        },
      },
      comment: {
        type: 'string',
        description:
          'The comment of the record. The maximum length is 100 characters.',
      },
    },
    required: ['siteId', 'recordName', 'type', 'data'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
      openWorldHint: false,
    },
  },
};
export const CREATE_SITE_CNAME_RECORD_TOOL: Tool = {
  name: 'create_site_cname_record',
  description:
    'Creates a DNS record for a specific website. Only supports records with type=CNAME and sourceType=Domain.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the [ListSites] operation.',
      },
      recordName: {
        type: 'string',
        description: 'The record name.',
        examples: ['www.example.com'],
      },
      sourceType: {
        type: 'string',
        description:
          'The origin type for the CNAME record. This parameter is required when you add a CNAME record. Valid values:\n- Domain: domain name\n\nIf you do not pass this parameter or if you leave its value empty, Domain is used by default.',
        enum: ['Domain'],
        examples: ['Domain'],
      },
      bizName: {
        type: 'string',
        description:
          'The business scenario of the record for acceleration. Leave the parameter empty if your record is not proxied. Valid values:\n- image_video\n- api\n- web',
        enum: ['image_video', 'api', 'web'],
        examples: ['web'],
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.',
        examples: [1],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description: 'The target domain name. Required.',
            example: ['origin.example.com'],
          },
        },
      },
      comment: {
        type: 'string',
        description:
          'The comment of the record. The maximum length is 100 characters.',
      },
      hostPolicy: {
        type: 'string',
        description:
          'The origin host policy. This policy takes effect when the record type is CNAME. Required. You can set the policy in two modes:\n- follow_hostname\n- follow_origin_domain',
        enum: ['follow_hostname', 'follow_origin_domain'],
        examples: ['follow_hostname'],
      },
    },
    required: ['siteId', 'recordName', 'type', 'data'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
      openWorldHint: false,
    },
  },
};
export const CREATE_SITE_TXT_RECORD_TOOL: Tool = {
  name: 'create_site_txt_record',
  description:
    'Creates a DNS record for a specific website. Only TXT records are supported.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the [ListSites] operation.',
      },
      recordName: {
        type: 'string',
        description: 'The record name.',
        examples: ['www.example.com'],
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.',
        examples: [1],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description: 'A valid text string. Required.',
            example: ['xxxxxxxxxxxxxxxxxx'],
          },
        },
      },
      comment: {
        type: 'string',
        description:
          'The comment of the record. The maximum length is 100 characters.',
      },
    },
    required: ['siteId', 'recordName', 'type', 'data'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
      openWorldHint: false,
    },
  },
};
export const CREATE_SITE_NS_RECORD_TOOL: Tool = {
  name: 'create_site_ns_record',
  description:
    'Creates a DNS record for a specific website. Only NS records are supported.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the [ListSites] operation.',
      },
      recordName: {
        type: 'string',
        description: 'The record name.',
        examples: ['www.example.com'],
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.',
        examples: [1],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description: 'The name servers for the domain name. Required.',
            example: ['ns.example.com'],
          },
        },
      },
      comment: {
        type: 'string',
        description:
          'The comment of the record. The maximum length is 100 characters.',
      },
      required: ['siteId', 'recordName', 'type', 'data'],
      annotations: {
        readOnlyHint: false,
        destructiveHint: false,
        idempotentHint: false,
        openWorldHint: false,
      },
    },
  },
};
export const CREATE_SITE_MX_RECORD_TOOL: Tool = {
  name: 'create_site_mx_record',
  description:
    'Creates a DNS record for a specific website. Only MX records are supported.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description:
          'The website ID, which can be obtained by calling the [ListSites] operation.',
      },
      recordName: {
        type: 'string',
        description: 'The record name.',
        examples: ['www.example.com'],
      },
      bizName: {
        type: 'string',
        description:
          'The business scenario of the record for acceleration. Leave the parameter empty if your record is not proxied. Valid values:\n- image_video\n- api\n- web',
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. If the value is 1, the TTL of the record is determined by the system. Default: 1.',
        examples: [1],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description:
              'A valid domain name of the target mail server. Required.',
            example: ['mx.example.com'],
          },
          priority: {
            type: 'number',
            description:
              'The priority of the record, specified within the range of 0 to 65,535. A smaller value indicates a higher priority. Required.',
          },
        },
      },
      comment: {
        type: 'string',
        description:
          'The comment of the record. The maximum length is 100 characters.',
      },
    },
    required: ['siteId', 'recordName', 'type', 'data'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
      openWorldHint: false,
    },
  },
};
export const UPDATE_RECORD_TOOL: Tool = {
  name: 'update_record',
  description:
    'This operation allows you to update multiple types of DNS records, including but not limited to A/AAAA, CNAME, NS, MX, TXT, CAA, SRV, and URI. You can modify the record content by providing the necessary fields such as Value, Priority, and Flag. For origins added in CNAME records such as OSS and S3, the API enables you to configure authentication details to ensure secure access. Usage notes: The record value (Value) must match the record type. For example, the CNAME record should correspond to the target domain name. You must specify a priority (Priority) for some record types, such as MX and SRV. You must specify specific fields such as Flag and Tag for CAA records. When you update security records such as CERT and SSHFP, you must accurately set fields such as Type and Algorithm.If your origin type is OSS or S3, configure the authentication details in AuthConf based on the permissions.',
  inputSchema: {
    type: 'object',
    properties: {
      recordId: {
        type: 'number',
        description: 'The record ID, which can be obtained by calling ListRecords .',
        examples: [1234567890123],
      },
      ttl: {
        type: 'number',
        description:
          'The TTL of the record. Unit: seconds. The range is 30 to 86,400, or 1. If the value is 1, the TTL of the record is determined by the system.',
        examples: [30],
      },
      proxied: {
        type: 'boolean',
        description:
          'Specifies whether to proxy the record. Only CNAME and A/AAAA records can be proxied. Valid values: true,false',
        enum: [true, false],
        examples: [true],
      },
      type: {
        type: 'string',
        description:
          'The type of the DNS record. For example, A/AAAA, TXT, MX, NS, SRV, CAA, CERT, SMIMEA, SSHFP, TLSA, URI or CNAME.',
        enum: ['A/AAA', 'TXT', 'MX', 'NS', 'SRV', 'CAA', 'CERT', 'SMIMEA', 'SSHFP', 'TLSA', 'URI', 'CNAME'],
        examples: ['A/AAA'],
      },
      data: {
        type: 'object',
        description:
          'The DNS record information. The format of this field varies based on the record type. For more information, see https://www.alibabacloud.com/help/doc-detail/2708761.html',
        properties: {
          value: {
            type: 'string',
            description:
              'The record value or part of the record content. This parameter is required when you add A/AAAA, CNAME, NS, MX, TXT, CAA, SRV, and URI records. It has different meanings based on different types of records:A/AAAA: the IP address(es). Separate multiple IPs with commas (,). You must have at least one IPv4 address. CNAME: the target domain name. NS: the name servers for the domain name. MX: a valid domain name of the target mail server. TXT: a valid text string. CAA: a valid domain name of the certificate authority. SRV: a valid domain name of the target host. URI: a valid URI string.',
            example: ['example.com'],
          },
          priority: {
            type: 'number',
            description:
              'The priority of the record, specified within the range of 0 to 65,535. A smaller value indicates a higher priority. This parameter is required when you add MX, SRV, and URI records.',
            example: [10],
          },
          flag: {
            type: 'number',
            description:
              'The flag bit of the record. The Flag for a CAA record indicates its priority and how it is processed, specified within the range of 0 to 255. This parameter is required when you add a CAA record.',
              example: [128],
          },
          tag: {
            type: 'string',
            description:
              'The label of the record. The Tag of a CAA record indicate its specific type and usage. This parameter is required when you add a CAA record.',
            example: ['issue'],
          },
          weight: {
            type: 'number',
            description:
              'The weight of the record, specified within the range of 0 to 65,535. This parameter is required when you add SRV or URI records.',
            example: [0],
          },
          port: {
            type: 'number',
            description:
              'The port of the record, specified within the range of 0 to 65,535. This parameter is required when you add an SRV record.',
            example: [0],
          },
          type: {
            type: 'number',
            description:
              'The certificate type of the record (in CERT records), or the public key type (in SSHFP records). This parameter is required when you add CERT or SSHFP records.',
            example: [0],
          },
          keyTag: {
            type: 'number',
            description:
              'The public key identification for the record, specified within the range of 0 to 65,535. This parameter is required when you add a CAA record.',
            example: [0],
          },
          algorithm: {
            type: 'number',
            description:
              'The encryption algorithm used for the record, specified within the range from 0 to 255. This parameter is required when you add CERT or SSHFP records.',
            example: [0],
          },
          certificate: {
            type: 'string',
            description:
              'The public key of the certificate. This parameter is required when you add CERT, SMIMEA, or TLSA records.',
            example: ['dGVzdGFkYWxrcw=='],
          },
          usage: {
            type: 'number',
            description:
              'The usage identifier of the record, specified within the range of 0 to 255. This parameter is required when you add SMIMEA or TLSA records.',
            example: [0],
          },
          selector: {
            type: 'number',
            description:
              'The type of certificate or public key, specified within the range of 0 to 255. This parameter is required when you add SMIMEA or TLSA records.',
            example: [0],
          },
          matchingType: {
            type: 'number',
            description:
              'The algorithm policy used to match or validate the certificate, specified within the range 0 to 255. This parameter is required when you add SMIMEA or TLSA records.',
            example: [0],
          },
          fingerprint: {
            type: 'string',
            description: 'The public key fingerprint of the record. This parameter is required when you add a SSHFP record.',
            example: ['abcdef1234567890'],
          },
        },
      },
      sourceType: {
        type: 'string',
        description:
          'The type of the origin for the CNAME record. This parameter is required when you add a CNAME record. Valid values: OSS : OSS origin. S3 : S3 origin. LB: Load Balancer origin. OP: origin in an origin pool. Domain: common domain name. If you leave the parameter empty or set its value as null, the default is Domain, which is common domain name.',
        enum: ['OSS', 'S3', 'LB', 'OP', 'Domain', 'IP'],
        examples: ['OSS'],
      },
      bizName: {
        type: 'string',
        description:
          'The business scenario of the record for acceleration. Leave the parameter empty if your record is not proxied. Valid values: video_image: video and image. api: API. web: web page.',
        enum: ['api', 'web', 'video_image'],
        examples: ['web'],
      },
      comment: {
        type: 'string',
        description: 'The comments of the record.',
        example: ['This is a remark.'],
      },
      authConf: {
        type: 'object',
        description: 'The origin authentication information of the CNAME record.',
        properties: {
          authType: {
            type: 'string',
            description:
              'The authentication type of the origin server. Different origins support different authentication types. The type of origin refers to the SourceType parameter in this operation. If the type of origin is OSS or S3, you must specify the authentication type of the origin. Valid values: public: public read. Select this value when the origin type is OSS or S3 and the origin access is public read. private: private read. Select this value when the origin type is S3 and the origin access is private read.private_same_account: private read under the same account. Select this value when the origin type is OSS, the origins belong to the same Alibaba Cloud account, and the origins have private read access.',
            enum: ['private', 'public', 'private_same_account', 'private_cross_account'],
            examples: ['private'],
          },
          secretKey: {
            type: 'string',
            description:
              'The secret access key of the account to which the origin server belongs. This parameter is required when the SourceType is OSS, and AuthType is private_same_account, or when the SourceType is S3 and AuthType is private.',
            example: ['u0Nkg5gBK*******QF5wvKMM504JUHt'],
          },
          accessKey: {
            type: 'string',
            description:
              'The access key of the account to which the origin server belongs. This parameter is required when the SourceType is OSS, and AuthType is private_same_account, or when the SourceType is S3 and AuthType is private.',
            example: ['VIxuvJSA2S03f******kp208dy5w7'],
          },
          region: {
            type: 'string',
            description:
              'The version of the signature algorithm. This parameter is required when the origin type is S3 and AuthType is private. The following two types are supported: v2 v4. If you leave this parameter empty, the default value v4 is used.',
            enum: ['v2', 'v4'],
            examples: ['v2'],
          },
          version: {
            type: 'string',
            description:
              'The region of the origin. If the origin type is S3, you must specify this value. You can get the region information from the official website of S3.',
            example: ['us-east-1'],
          },
        },
      },
      hostPolicy: {
        type: 'string',
        description:
          'The origin host policy. This policy takes effect when the record type is CNAME. You can set the policy in two modes: follow_hostname: match the requested domain name. follow_origin_domain: match the origin\'s domain name.',
        enum: ['follow_hostname', 'follow_origin_domain'],
        example: ['follow_hostname'],
      },
    },
    required: ['recordId', 'data'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const DELETE_RECORD_TOOL: Tool = {
  name: 'delete_record',
  description: 'Deletes a DNS record of a website based on the specified RecordId.',
  inputSchema: {
    type: 'object',
    properties: {
      recordId: {
        type: 'number',
        description: 'The record ID, which can be obtained by calling ListRecords .',
        examples: [1234567890123],
      },
    },
    required: ['recordId'],
    annotations: {
      readOnlyHint: false,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const LIST_RECORDS_TOOL: Tool = {
  name: 'list_records',
  description:
    'Queries a list of Domain Name System (DNS) records of a website, including the record value, priority, and authentication configurations. Supports filtering by specifying parameters such as RecordName and RecordMatchType.',
  inputSchema: {
    type: 'object',
    properties: {
      siteId: {
        type: 'number',
        description: 'The website ID, which can be obtained by calling the ListSites operation.',
        examples: [1234567890456],
      },
      recordName: {
        type: 'string',
        description: 'The record name. This parameter specifies a filter condition for the query.',
        examples: ['www.example.com'],
      },
      recordMatchType: {
        type: 'string',
        description:
          'The match mode to search for the record name. Default value: exact. Valid values: prefix: match by prefix.suffix: match by suffix. exact: exact match. fuzzy: fuzzy match.',
        examples: ['fuzzy'],
      },
      pageNumber: {
        type: 'number',
        description: 'The page number. Default value: 1.',
        examples: [1],
      },
      pageSize: {
        type: 'number',
        description: 'The number of entries per page. Default value: 500.',
        examples: [50],
      },
      sourceType: {
        type: 'string',
        description:
          'The origin type of the record. Only CNAME records can be filtered by using this field. Valid values: OSS: OSS bucket. S3: S3 bucket. LB: load balancer. OP: origin pool. Domain: domain name.',
        enum: ['OSS', 'S3', 'LB', 'OP', 'Domain', 'IP'],
        examples: ['OSS'],
      },
      bizName: {
        type: 'string',
        description:
          'The business scenario of the record for acceleration. Valid values: image_video: video and image. api: API.web: web page.',
        enum: ['api', 'web', 'video_image'],
        examples: ['web'],
      },
      proxied: {
        type: 'boolean',
        description:
          'Filters by whether the record is proxied. Valid values:true, false',
        enum: [true, false],
        examples: [true],
      },
      type: {
        type: 'string',
        description: 'The DNS record type.',
        enum: ['A/AAA', 'TXT', 'MX', 'NS', 'SRV', 'CAA', 'CERT', 'SMIMEA', 'SSHFP', 'TLSA', 'URI', 'CNAME'],
        examples: ['A/AAA'],
      },
    },
    required: ['siteId'],
    annotations: {
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const GET_RECORD_TOOL: Tool = {
  name: 'get_record',
  description:
    'Queries the configuration of a single DNS record, such as the record value, priority, and origin authentication setting (exclusive to CNAME records).',
  inputSchema: {
    type: 'object',
    properties: {
      recordId: {
        type: 'number',
        description: 'The record ID, which can be obtained by calling ListRecords.',
        examples: [1234567890123],
      },
    },
    required: ['recordId'],
    annotations: {
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: false,
    },
  },
};
export const site_record_list = async (request: CallToolRequest) => {
  const res = await api.listRecords({
    siteId: request.params.arguments?.SiteId ?? 0,
  } as ListRecordsRequest);
  return {
    content: [
      {
        type: 'text',
        text: JSON.stringify(res),
      },
    ],
    success: true,
  };
};
export const create_site_a_or_aaaa_record = async (
  request: CallToolRequest,
) => {
  const req = request.params.arguments as CreateRecordRequest;
  req.proxied = req.proxied || false;
  req.type = 'A/AAAA';
  req.ttl = req.ttl || 1;
  const res = await api.createRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const create_site_cname_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as CreateRecordRequest;
  req.type = 'CNAME';
  req.sourceType = 'Domain';
  req.proxied = true;
  req.ttl = req.ttl || 1;
  if (req.sourceType !== 'Domain') {
    return {
      content: [{ type: 'text', text: 'sourceType must be Domain' }],
      success: false,
    };
  }
  const res = await api.createRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const create_site_txt_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as CreateRecordRequest;
  req.type = 'TXT';
  req.ttl = req.ttl || 1;
  const res = await api.createRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const create_site_ns_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as CreateRecordRequest;
  req.type = 'NS';
  req.ttl = req.ttl || 1;
  const res = await api.createRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const create_site_mx_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as CreateRecordRequest;
  req.type = 'MX';
  req.ttl = req.ttl || 1;
  const res = await api.createRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const update_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as UpdateRecordRequest;
  const res = await api.updateRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const delete_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as DeleteRecordRequest;
  const res = await api.deleteRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const list_records = async (request: CallToolRequest) => {
  const req = request.params.arguments as ListRecordsRequest;
  const res = await api.listRecords(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
export const get_record = async (request: CallToolRequest) => {
  const req = request.params.arguments as GetRecordRequest;
  const res = await api.getRecord(req);
  return {
    content: [{ type: 'text', text: JSON.stringify(res) }],
    success: true,
  };
};
```