The Model Context Protocol (MCP) was introduced and open-sourced by Anthropic in November 2024. It lets large language models interact with external tools and data sources. With MCP, you don’t have to copy model output and run it manually—the model can instruct tools to perform actions directly.
The OceanBase MCP Server uses MCP to give LLMs access to OceanBase Database so they can run SQL. With an MCP-capable client you can quickly prototype applications. The server is open source on GitHub.
Kiro is an integrated development environment (agentic IDE) from Amazon Web Services (AWS), built for AI agents. It is an AI-powered coding tool that helps developers go from concept to production.
This topic uses Kiro to show how to build a backend application quickly with the OceanBase MCP Server.
Prerequisites
You have deployed OceanBase Database and created a MySQL-compatible tenant. For details, see Create a tenant.
You have Python 3.11 or later and pip installed. If your system Python is older, use Miniconda to create a Python 3.11+ environment.
You have Git installed for your OS:
- Windows: https://git-scm.com/downloads/win
- macOS: https://git-scm.com/download/mac
- Linux: https://git-scm.com/downloads/linux
You have the Python package manager uv installed:
macOS/Linux (standalone script):
curl -LsSf https://astral.sh/uv/install.sh | shWindows (PowerShell):
irm https://astral.sh/uv/install.ps1 | iexOr install with pip on any platform:
pip install uvVerify the installation:
uv --version
Kiro: Download and install the client for your OS from the Kiro downloads page.
Step 1: Get database connection details
Obtain the database connection string from your OceanBase deployment team or administrator. For example:
obclient -h$host -P$port -u$user_name -p$password -D$database_name
Parameters:
$host: The IP for connecting to OceanBase. Use an ODP address when connecting via OceanBase Database Proxy (ODP), or an OBServer IP for direct connection.$port: The connection port. ODP default is2883; direct connection default is2881. Both can be customized at deployment.$database_name: The database to use.Notice
The user connecting to the tenant must have
CREATE,INSERT,DROP, andSELECTprivileges on that database. For more on privileges, see Privilege types in MySQL-compatible mode.$user_name: The tenant account. ODP:username@tenant#clusterorcluster:tenant:username. Direct:username@tenant.$password: The account password.
For more on connection strings, see Connect to an OceanBase tenant by using OBClient.
Step 2: Configure the OceanBase MCP Server
Clone the OceanBase MCP Server repository
Download the source:
git clone https://github.com/oceanbase/awesome-oceanbase-mcp.git
Change into the project directory:
cd awesome-oceanbase-mcp
Install dependencies
From the oceanbase_mcp_server directory, create a virtual environment and install dependencies:
uv venv
source .venv/bin/activate
uv pip install .
Configure the OceanBase MCP Server in Kiro
Open the chat with Command + L (macOS) or the equivalent shortcut on your OS. Click the gear icon and select Kiro Settings.

Click Open User MCP Config (JSON) or Open Workspace MCP Config (JSON) and enter the MCP configuration.


Paste the configuration below and confirm. Replace
/path/to/your/oceanbase_mcp_serverwith the absolute path to theoceanbase_mcp_serverfolder, and setOB_HOST,OB_PORT,OB_USER,OB_PASSWORD, andOB_DATABASEto your database values.{ "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 connection. In the chat, ask: How many tables are in the test database? Kiro will show the SQL it plans to run and the query result.
Kiro will show the number of tables in the
testdatabase, confirming that the connection to OceanBase is working.
Step 3: Build a RESTful API with FastAPI
FastAPI is a Python web framework well-suited for building RESTful APIs.
Create the table. Use the prompt: Create a customer table with primary key ID and columns name, age, telephone, and location.
Insert test data. Use the prompt: Insert 10 rows of test data.
Create the FastAPI project. Use the prompt: Create a FastAPI project that exposes a RESTful API for the customer table. Kiro will generate the files. Click Accept all first; you can refine the code afterward if needed. Generated output may vary from run to run.
Create a virtual environment and install dependencies. In the project directory:
pip install -r requirements.txtStart the FastAPI app.
python3 main.pyQuery the API. From a terminal or any HTTP client:
curl http://127.0.0.1:8000/customersThe response will contain the customer records. The generated code implements full CRUD (create, read, update, delete) for the
customertable.Example generated code:
from database import db from models import CustomerCreate, CustomerUpdate from typing import List, Optional class CustomerCRUD: @staticmethod def get_all_customers() -> List[dict]: query = "SELECT * FROM customer ORDER BY id" return db.execute_query(query) @staticmethod def get_customer_by_id(customer_id: int) -> Optional[dict]: query = "SELECT * FROM customer WHERE id = %s" result = db.execute_query(query, (customer_id,)) return result[0] if result else None @staticmethod def create_customer(customer: CustomerCreate) -> dict: query = """ INSERT INTO customer (name, age, telephone, location) VALUES (%s, %s, %s, %s) """ customer_id = db.execute_insert( query, (customer.name, customer.age, customer.telephone, customer.location) ) return CustomerCRUD.get_customer_by_id(customer_id) @staticmethod def update_customer(customer_id: int, customer: CustomerUpdate) -> Optional[dict]: update_fields = [] params = [] if customer.name is not None: update_fields.append("name = %s") params.append(customer.name) if customer.age is not None: update_fields.append("age = %s") params.append(customer.age) if customer.telephone is not None: update_fields.append("telephone = %s") params.append(customer.telephone) if customer.location is not None: update_fields.append("location = %s") params.append(customer.location) if not update_fields: return CustomerCRUD.get_customer_by_id(customer_id) query = f"UPDATE customer SET {', '.join(update_fields)} WHERE id = %s" params.append(customer_id) db.execute_query(query, tuple(params)) return CustomerCRUD.get_customer_by_id(customer_id) @staticmethod def delete_customer(customer_id: int) -> bool: query = "DELETE FROM customer WHERE id = %s" db.execute_query(query, (customer_id,)) return True customer_crud = CustomerCRUD()