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.
Project description
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.
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
Tools
- [✔️] Execute SQL queries
- [✔️] Get current tenant
- [✔️] Get all server nodes (sys tenant only)
- [✔️] Get resource capacity (sys tenant only)
- [✔️] Get ASH report
- [✔️] Search OceanBase document from official website. This tool is experimental because the API on the official website may change.
Install from PyPI Repository
Install the Python package manager uv and create virtual environment
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
If the dependency packages cannot be downloaded via uv due to network issues, you can change the mirror source to the Alibaba Cloud mirror source.
export UV_DEFAULT_INDEX="https://mirrors.aliyun.com/pypi/simple/"
Install OceanBase MCP Server
uv pip install oceanbase-mcp
Configuration
There are two ways to configure the connection information of OceanBase
- Set the following environment variables:
export OB_HOST=localhost # Database host
export OB_PORT=2881 # Optional: Database port (defaults to 2881 if not specified)
export OB_USER=your_username
export OB_PASSWORD=your_password
export OB_DATABASE=your_database
- Configure in the .env file Create an .env file in the directory where the OceanBase MCP Server command is executed, and fill in the following information OB_HOST=localhost # Database host OB_PORT=2881 # Optional: Database port (defaults to 2881 if not specified) OB_USER=your_username OB_PASSWORD=your_password OB_DATABASE=your_database
Usage
stdio Mode
Add the following content to the configuration file that supports the MCP server client:
{
"mcpServers": {
"oceanbase": {
"command": "uvx",
"args": [
"oceanbase-mcp"
],
"env": {
"OB_HOST": "localhost",
"OB_PORT": "2881",
"OB_USER": "your_username",
"OB_PASSWORD": "your_password",
"OB_DATABASE": "your_database"
}
}
}
}
sse Mode
Within the mcp-oceanbase directory, execute the following command, the port can be customized as desired.
'--transport': MCP server transport type as stdio or sse, default is stdio
'--host': sse Host to bind to, default is 127.0.0.1, that is to say, you can only access it on your local computer. If you want any remote client to be able to access it, you can set the host to 0.0.0.0
'--port': sse port to listen on, default is 8000
oceanbase_mcp_server --transport sse --port 8000
The URL address for the general SSE mode configuration is http://ip:port/sse
Security Considerations
- 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:
- Create a dedicated OceanBase user with minimal permissions
- Never use root credentials or administrative accounts
- Restrict database access to only necessary operations
- Enable logging for audit purposes
- 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oceanbase_mcp-0.0.1.tar.gz.
File metadata
- Download URL: oceanbase_mcp-0.0.1.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f63ee5e02a3411c95fe3ddb8b2c274071eed5e2a80b19572fc54eba35a1624d6
|
|
| MD5 |
cf1e2371b0dc41314570e4539e8e15c4
|
|
| BLAKE2b-256 |
3af46da1091e841b496c9dd312f855492b40d33c4b4bf3cb8d1d5a60807d9f21
|
Provenance
The following attestation bundles were made for oceanbase_mcp-0.0.1.tar.gz:
Publisher:
publish_oceanbase_mcp.yaml on oceanbase/mcp-oceanbase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oceanbase_mcp-0.0.1.tar.gz -
Subject digest:
f63ee5e02a3411c95fe3ddb8b2c274071eed5e2a80b19572fc54eba35a1624d6 - Sigstore transparency entry: 409473760
- Sigstore integration time:
-
Permalink:
oceanbase/mcp-oceanbase@ac2f6af132200ce1a1426db7ed1f244988a0b980 -
Branch / Tag:
refs/tags/oceanbase-mcp-server-v0.0.1 - Owner: https://github.com/oceanbase
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_oceanbase_mcp.yaml@ac2f6af132200ce1a1426db7ed1f244988a0b980 -
Trigger Event:
release
-
Statement type:
File details
Details for the file oceanbase_mcp-0.0.1-py3-none-any.whl.
File metadata
- Download URL: oceanbase_mcp-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
497bed694ce1d2ab7a2a36d04b3f9d7768e71ca91b3524e4c8aa04dcf0c14bc4
|
|
| MD5 |
ca0716157613eb15d2085d79415d54ea
|
|
| BLAKE2b-256 |
c63e779754dd2e4bf3ca1cf9ec1e3dfd4b2f7e77c85a8711426281864cd4150a
|
Provenance
The following attestation bundles were made for oceanbase_mcp-0.0.1-py3-none-any.whl:
Publisher:
publish_oceanbase_mcp.yaml on oceanbase/mcp-oceanbase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oceanbase_mcp-0.0.1-py3-none-any.whl -
Subject digest:
497bed694ce1d2ab7a2a36d04b3f9d7768e71ca91b3524e4c8aa04dcf0c14bc4 - Sigstore transparency entry: 409473763
- Sigstore integration time:
-
Permalink:
oceanbase/mcp-oceanbase@ac2f6af132200ce1a1426db7ed1f244988a0b980 -
Branch / Tag:
refs/tags/oceanbase-mcp-server-v0.0.1 - Owner: https://github.com/oceanbase
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_oceanbase_mcp.yaml@ac2f6af132200ce1a1426db7ed1f244988a0b980 -
Trigger Event:
release
-
Statement type: