mcp-oceanbase

mcp-oceanbase provides Model Context Protocol (MCP) servers that enable secure interactions with the OceanBase database. This repository includes multiple MCP servers for OceanBase, OCP, OBCloud, and interactions with resources in Kubernetes. Each server comes with specific documentation tailored to different environments and needs, making it accessible for developers.

GitHub Stars

26

User Rating

Not Rated

Favorites

0

Views

25

Forks

23

Issues

1

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Python 3.6以上
pip 最新版

Installation

Installation

Prerequisites

Please specify required software and versions:
Python: 3.6 or higher
pip: Latest version

Installation Steps

1. Clone Repository

bash
git clone https://github.com/oceanbase/mcp-oceanbase.git
cd mcp-oceanbase

2. Install Dependencies

bash
pip install -r requirements.txt

3. Start Server

bash
python server.py

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Python version and reinstall dependencies. Issue: Unable to connect to the database Solution: Verify database connection settings.

Configuration

Configuration

Basic Configuration

OceanBase Connection Settings

Create or edit config.json to add connection information:
json
{
  "database": {
    "host": "localhost",
    "port": 2881,
    "user": "your-username",
    "password": "your-password"
  }
}

Environment Variables

Set the following environment variables as needed:
bash
export OCEANBASE_USER="your-username"
export OCEANBASE_PASSWORD="your-password"

Advanced Configuration

Security Settings

Manage database connection information securely
Set appropriate access permissions

Performance Tuning

Configure connection pooling
Adjust timeout values

Configuration Example

json
{
  "database": {
    "host": "localhost",
    "port": 2881,
    "user": "admin",
    "password": "securepassword"
  }
}

Examples

Examples

Basic Usage

Here are basic usage examples for the MCP server:

Connecting to OceanBase Database

python
import json
import requests

with open('config.json') as config_file:
    config = json.load(config_file)

response = requests.get(f"http://{config['database']['host']}:{config['database']['port']}/query")
print(response.json())

Executing a Tool

python

Python example

import requests response = requests.post( 'http://localhost:3000/mcp/call', json={ 'tool': 'analyze', 'parameters': {'input': 'sample data'} } ) print(response.json())

Use Cases

Executing queries on the OceanBase database and retrieving results
Managing and manipulating data via OCP
Backing up and restoring databases in the OBCloud environment
Monitoring and managing OceanBase resources in a k8s environment
Using obdiag for database diagnostics and troubleshooting

Additional Resources