Skip to main content
Glama
aliyun

Alibaba Cloud FC MCP Server

Official
by aliyun

publish-function-version

Publish the latest function code as a new version in Alibaba Cloud Function Compute to enable version control and deployment management.

Instructions

将函数的最新代码发布为新版本

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNameYes函数名称,函数名称在每个region必须是唯一的。
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
descriptionYes函数版本的描述,可以描述一下发布的函数版本的功能。

Implementation Reference

  • The handler function that implements the core logic for publishing a new version of the function using the Alibaba Cloud Function Compute SDK. It validates credentials, fetches account ID, creates FC client, and invokes publishFunctionVersion.
    const { functionName, region, description } = 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); try { const request = new PublishFunctionVersionRequest({ description, }) const result = await fcClient.publishFunctionVersion(functionName, request); 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 'region' parameter used in the tool.
    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");
  • Zod schema definition for the 'functionName' parameter used in the tool.
    export const functionNameSchema = z.string().describe("函数名称,函数名称在每个region必须是唯一的。") .regex(/^[a-zA-Z0-9_][a-zA-Z0-9_-]{0,63}$/);
  • Zod schema definition for the 'description' parameter used in the tool.
    export const functionVersionDescriptionSchema = z.string().describe("函数版本的描述,可以描述一下发布的函数版本的功能。");
  • src/index.ts:785-814 (registration)
    MCP server tool registration for 'publish-function-version', specifying name, description, input schema, and inline handler function.
    "publish-function-version", "将函数的最新代码发布为新版本", { functionName: functionNameSchema, region: regionSchema, description: functionVersionDescriptionSchema, }, async (args) => { const { functionName, region, description } = 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); try { const request = new PublishFunctionVersionRequest({ description, }) const result = await fcClient.publishFunctionVersion(functionName, request); return { content: [{ type: "text", text: `发布函数版本成功。result: ${JSON.stringify(result)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `发布函数版本失败:${JSON.stringify(error as any)}` }] }; } } )
  • Helper function to create the Alibaba Cloud Function Compute (FC) client instance used in the handler.
    export function createFcClient(regionId: string) { const config = new $OpenApi.Config({ credential: getCredentialClient(), endpoint: `fcv3.${regionId}.aliyuncs.com`, }); return new FCClient(config); }

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