MCP Now
OceanBase

OceanBase

by yuanoOo
GitHub

(by yuanoOo) A Model Context Protocol (MCP) server that enables secure interaction with OceanBase databases.

database
access
security
oceanbase
server

OceanBase MCP Server

A Model Context Protocol (MCP) server that enables secure interaction with OceanBase databases. This server allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.

OceanBase Server MCP server

Features

  • List available OceanBase tables as resources
  • Read table contents
  • Execute SQL queries with proper error handling
  • Secure database access through environment variables
  • Comprehensive logging

Installation

1pip install oceanbase-mcp-server

Configuration

Set the following environment variables:

1OB_HOST=localhost # Database host 2OB_PORT=2881 # Optional: Database port (defaults to 2881 if not specified) 3OB_USER=your_username 4OB_PASSWORD=your_password 5OB_DATABASE=your_database

Usage

With Claude Desktop

Add this to your claude_desktop_config.json:

1{ 2 "mcpServers": { 3 "oceanbase": { 4 "command": "uv", 5 "args": [ 6 "--directory", 7 "path/to/oceanbase_mcp_server", 8 "run", 9 "oceanbase_mcp_server" 10 ], 11 "env": { 12 "OB_HOST": "localhost", 13 "OB_PORT": "2881", 14 "OB_USER": "your_username", 15 "OB_PASSWORD": "your_password", 16 "OB_DATABASE": "your_database" 17 } 18 } 19 } 20}

As a standalone server

1# Install dependencies 2pip install -r requirements.txt 3 4# Run the server 5python -m oceanbase_mcp_server

Development

1# Clone the repository 2git clone https://github.com/yourusername/oceanbase_mcp_server.git 3cd oceanbase_mcp_server 4 5# Create virtual environment 6python -m venv venv 7source venv/bin/activate # or `venv\Scripts\activate` on Windows 8 9# Install development dependencies 10pip install -r requirements-dev.txt 11 12# Run tests 13pytest

Security Considerations

  • Never commit environment variables or credentials
  • Use a database user with minimal required permissions
  • Consider implementing query whitelisting for production use
  • Monitor and log all database operations

Security Best Practices

This MCP server requires database access to function. For security:

  1. Create a dedicated OceanBase user with minimal permissions
  2. Never use root credentials or administrative accounts
  3. Restrict database access to only necessary operations
  4. Enable logging for audit purposes
  5. Regular security reviews of database access

See OceanBase Security Configuration Guide for detailed instructions on:

  • Creating a restricted OceanBase user
  • Setting appropriate permissions
  • Monitoring database access
  • Security best practices

⚠️ IMPORTANT: Always follow the principle of least privilege when configuring database access.

License

Apache License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request