OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Database

  • Overview of the ecosystem
  • ORM frameworks
    • Java
      • Spring Boot
      • Spring Batch
      • Use Spring JDBC to connect to OceanBase Database
      • Spring Data JPA
      • Hibernate
      • MyBatis
      • jOOQ
    • Python
      • Use SQLAlchemy to connect to OceanBase Database
      • Connect to OceanBase Database by using peewee
      • Use Tortoise ORM to connect to OceanBase Database
    • Go
      • Connect to OceanBase Database by using GORM
      • beego ORM
    • Rust
      • SeaORM Connection to OceanBase Database
      • Diesel Connection to OceanBase Database
    • Ruby
      • Active Record
      • Sequel Connection to OceanBase Database
      • Connect to OceanBase Database by using Ruby on Rails
    • Node.js
      • Sequelize
      • TypeORM
      • Prisma
      • Drizzle
    • C#
      • Dapper
      • SqlSugar
      • FreeSQL
    • PHP
      • Connect to OceanBase Database by using the Yii 2.0 ORM
      • Connect to OceanBase Database by using Laravel Eloquent ORM
      • CakePHP
  • Database version management
    • Liquibase
    • Flyway
  • Data integration
    • Flink
      • Apache Flink
      • Flink DirectLoad
      • Flink Connector OceanBase
    • dbt
    • SeaTunnel
    • Maxwell
    • Debezium
    • Spark Catalog
    • NiFi
    • Qlik Replicate
    • RisingWave CDC
    • Flume
    • Migrate data from SQL Server to OceanBase Database by using MySQL Workbench
  • SQL development
    • WebLogic
    • DBeaver
    • Navicat
    • DataGrip
    • TablePlus
    • DMS
  • Orchestration and scheduling
    • Airflow
    • PowerJob
    • DolphinScheduler
    • Linkis
  • Visualization tools
    • Superset
    • Excel
    • Power BI
    • Quick BI
    • Tableau
    • GuanData
    • vividime
    • DataV
    • Metabase
    • Redash
    • FineReport
  • Database management
    • NineData
    • Bytebase
    • DataHub
    • Zabbix
  • AI
    • OpenAI
    • Qwen
    • LangChain
    • LlamaIndex
    • Dify
    • n8n
    • Trae
    • SpringAI
    • Cline
    • Cursor
    • Continue
    • MCP Toolbox
    • CamelAI
    • Firecrawl
    • Hugging Face
    • Ollama
    • Google Gemini
    • Cloudflare Workers AI
    • DB GPT
    • Jina AI
    • Augment Code
    • Claude Code
    • Kiro
    • GPT4All
  • Application
    • Ghost
    • Jira
    • Seata
    • SAP Crystal Reports
  • Middleware
    • Apache Pulsar

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Database
  3. master

Integrate OceanBase MCP Server with Claude Code

Last Updated:2026-09-04 07:40:45

Prerequisites
Step 1: Get database connection details
Step 2: Configure the OceanBase MCP Server
Clone the OceanBase MCP Server repository
Install dependencies
Configure the OceanBase MCP Server
Step 3: Build a RESTful API with FastAPI

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.

Claude Code is an AI coding tool from Anthropic. It runs in the terminal as an intelligent coding assistant and helps developers turn ideas into production-quality code quickly.

This topic uses Claude Code 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.

  • 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 | sh
      
    • Windows (PowerShell):

      irm https://astral.sh/uv/install.ps1 | iex
      
    • Or install with pip on any platform:

      pip install uv
      
    • Verify the installation:

      uv --version
      
  • Claude Code is installed:

    1. Open VS Code (install it from the official site if needed).

    2. Click the Extensions icon in the sidebar.

    3. Search for Claude Code and install it.

    4. Configure Claude Code environment variables. For example, add the following to your shell config (e.g. ~/.zshrc):

      export ANTHROPIC_BASE_URL=*****
      export ANTHROPIC_API_KEY=*******
      export ANTHROPIC_MODEL=*******
      

      Then run source ~/.zshrc (or the equivalent for your shell).

    5. Test the connection.

    6. Select your Anthropic model.

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 is 2883; direct connection default is 2881. Both can be customized at deployment.

  • $database_name: The database to use.

    Notice

    The user connecting to the tenant must have CREATE, INSERT, DROP, and SELECT privileges on that database.

  • $user_name: The tenant account. ODP: username@tenant#cluster or cluster:tenant:username. Direct: username@tenant.

  • $password: The account password.

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

  1. Open the terminal in VS Code and run the claude mcp add-json command. Replace /path/to/your/oceanbase_mcp_server with the absolute path to the oceanbase_mcp_server folder, and set OB_HOST, OB_PORT, OB_USER, OB_PASSWORD, and OB_DATABASE to your database values.

    claude mcp add-json 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": "***"
      }
    }'
    
  2. Verify the connection. In the chat, ask: How many tables are in the test database? Claude Code will show the SQL it plans to run and then the query result.

    Claude Code will show the number of tables in the test database, 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.

  1. Create the table. Use the prompt: Create a customer table with primary key ID and columns name, age, telephone, and location.

  2. Insert test data. Use the prompt: Insert 10 rows of test data.

  3. Create the FastAPI project. Use the prompt: Create a FastAPI project that exposes a RESTful API for the customer table. Claude Code will generate the files. Adjust the code if anything needs to be changed.

  4. Install dependencies.

    cd customer_api
    pip install -r requirements.txt
    
  5. Start the FastAPI app.

    python3 main.py
    
  6. Query the API. From a terminal or any HTTP client:

    curl http://127.0.0.1:8000/customers
    

    The response will contain the customer records. The generated code implements full CRUD (create, read, update, delete) for the customer table.

    Example generated code:

    from sqlalchemy.orm import Session
    from . import models, schemas
    from typing import List, Optional
    
    def get_customer(db: Session, customer_id: int):
        return db.query(models.Customer).filter(models.Customer.ID == customer_id).first()
    
    def get_customers(db: Session, skip: int = 0, limit: int = 100):
        return db.query(models.Customer).offset(skip).limit(limit).all()
    
    def create_customer(db: Session, customer: schemas.CustomerCreate):
        db_customer = models.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: schemas.CustomerUpdate):
        db_customer = db.query(models.Customer).filter(models.Customer.ID == customer_id).first()
        if db_customer:
            update_data = customer.dict(exclude_unset=True)
            for key, value in update_data.items():
                setattr(db_customer, key, value)
            db.commit()
            db.refresh(db_customer)
        return db_customer
    
    def delete_customer(db: Session, customer_id: int):
        db_customer = db.query(models.Customer).filter(models.Customer.ID == customer_id).first()
        if db_customer:
            db.delete(db_customer)
            db.commit()
            return True
        return False
    
    def search_customers(db: Session, name: Optional[str] = None, location: Optional[str] = None):
        query = db.query(models.Customer)
        if name:
            query = query.filter(models.Customer.name.contains(name))
        if location:
            query = query.filter(models.Customer.location.contains(location))
        return query.all()
    

Previous topic

Augment Code
Last

Next topic

Kiro
Next
on this page
Prerequisites
Step 1: Get database connection details
Step 2: Configure the OceanBase MCP Server
Clone the OceanBase MCP Server repository
Install dependencies
Configure the OceanBase MCP Server
Step 3: Build a RESTful API with FastAPI