All Products
Search
Document Center

Platform For AI:Build a ChatBI agent with LangStudio and Hologres

Last Updated:Aug 21, 2026

Build an intelligent data analysis assistant with LangStudio that answers natural language questions by querying your database. The solution connects a large language model (LLM) with tool-calling capabilities to a database through the Model Context Protocol (MCP), using the Qwen model and Hologres as an example.

Solution overview

LangStudio connects three core components into a complete data analysis application:

  1. Large language model (LLM): A Qwen model that supports tool calling acts as the application's "brain" and is responsible for understanding your natural language questions.

  2. MCP server: This component acts as a bridge, translating instructions from the LLM, such as "query the user table," into SQL statements that Hologres can execute. This topic uses an MCP server for Hologres deployed on FC as an example.

  3. LangStudio Agent: As the application's orchestration center, it receives your question, directs the LLM to process it, and interacts with the Hologres database through the MCP server. Finally, it formats the query results into a user-friendly answer.

Billing

This tutorial uses several paid cloud services. Review their billing policies before you start, and release all resources after you finish to avoid unexpected charges.

Prerequisites

Before you begin, complete the following prerequisites:

  1. Plan your network environment: For secure and efficient communication between components, deploy all resources in the same region and VPC. If you do not have a VPC, create a VPC and a vSwitch and create a security group.

  2. Prepare a Hologres instance and data:

    1. You can use an existing Hologres instance or purchase a Hologres instance. When purchasing the instance, select the correct VPC.

    2. Create a database and import the tpch_10g public dataset for testing.

Step 1: Create a model service connection

1.1 (Optional) Deploy a model service

Deploy the Qwen3-32B model service from the Getting Started > Model Gallery page with a single click.

In the search box, enter Qwen3-32B, click Deploy on the model card, and use the default parameters.

Note

The model service in this topic must support tool calling.

1.2 Create a connection

Note

If you are not using an EAS model service, select an appropriate model service connection for your service type. For more information, see Connection configuration.

Go to LangStudio. On the Connection > Model Service tab, click New Connection and configure the following parameters:

  • Connection Type: Select Generic LLM Model Service Connection.

  • Service Provider: Select PAI-EAS Model Service. When you select the deployed EAS service from the drop-down list, LangStudio automatically populates the base_url and api_key fields with the VPC endpoint and token of the service.

  • Tool Call: This option is automatically selected for models deployed from the Model Gallery. If you deployed your model using another method, configure this parameter based on your setup.

Step 2: Create an MCP service connection

The MCP server bridges the agent and the Hologres database by exposing database operations as a standard tool interface.

In LangStudio, you can quickly deploy the Hologres MCP server from an MCP template.

  1. Go to LangStudio. On the Explore > MCP Template tab, search for Hologres.

  2. Click the aliyun-hologres-mcp-server card. In the right-side panel that appears, configure the following deployment parameters. Leave other parameters at their default values:

    1. Region: Select the same region as your Hologres instance.

    2. Function Compute Access Hologres Service Role: Select AliyunFCDefaultRole. If this role does not exist, click Create Role. In the Hologres console, you must then create a user with this role and grant the necessary permissions.

      Grant Hologres permissions to the service role

      1. Add a user.

        In the left-side navigation pane, click User Management, and then click Add User in the upper-right corner. In the Add User dialog box, search for and select the AliyunFCDefaultRole role. In the Select Member Role section, select Common User, and then click OK.

      2. If the user only needs to query data, use the simple permission model and grant only viewer permissions.

        In the left-side navigation pane of the HoloWeb console, choose Security Center > DB Authorization. Find the target database and click User Authorization in the Actions column.

        In the Add Authorization dialog box, set User to role/AliyunFCDefaultRole, set User Group to the permission level that you need (Admin, Developer, Writer, or Viewer), and then click OK.

    3. VPC ID: Select the same VPC as your Hologres instance. Follow the instructions on the page to select a vSwitch and a security group.

    4. Hologres Instance Host: Enter the domain name for the VPC access endpoint of your Hologres instance. You can find it in Network Information on the Hologres instance details page.

  3. After the deployment is complete, the service name and address appear in the right-side panel. Click Online Test to verify the connection between the MCP server and the Hologres instance.

    Note

    The service address displayed here is the public endpoint. To get the VPC endpoint, click the arrow next to the service name to go to the Access Address tab of the service details page.

  4. On the Tools > MCP Tool tab, LangStudio automatically creates a connection for this MCP service.

    The connection record shows the connection name and ID, the connection type (for example, Function AI), the creator, the creation time, the update time, and available actions such as Delete.

    Note

    MCP servers created in LangStudio through templates or custom settings automatically generate connection configurations. If you deploy your own MCP service or use a third-party hosting platform, create a connection and configure it manually.

Step 3: Create a runtime

On the Runtime tab, click New Runtime to create a runtime, which provides the execution environment for your application flow.

Important

If you use an existing runtime, update its image to the latest version.

Step 4: Create an application flow

  1. On the Applications tab, click Create Application and select the Intelligent Data Agent template.

  2. Click the application flow you just created to open its details page. Click the Agent node and configure the following settings:

    1. Agent Strategy: Select FunctionCalling.

    2. Model Settings: Select the model connection that you created in Step 1.2.

    3. Conversation History: Enable this option.

    4. MCP Service Configuration: Click Add MCP Server. Set Type to connection and select the MCP service connection created in Step 2.

    5. Configure the Input Variables, including the System Prompt and USER prompt. Set the Maximum Loop Count to 5. You can adjust this value as needed.

Step 5: Test and verify

After you finish the configuration, click Run in the upper-right corner to open the chat interface and test the application.

The public dataset imported into Hologres has multiple schemas. If you ask about tables directly, the agent might not respond correctly. Use the following prompts to guide it:

  1. What schemas are in Hologres?

  2. What tables are in the hologres_dataset_tpch_10g schema?

  3. Calculate the number of distinct countries that customers come from.

Recommendations for production use

After you debug and verify your application in LangStudio, deploy it as a production-grade API service.

  • Deploy the application flow: In the upper-right corner of the LangStudio application flow canvas, click Deploy. Select an appropriate resource specification, and make sure to select the same VPC and vSwitch as your other components to ensure network connectivity. For more information, see Deploy an application flow.

  • Configure public network access: If your application flow needs to access other services over the internet, enable public network access when deploying it as an EAS service.

  • Cost and performance: Select the resource specifications and number of instances for the EAS service based on your business workload to balance performance and cost. After you finish testing, release all resources to avoid unnecessary charges.

FAQ

  1. Can I connect to other types of databases, such as MySQL or PostgreSQL?

    Yes. You can query other data sources by replacing the Hologres MCP server in the agent settings with an MCP server for your target database. You will need to find or develop an appropriate MCP server.

  2. Can I build an agent application with a model that does not support tool calling?

    Yes. In the Agent node settings, select the ReAct Strategy. This strategy does not require the model to support tool calling. However, for best results, use a model with strong reasoning capabilities.