Help Center/ FunctionGraph/ Best Practices/ Functional Application Practices/ Deploying an MCP Server Using FunctionGraph
Updated on 2025-08-22 GMT+08:00

Deploying an MCP Server Using FunctionGraph

What Is MCP Server?

Model Context Protocol (MCP) is an open-source protocol that aims to provide context information to large language models (LLMs) in a standardized manner. The MCP server runs based on the model context protocol and can seamlessly integrate LLMs with external data sources and tools. By using standardized interactions, the MCP server helps LLMs obtain abundant context information. MCP servers are widely used. For example, the file system server can assist AI in analyzing project files, and the web search server can help AI obtain the latest information.

Solution Overview

During digital transformation, if you use the traditional cloud server deployment model, you need to estimate the peak traffic and plan resources in advance. However, the static resource configuration is not suitable for services with unpredictable traffic, which may lead to underutilization of servers and waste of resources, affecting cost-effectiveness. FunctionGraph offers an efficient, flexible, and reliable solution for hosting MCP servers. With the serverless architecture, FunctionGraph can automatically adjust resource allocation based on actual traffic, improving resource utilization, reducing resource idleness, and optimizing costs.

FunctionGraph provides application templates for deploying popular open-source MCP servers in one click. You can use API Gateway (APIG) to provide services externally. FunctionGraph not only simplifies the deployment process, but also automatically processes logs and monitoring data, allowing you to focus on core service logic development.

Figure 1 MCP server template in the FunctionGraph application center

Notes and Constraints

  • Currently, the MCP server application can be deployed only in the CN North-Beijing4 region. Ensure that all resources used in this practice are deployed in the region.
  • Each application can run only one MCP server instance.

Resource and Cost Planning

Table 1 describes the resources and costs required for deploying the MCP server application.

Table 1 Resource and cost planning

Resource

Description

Billing

FunctionGraph

  • Function type: HTTP function
  • Example region: CN North-Beijing4
  • Quantity: 1
  • Billing mode: Pay-per-use
  • The first 1 million invocations are free of charge in a month. For details about the billing items, see Pay-per-Use Billing.

API Gateway (APIG)

  • Version: dedicated gateway
  • Example region: CN North-Beijing4
  • Public inbound access: enabled
  • Quantity: 1
  • Billing mode: Pay-per-use
  • Select the instance specifications and bandwidth based on your service requirements. For details about the billing items and standards, see APIG Billing Overview.

Step 1: Creating a Dedicated Gateway

  1. On the APIG console, purchase a dedicated gateway on the Buy Gateway page by referring to Creating a Gateway.
    Create a dedicated gateway named apig-fg by referring to the following parameters:
    • Region: CN North-Beijing4.
    • Public Inbound Access: Enable the public inbound access and select the bandwidth as required.
  2. In the navigation pane on the left of the APIG console, choose Gateways. On the displayed page, click Access Console.
    Figure 2 Viewing the gateway console
  3. On the Parameters tab page, click Modify on the right of the sse_strategy parameter, change the parameter value to On, and click Save to enable the SSE transmission policy.

Step 2: Create an MCP Server Application

  1. Log in to the FunctionGraph console and select the CN North-Beijing4 region.
  2. In the navigation pane on the left, choose Applications. In the upper right corner, click Create. The page for selecting a template is displayed.
  3. Find the MCP Server template and click Create Application. The page for creating an application is displayed.
  4. Set application parameters by referring to Table 2. After the configuration is complete, click Create Now.
    Figure 3 Creating an MCP Server application
    Table 2 Parameters for creating an MCP server application

    Parameter

    Example Value

    Description

    Template

    MCP Server

    The selected function template is displayed by default. To change it, click Reselect.

    Region

    CN North-Beijing4

    Select a region to create the application. This application can be created in the CN North-Beijing4 region.

    Regions are geographic areas isolated from each other. Resources are region-specific and cannot be used across regions through internal network connections. Select a region near you to ensure the lowest latency possible.

    Application Name

    fg-mcp-server

    Enter a custom application name,

    which contains 2 to 60 characters, including letters, digits, underscores (_), and hyphens (-). It must start with a letter and end with a letter or digit.

    Runtime

    HTTP

    The default runtime of the template is displayed and cannot be changed.

    Agency

    fgs-app-adminagency

    Select the agency of the function to access other cloud services.

    If the default agency fgs-app-adminagency has not been created, select Use no agency, complete other configurations, and click Create Now. The system prompts you to create an agency named fgs-app-adminagency to ensure that the application can be created.

    Create Repository

    Disabled

    When enabled, you can create a code repository in CodeArts Repo to update and deploy your application code.

    (Optional) Description

    -

    Enter a description of the application.

    It can contain up to 1,024 characters.

    APIG Instance

    apig-fg

    Select the APIG gateway created in Step 1: Creating a Dedicated Gateway.

    env

    uvx

    You can select either of the following running environments based on your requirements:

    • npx: Temporarily invokes npm packages to execute commands. It is Node.js-based and no global dependency is required.
    • uvx: temporarily installs and runs the command line tool provided by the Python package in an isolated environment.

    MCP Service Configuration

    {
      "mcpServers": {
        "fetch": {
          "command": "uvx",
          "args": [
            "mcp-server-fetch"
          ]
        }
      }
    }

    Enter the MCP service configuration in JSON format. You can customize the configuration as needed.

    The JSON configuration file defines how to obtain data from the MCP server. The following describes the parameters in the JSON configuration file in this example:

    • mcpServers: main object of the configuration file, indicating the configuration related to the MCP server.
    • fetch: configuration related to the fetch operation, which defines how to obtain data from the MCP server.
    • command: name of the command or tool used to perform the fetch operation. In this example, the uvx environment is used.
    • args: parameter list provided for the command command, which is used to notify the specific task to be executed.
  5. After the application is created, copy the APIG Trigger URL.
    By default, a temporary domain name is provided for 30 days in the test environment. In the actual production environment, prepare a custom domain name.
    Figure 4 MCP server application

Step 3: Configuring a Client to Start an AI Dialog

In this example, CherryStudio is used as the client for AI dialog. Install the CherryStudio client applicable to your device and ensure that a proper model is configured for CherryStudio to perform basic dialogs.

  1. Open the CherryStudio client, go to the settings page, click MCP Servers, and choose Add Server > Quick Create.
    Figure 5 Adding a server

  2. Set Type to Server-Sent Events (sse), enter the URL copied in 5 in the URL text box, change https to http, and add sse to the end of the URL. The configuration is complete, as shown in Figure 6. Click Save.
    Figure 6 Configuring the MCP Server

  3. After the configuration is complete, you can access the assistant page to start AI dialogs. As shown in Figure 7, the MCP server is not enabled for model dialog, and the model does not provide a normal answer.
    Figure 7 Dialog with MCP server disabled

  4. Click the MCP server button in the chat box and select the MCP server configured in 2.
    Figure 8 Configuring the MCP server

  5. After the MCP server is enabled, the model invokes the fetch tool to read the official document link and answers the question correctly, as shown in Figure 9.
    Figure 9 Dialog with MCP server enabled

More MCP Templates

FunctionGraph provides multiple popular MCP application templates to help you quickly develop MCP services. You can click Learn More of a template to view the usage description.

Figure 10 MCP-related templates

Disclaimer

  • This practice uses open-source components (supergateway, mcp-proxy, and image build project). Huawei Cloud is not responsible for these components. For open-source issues, contact their official communities. Huawei Cloud only provides computing support.
  • This practice is for reference only. If you want to use it in a production environment, test it thoroughly and evaluate the costs. For any questions, submit a service ticket.