update-custom-domain-config
Modify or update custom domain routing configurations for function compute, including protocols, routes, authentication, and TLS settings, to manage serverless functions effectively.
Instructions
更新函数计算的域名路由配置,修改域名路由配置
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | 域名,例如example.com,域名不能带有'https://'或'http://'等协议内容 | |
| region | No | 部署的区域,当前可选的区域是cn-hangzhou, cn-shanghai, cn-beijing, cn-shenzhen, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1, me-east-1, cn-chengdu, cn-wulanchabu, cn-guangzhou,默认是cn-hangzhou | cn-hangzhou |
| updateCustomDomainConfig | Yes |
Implementation Reference
- src/index.ts:683-711 (handler)Asynchronous handler function that extracts arguments, checks credentials, creates FC client, builds UpdateCustomDomainRequest from input, calls updateCustomDomain API, and returns success or error result.async (args) => { const { region, domain, updateCustomDomainConfig } = args; const accessKeyId = process.env.ALIBABA_CLOUD_ACCESS_KEY_ID; const accessKeySecret = process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET; if (!accessKeyId || !accessKeySecret) { return { isError: true, content: [{ type: "text", text: `执行失败,请设置ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET, ALIBABA_CLOUD_SECURITY_TOKEN环境变量` }] }; } const accountId = await getAccountId(); if (!accountId) { return { isError: true, content: [{ type: "text", text: `执行失败,获取accountId异常` }] }; } const fcClient = createFcClient(region); const updateCustomDomainRequest: UpdateCustomDomainRequest = new UpdateCustomDomainRequest({ body: { authConfig: updateCustomDomainConfig.authConfig, certConfig: updateCustomDomainConfig.certConfig, tlsConfig: updateCustomDomainConfig.tlsConfig, wafConfig: updateCustomDomainConfig.wafConfig, routeConfig: updateCustomDomainConfig.routeConfig, protocol: updateCustomDomainConfig.protocol, }, }); try { const result = await fcClient.updateCustomDomain(domain, updateCustomDomainRequest); return { content: [{ type: "text", text: `更新域名路由配置成功。result: ${JSON.stringify(result)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `更新域名路由配置失败:${JSON.stringify(error as any)}` }] }; } }
- src/index.ts:675-712 (registration)MCP server.tool registration for 'update-custom-domain-config' tool, including name, description, input schema parameters, and handler reference.server.tool( "update-custom-domain-config", "更新函数计算的域名路由配置,修改域名路由配置", { region: regionSchema, domain: domainSchema, updateCustomDomainConfig: updateCustomDomainConfigSchema, }, async (args) => { const { region, domain, updateCustomDomainConfig } = args; const accessKeyId = process.env.ALIBABA_CLOUD_ACCESS_KEY_ID; const accessKeySecret = process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET; if (!accessKeyId || !accessKeySecret) { return { isError: true, content: [{ type: "text", text: `执行失败,请设置ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET, ALIBABA_CLOUD_SECURITY_TOKEN环境变量` }] }; } const accountId = await getAccountId(); if (!accountId) { return { isError: true, content: [{ type: "text", text: `执行失败,获取accountId异常` }] }; } const fcClient = createFcClient(region); const updateCustomDomainRequest: UpdateCustomDomainRequest = new UpdateCustomDomainRequest({ body: { authConfig: updateCustomDomainConfig.authConfig, certConfig: updateCustomDomainConfig.certConfig, tlsConfig: updateCustomDomainConfig.tlsConfig, wafConfig: updateCustomDomainConfig.wafConfig, routeConfig: updateCustomDomainConfig.routeConfig, protocol: updateCustomDomainConfig.protocol, }, }); try { const result = await fcClient.updateCustomDomain(domain, updateCustomDomainRequest); return { content: [{ type: "text", text: `更新域名路由配置成功。result: ${JSON.stringify(result)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `更新域名路由配置失败:${JSON.stringify(error as any)}` }] }; } } )
- src/schema.ts:90-97 (schema)Zod schema definition for updateCustomDomainConfig input object, composing sub-schemas for protocol, routes, auth, cert, TLS, and WAF configurations.export const updateCustomDomainConfigSchema = z.object({ protocol: protocolSchema.optional(), routeConfig: routeConfigSchema, authConfig: authConfigSchema, certConfig: certConfigSchema.optional(), tlsConfig: tlsConfigSchema.optional(), wafConfig: wafConfigSchema.optional(), });
- src/schema.ts:3-6 (schema)Zod schema for 'region' parameter used in tool input.// region schema export const regionSchema = z.enum(['cn-hangzhou', 'cn-shanghai', 'cn-beijing', 'cn-shenzhen', 'cn-hongkong', 'ap-southeast-1', 'ap-southeast-2', 'ap-southeast-3', 'ap-southeast-5', 'ap-northeast-1', 'eu-central-1', 'eu-west-1', 'us-west-1', 'us-east-1', 'ap-south-1', 'me-east-1', 'cn-chengdu', 'cn-wulanchabu', 'cn-guangzhou']) .default('cn-hangzhou') .describe("部署的区域,当前可选的区域是cn-hangzhou, cn-shanghai, cn-beijing, cn-shenzhen, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1, me-east-1, cn-chengdu, cn-wulanchabu, cn-guangzhou,默认是cn-hangzhou");
- src/schema.ts:99-99 (schema)Zod schema for 'domain' parameter used in tool input.export const domainSchema = z.string().describe("域名,例如example.com,域名不能带有'https://'或'http://'等协议内容");