MCP (Model Context Protocol) is an open-source protocol launched by Anthropic in November 2024, designed to enable large language models (LLMs) to interact with external tools or data sources. With MCP, users no longer need to manually copy and execute the output of the large model; instead, the large model can directly command the tool to perform the corresponding action (Action).
OceanBase MCP Server provides the capability for large models to interact with OceanBase Database through the MCP protocol, allowing the execution of SQL statements. With the right client, you can quickly build a project prototype, and it is already open-sourced on GitHub.
Augment Code is a developer AI platform that helps you understand your code, debug issues, and release faster by being familiar with your codebase. It allows you to do more work through chat, next-step editing, and code completion.
This article will demonstrate how to use Augment Code to quickly build a backend application using OceanBase MCP Server.
Prerequisites
You have deployed OceanBase Database and created a MySQL user tenant. For more information, see Create a tenant.
Install Python 3.11 or later and the corresponding pip. If your system has a lower version of Python, you can use Miniconda to create a new environment with Python 3.11 or later. For more information, see Miniconda installation guide.
Install Git based on your operating system. Download and install it according to your operating system:
Windows: https://git-scm.com/downloads/win.
macOS: https://git-scm.com/download/mac.
Linux: https://git-scm.com/downloads/linux.
Install the Python package manager uv.
For macOS and Linux, you can install it using the standalone script:
curl -LsSf https://astral.sh/uv/install.sh | shFor Windows, use the following script:
irm https://astral.sh/uv/install.ps1 | iexAlternatively, you can install it using pip:
pip install uv
After installation, you can verify it by running the
uv --versioncommand:pip install uv uv --versionInstall Augment Code:
Open VS Code (if not installed, refer to the official documentation for installation).
Click the Extensions icon in the sidebar.
Search for "Augment Code" and click Install.
Register and log in to your Augment Code account.

Step 1: Obtain the database connection information
Contact the deployment personnel or administrator of OceanBase Database to obtain the database connection string. For example:
obclient -h$host -P$port -u$user_name -p$password -D$database_name
Parameters:
$host: the IP address for connecting to OceanBase Database. If you connect through OceanBase Database Proxy (ODP), use the IP address of an ODP. If you connect directly to an OBServer node, use the IP address of the OBServer node.$port: the port for connecting to OceanBase Database. The default port for connecting through ODP is2883, which can be customized when you deploy ODP. The default port for direct connection is2881, which can be customized when you deploy OceanBase Database.$database_name: the name of the database to be accessed.Notice
The user for connecting to the tenant must have the
CREATE,INSERT,DROP, andSELECTprivileges on the database. For more information about user privileges, see Privilege types in MySQL-compatible mode.$user_name: the username for connecting to the tenant. The username for connecting through ODP is in theusername@tenant name#cluster nameorcluster name:tenant name:usernameformat. The username for direct connection is in theusername@tenant nameformat.$password: the password of the account.
For more information about the connection string, see Connect to an OceanBase tenant by using OBClient.
Step 2: Configure OceanBase MCP Server
Clone the OceanBase MCP Server repository
Run the following command to download the source code to your local machine:
git clone https://github.com/oceanbase/awesome-oceanbase-mcp.git
Navigate to the source code directory:
cd awesome-oceanbase-mcp
Install dependencies
In the oceanbase_mcp_server directory, run the following commands to create a virtual environment and install the dependencies:
uv venv
source .venv/bin/activate
uv pip install .
Add and configure MCP Servers
Configure OceanBase MCP Server in Augment Code.

Click Import from json and fill in the MCP configuration file.


Fill in the configuration file and click Confirm.
Replace
/path/to/your/oceanbase_mcp_serverwith the absolute path to theoceanbase_mcp_serverfolder, and replaceOB_HOST,OB_PORT,OB_USER,OB_PASSWORD, andOB_DATABASEwith the corresponding information from your database:{ "mcpServers": { "oceanbase": { "command": "uv", "args": [ "--directory", "/path/to/your/oceanbase_mcp_server/src/oceanbase_mcp_server", "run", "oceanbase_mcp_server" ], "env": { "OB_HOST": "***", "OB_PORT": "***", "OB_USER": "***", "OB_PASSWORD": "***", "OB_DATABASE": "***" } } } }Verify the ability to connect to the database.
Enter the prompt "Create a customer table with ID as the primary key, including name, age, telephone, and location fields":

