Skip to main content
Glama
aliyun

Alibaba Cloud FC MCP Server

Official
by aliyun

get-function

Retrieve detailed information about deployed serverless functions in Alibaba Cloud Function Compute, including configuration and metadata for management and monitoring.

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

Implementation Reference

  • The handler function that implements the core logic of the 'get-function' tool. It retrieves detailed information about a specific function from Alibaba Cloud Function Compute (FC), including checks for custom domain configuration, using the FC SDK client.
    async (args) => {
        const { functionName, region } = 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);
        let getFunctionResult;
        try {
            const getFunctionRequest = new GetFunctionRequest({})
            getFunctionResult = await fcClient.getFunction(functionName, getFunctionRequest)
        } catch (error) {
            return { isError: true, content: [{ type: "text", text: `获取函数信息失败:${JSON.stringify(error as any)}` }] };
        }
    
        const functionInfo = {
            ...getFunctionResult.body,
        }
        const autoDomainName = getAutoCustomDomainName(accountId, functionName, region);
        let getCustomDomainResult;
        try {
            getCustomDomainResult = await fcClient.getCustomDomain(autoDomainName);
        } catch (error: any) {
            if (error.statusCode !== 404) {
                return { isError: true, content: [{ type: "text", text: `获取函数域名信息失败:${JSON.stringify(error as any)}` }] };
            }
            getCustomDomainResult = null;
        }
        if (getCustomDomainResult) {
            const routes = getCustomDomainResult.body?.routeConfig?.routes
            if (routes && routes.length == 1) {
                const route = routes[0];
                if (route.functionName == functionName) {
                    functionInfo.domain = autoDomainName;
                }
            }
        }
        return { content: [{ type: "text", text: `获取函数信息: ${JSON.stringify(functionInfo)}` }] };
    }
  • src/index.ts:533-584 (registration)
    The registration of the 'get-function' MCP tool using server.tool(), including the tool name, description, input schema parameters (functionName and region), and inline handler.
    server.tool(
        "get-function",
        "获取创建的函数计算的函数信息",
        {
            functionName: functionNameSchema,
            region: regionSchema,
        },
        async (args) => {
            const { functionName, region } = 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);
            let getFunctionResult;
            try {
                const getFunctionRequest = new GetFunctionRequest({})
                getFunctionResult = await fcClient.getFunction(functionName, getFunctionRequest)
            } catch (error) {
                return { isError: true, content: [{ type: "text", text: `获取函数信息失败:${JSON.stringify(error as any)}` }] };
            }
    
            const functionInfo = {
                ...getFunctionResult.body,
            }
            const autoDomainName = getAutoCustomDomainName(accountId, functionName, region);
            let getCustomDomainResult;
            try {
                getCustomDomainResult = await fcClient.getCustomDomain(autoDomainName);
            } catch (error: any) {
                if (error.statusCode !== 404) {
                    return { isError: true, content: [{ type: "text", text: `获取函数域名信息失败:${JSON.stringify(error as any)}` }] };
                }
                getCustomDomainResult = null;
            }
            if (getCustomDomainResult) {
                const routes = getCustomDomainResult.body?.routeConfig?.routes
                if (routes && routes.length == 1) {
                    const route = routes[0];
                    if (route.functionName == functionName) {
                        functionInfo.domain = autoDomainName;
                    }
                }
            }
            return { content: [{ type: "text", text: `获取函数信息: ${JSON.stringify(functionInfo)}` }] };
        }
    )
  • Zod schema definition for 'region' input parameter used in 'get-function' tool validation.
    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 'functionName' input parameter used in 'get-function' tool validation.
    export const functionNameSchema = z.string().describe("函数名称,函数名称在每个region必须是唯一的。")
        .regex(/^[a-zA-Z0-9_][a-zA-Z0-9_-]{0,63}$/);
  • Helper function to create an Alibaba Cloud FC client instance, used in the 'get-function' handler.
    export function createFcClient(regionId: string) {
      const config = new $OpenApi.Config({
        credential: getCredentialClient(),
        endpoint: `fcv3.${regionId}.aliyuncs.com`,
      });
      return new FCClient(config);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it retrieves information, implying a read-only operation, but doesn't specify whether it requires authentication, rate limits, error conditions, or what information is returned. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero waste, making it easy for an AI agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a read operation with 2 parameters), 100% schema coverage, and no output schema, the description is minimally adequate. It states what the tool does but lacks details on behavioral aspects (e.g., authentication, error handling) and doesn't guide usage relative to siblings. Without annotations or output schema, more context would be helpful for completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters ('functionName' and 'region') well-documented in the schema. The description doesn't add any meaning beyond what the schema provides (e.g., it doesn't explain parameter interactions or usage nuances). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取创建的函数计算的函数信息' clearly states the purpose: retrieving information about a created function in function computing. It specifies the verb '获取' (get/retrieve) and the resource '函数计算的函数信息' (function computing function information). However, it doesn't explicitly differentiate from sibling tools like 'list-functions' or 'get-custom-domain-config', which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention siblings like 'list-functions' (for listing multiple functions) or 'get-custom-domain-config' (for different resource types), nor does it specify prerequisites such as needing an existing function. Usage is implied by the action but not explicitly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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