Skip to main content
Glama
aliyun

Alibaba Cloud FC MCP Server

Official
by aliyun

create-custom-domain-config

Configure custom domain routing for Alibaba Cloud Function Compute by setting up domain-to-function mappings with protocol, authentication, and TLS options.

Instructions

创建函数计算的域名路由配置,域名必须已经CNAME到函数计算的公网域名(格式为${uid}.${regionId}.fc.aliyuncs.com,例如14**49.cn-hangzhou.fc.aliyuncs.com)上,否则会创建失败。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNo部署的区域,当前可选的区域是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-hangzhoucn-hangzhou
createCustomDomainConfigYes

Implementation Reference

  • src/index.ts:715-752 (registration)
    Registration of the 'create-custom-domain-config' tool, including the inline handler function that uses Alibaba Cloud FC SDK to create the custom domain configuration.
    server.tool(
        "create-custom-domain-config",
        "创建函数计算的域名路由配置,域名必须已经CNAME到函数计算的公网域名(格式为${uid}.${regionId}.fc.aliyuncs.com,例如14**49.cn-hangzhou.fc.aliyuncs.com)上,否则会创建失败。",
        {
            region: regionSchema,
            createCustomDomainConfig: createCustomDomainConfigSchema,
        },
        async (args) => {
            const { region, createCustomDomainConfig } = 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 createCustomDomainRequest: CreateCustomDomainRequest = new CreateCustomDomainRequest({
                body: {
                    domainName: createCustomDomainConfig.domain,
                    protocol: createCustomDomainConfig.protocol,
                    routeConfig: createCustomDomainConfig.routeConfig,
                    authConfig: createCustomDomainConfig.authConfig,
                    certConfig: createCustomDomainConfig.certConfig,
                    tlsConfig: createCustomDomainConfig.tlsConfig,
                    wafConfig: createCustomDomainConfig.wafConfig,
                },
            });
            try {
                const result = await fcClient.createCustomDomain(createCustomDomainRequest);
                return { content: [{ type: "text", text: `创建域名路由配置成功。result: ${JSON.stringify(result)}` }] };
            } catch (error) {
                return { isError: true, content: [{ type: "text", text: `创建域名路由配置失败:${JSON.stringify(error as any)}` }] };
            }
        }
    )
  • The handler function that extracts arguments, creates FC client, prepares CreateCustomDomainRequest, and calls fcClient.createCustomDomain to implement the tool logic.
        async (args) => {
            const { region, createCustomDomainConfig } = 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 createCustomDomainRequest: CreateCustomDomainRequest = new CreateCustomDomainRequest({
                body: {
                    domainName: createCustomDomainConfig.domain,
                    protocol: createCustomDomainConfig.protocol,
                    routeConfig: createCustomDomainConfig.routeConfig,
                    authConfig: createCustomDomainConfig.authConfig,
                    certConfig: createCustomDomainConfig.certConfig,
                    tlsConfig: createCustomDomainConfig.tlsConfig,
                    wafConfig: createCustomDomainConfig.wafConfig,
                },
            });
            try {
                const result = await fcClient.createCustomDomain(createCustomDomainRequest);
                return { content: [{ type: "text", text: `创建域名路由配置成功。result: ${JSON.stringify(result)}` }] };
            } catch (error) {
                return { isError: true, content: [{ type: "text", text: `创建域名路由配置失败:${JSON.stringify(error as any)}` }] };
            }
        }
    )
  • Zod schema definition for the input parameter 'createCustomDomainConfig', which defines the structure for creating custom domain config including domain, protocol, routes, auth, cert, tls, and waf.
    export const createCustomDomainConfigSchema = z.object({
        domain: domainSchema,
        protocol: protocolSchema.optional(),
        routeConfig: routeConfigSchema,
        authConfig: authConfigSchema,
        certConfig: certConfigSchema.optional(),
        tlsConfig: tlsConfigSchema.optional(),
        wafConfig: wafConfigSchema.optional(),
    });
  • Import of helper functions createFcClient and getAccountId used in the handler to create the FC client and get account ID.
    import { createFcClient, getAccountId } from "./utils/alibaba_cloud_sdk.js";
  • Supporting schema for routeConfig, which is part of createCustomDomainConfigSchema.
    export const routeConfigSchema = z.object({
        routes: z.array(pathConfigSchema).describe("路由配置"),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aliyun/alibabacloud-fc-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server