list-function-versions
Retrieve available versions of a specific Alibaba Cloud Function Compute function to manage deployments and track changes.
Instructions
获取函数计算的函数版本列表
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| functionName | Yes | 函数名称,函数名称在每个region必须是唯一的。 | |
| 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 |
| nextToken | No | 函数版本列表的下一页token,用于分页查询函数版本列表。第一页不需要提供 | |
| direction | No | 函数版本列表的排序方向,BACKWARD表示按版本号降序,FORWARD表示按版本号升序 | BACKWARD |
| limit | No | 函数版本列表的返回数量上限,默认50,最大100 |
Implementation Reference
- src/index.ts:827-856 (handler)The handler function extracts parameters, checks credentials, creates FC client, builds and sends ListFunctionVersionsRequest to list function versions, returns success or error response.async (args) => { const { functionName, region, nextToken, direction, limit } = 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 listFunctionVersionsRequest = new ListFunctionVersionsRequest({ functionName, direction, }) if (nextToken) { listFunctionVersionsRequest.nextToken = nextToken; } if (limit) { listFunctionVersionsRequest.limit = limit; } try { const listFunctionVersionsResult = await fcClient.listFunctionVersions(functionName, listFunctionVersionsRequest); return { content: [{ type: "text", text: `获取函数版本列表成功。result: ${JSON.stringify(listFunctionVersionsResult)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `获取函数版本列表失败:${JSON.stringify(error as any)}` }] }; } }
- src/index.ts:817-857 (registration)Registers the 'list-function-versions' MCP tool with name, description, input schema, and handler function.server.tool( "list-function-versions", "获取函数计算的函数版本列表", { functionName: functionNameSchema, region: regionSchema, nextToken: listFunctionVersionsNextTokenSchema.optional(), direction: listFunctionVersionsDirectionSchema, limit: listFunctionVersionsLimitSchema.optional(), }, async (args) => { const { functionName, region, nextToken, direction, limit } = 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 listFunctionVersionsRequest = new ListFunctionVersionsRequest({ functionName, direction, }) if (nextToken) { listFunctionVersionsRequest.nextToken = nextToken; } if (limit) { listFunctionVersionsRequest.limit = limit; } try { const listFunctionVersionsResult = await fcClient.listFunctionVersions(functionName, listFunctionVersionsRequest); return { content: [{ type: "text", text: `获取函数版本列表成功。result: ${JSON.stringify(listFunctionVersionsResult)}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `获取函数版本列表失败:${JSON.stringify(error as any)}` }] }; } } )
- src/schema.ts:172-182 (schema)Zod schema definitions for pagination and filtering parameters specific to list-function-versions tool: nextToken, limit, direction.export const listFunctionsPrefixSchema = z.string().describe("函数名称前缀,用于过滤函数列表"); export const listFunctionsNextTokenSchema = z.string().describe("函数列表的下一页token,用于分页查询函数列表。第一页不需要提供"); export const listFunctionVersionsNextTokenSchema = z.string().describe("函数版本列表的下一页token,用于分页查询函数版本列表。第一页不需要提供"); export const listFunctionVersionsLimitSchema = z.number().describe("函数版本列表的返回数量上限,默认50,最大100").min(1).max(100).default(50); export const listFunctionVersionsDirectionSchema = z.enum(["BACKWARD", "FORWARD"]).describe("函数版本列表的排序方向,BACKWARD表示按版本号降序,FORWARD表示按版本号升序").default("BACKWARD"); export const versionIdSchema = z.string().describe("函数版本ID");
- src/index.ts:820-826 (schema)Input schema object composing imported Zod schemas for tool parameters.{ functionName: functionNameSchema, region: regionSchema, nextToken: listFunctionVersionsNextTokenSchema.optional(), direction: listFunctionVersionsDirectionSchema, limit: listFunctionVersionsLimitSchema.optional(), },
- src/utils/alibaba_cloud_sdk.ts:11-17 (helper)Helper function to create the Alibaba Cloud 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); }