Integrate MCP Server with TrAE
Model Context Protocol (MCP) is an open-source protocol introduced by Anthropic in November 2024. It allows large language models to interact with external tools or data sources. With MCP, you do not need to manually copy and execute the output of large language models. Instead, the large language model can directly command tools to perform specific actions.
The MCP Server provides the capability for large models to interact with SeekDB through the MCP protocol and can execute SQL statements. With the right client, you can quickly set up a project prototype. It has been open-sourced on GitHub.
TRAE is an IDE that can integrate with MCP Server, can be downloaded from its official website.
This topic will show you how to use Trae IDE to integrate with seekdb MCP Server and quickly build a backend application.
Prerequisites
-
You have deployed seekdb.
-
You have installed Python 3.11 or later and the corresponding pip. If your system has a low Python version, you can use Miniconda to create a new Python 3.11 or later environment. For more information, see Install Miniconda.
-
You have installed uv, a Python package manager. After the installation, run the
uv --versioncommand to check whether the installation was successful:pip install uv
uv --version -
You have downloaded TRAE IDE and installed the version suitable for your operating system.
Step 1: Obtain the database connection information
Contact your seekdb deployment engineer or administrator to obtain the database connection string. For example:
mysql -h$host -P$port -u$user_name -p$password -D$database_name
Parameters:
-
$host: The IP address for connecting to seekdb. -
$port: The port number for connecting to seekdb. Default is2881. -
$database_name: The name of the database to access.tipThe connected user must have
CREATE,INSERT,DROP, andSELECTprivileges on the database. -
$user_name: The username for connecting to the database. -
$password: The password for the account.
Step 2: Configure the seekdb MCP Server
Install the seekdb MCP Server
Run the following command to install the seekdb MCP Server:
pip install seekdb-mcp-server
Configure the seekdb server environment variables in the .env file
Create a file named .env in the current directory and add the following content:
vi .env
SEEKDB_HOST=localhost # Database host
SEEKDB_PORT=2881 # Database port (default: 2881)
SEEKDB_USER=your_username
SEEKDB_PASSWORD=your_password
SEEKDB_DATABASE=your_database
Start in SSE mode
env $(cat .env | xargs) uvx seekdb-mcp-server --transport sse --port 8000 --host 0.0.0.0
Create a working directory for the TRAE client and configure the seekdb MCP Server
Manually create a working directory for TRAE and open it. TRAE will generate files in this directory. The example directory name is trae-generate.
Press Ctrl + U (Windows) or Command + U (MacOS) to open the chat box. Click the gear icon in the upper-right corner and select MCP.

Configure the seekdb MCP Server
-
Click Add Custom MCP and fill in the configuration file.

-
Fill in the configuration file and click OK.
{
"mcpServers": {
"sse-seekdb": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"type": "sse",
"url": "http://ip:port/sse"
}
}
} -
The configuration is successful.

Test the MCP server
-
Select the Builder with MCP agent.

-
In the dialog box, enter
How many tables in the test database?. The TRAE client will execute the command and display the names of all tables in thetestdatabase. This indicates that you have successfully connected to seekdb.
Create a RESTful API project using FastAPI
You can use FastAPI to quickly create a RESTful API project. FastAPI is a Python web framework that enables you to build RESTful APIs efficiently.
-
Create the customer table.
In the dialog box, enter
Create a "customer" table with "ID" as the primary key and containing fields such as "name", "age", "telephone", and "location". Confirm the SQL statement and click theAcceptbutton.
-
Insert test data.
In the dialog box, enter
Insert 10 pieces of data into the customer table.
-
Create a FastAPI project.
In the dialog box, enter
Create a FastAPI project on the customer table.
This step will generate multiple files. We recommend that you select
Accept Allfor the first use, because the files generated by AI may contain uncertain contents. You can adjust them based on your actual needs later. -
FastAPI project configuration database connection information

-
Install project dependencies
Execute the following command to install the project dependencies:
pip install -r requirements.txt -
Start the FastAPI project.
Run the following command to start the FastAPI project:
source .env
uvicorn main:app --reload -
View the data in the table.
Run the following command in the command line or use other request tools to view the data in the table:
curl http://127.0.0.1:8000/customersThe return result is as follows:
[{"name":"John Smith","age":35,"telephone":"555-1234","location":"New York, NY","ID":1},{"name":"Sarah Johnson","age":28,"telephone":"555-5678","location":"Los Angeles, CA","ID":2},{"name":"Michael Brown","age":42,"telephone":"555-9012","location":"Chicago, IL","ID":3},{"name":"Emma Davis","age":31,"telephone":"555-3456","location":"Houston, TX","ID":4},{"name":"James Wilson","age":45,"telephone":"555-7890","location":"Phoenix, AZ","ID":5},{"name":"Olivia Taylor","age":26,"telephone":"555-2345","location":"Philadelphia, PA","ID":6},{"name":"William Anderson","age":38,"telephone":"555-6789","location":"San Antonio, TX","ID":7},{"name":"Ava Thomas","age":33,"telephone":"555-0123","location":"San Diego, CA","ID":8},{"name":"Benjamin Martinez","age":40,"telephone":"555-4567","location":"Dallas, TX","ID":9},{"name":"Sophia Garcia","age":29,"telephone":"555-8901","location":"Austin, TX","ID":10}]