Augment Code will display the number of tables in the test database, indicating a successful connection to the OceanBase database.
Step 3: Use FastAPI to quickly create a RESTful API project
FastAPI is a Python web framework that allows you to build RESTful APIs quickly.
Create a table.
Enter the prompt "Create a customer table with ID as the primary key, and fields for name, age, telephone, and location":

Insert test data.
Enter the prompt "Insert 10 test data entries":

Create a FastAPI project.
Enter the prompt "Create a FastAPI project and generate a RESTful API based on the customer table". This will automatically generate multiple files, fix the code, and start the FastAPI project:


View the data in the table.
Run the command
curl http://127.0.0.1:8000/customersin the command line, or use another request tool to view the data in the table:curl http://127.0.0.1:8000/customers [{"name":"Zhang San","age":28,"telephone":"13812345678","location":"Chaoyang District, Beijing","id":1},{"name":"Li Si","age":35,"telephone":"13987654321","location":"Pudong New Area, Shanghai","id":2},{"name":"Wang Wu","age":42,"telephone":"15612345678","location":"Tianhe District, Guangzhou","id":3},{"name":"Zhao Liu","age":29,"telephone":"18712345678","location":"Nanshan District, Shenzhen","id":4},{"name":"Qian Qi","age":33,"telephone":"13512345678","location":"West Lake District, Hangzhou","id":5},{"name":"Sun Ba","age":26,"telephone":"15987654321","location":"Jinjiang District, Chengdu","id":6},{"name":"Zhou Jiu","age":38,"telephone":"18612345678","location":"Jinghan District, Wuhan","id":7},{"name":"Wu Shi","age":31,"telephone":"13712345678","location":"Gulou District, Nanjing","id":8},{"name":"Zheng Shiyi","age":45,"telephone":"15812345678","location":"Yanta District, Xi'an","id":9},{"name":"Wang Shier","age":27,"telephone":"18512345678","location":"Yuzhong District, Chongqing","id":10},{"name":"Test User","age":25,"telephone":"13900000000","location":"Test Address","id":11}]The code for adding, deleting, modifying, and querying data has been generated.
from sqlalchemy.orm import Session from database import Customer from schemas import CustomerCreate, CustomerUpdate from typing import List, Optional def get_customer(db: Session, customer_id: int) -> Optional[Customer]: """Get a customer by ID.""" return db.query(Customer).filter(Customer.id == customer_id).first() def get_customers(db: Session, skip: int = 0, limit: int = 100) -> List[Customer]: """Get a list of customers.""" return db.query(Customer).offset(skip).limit(limit).all() def create_customer(db: Session, customer: CustomerCreate) -> Customer: """Create a new customer.""" db_customer = Customer(**customer.dict()) db.add(db_customer) db.commit() db.refresh(db_customer) return db_customer def update_customer(db: Session, customer_id: int, customer: CustomerUpdate) -> Optional[Customer]: """Update customer information.""" db_customer = db.query(Customer).filter(Customer.id == customer_id).first() if db_customer: update_data = customer.dict(exclude_unset=True) for field, value in update_data.items(): setattr(db_customer, field, value) db.commit() db.refresh(db_customer) return db_customer def delete_customer(db: Session, customer_id: int) -> bool: """Delete a customer.""" db_customer = db.query(Customer).filter(Customer.id == customer_id).first() if db_customer: db.delete(db_customer) db.commit() return True return False def search_customers_by_name(db: Session, name: str) -> List[Customer]: """Search customers by name.""" return db.query(Customer).filter(Customer.name.contains(name)).all() def get_customers_by_location(db: Session, location: str) -> List[Customer]: """Get customers by location.""" return db.query(Customer).filter(Customer.location.contains(location)).all()