# RaseSQL MCP Server
<div align="center">




**A high-performance Model Context Protocol (MCP) server for RaseSQL databases**
[Features](#-features) • [Installation](#️-installation) • [Quick Start](#-quick-start) • [API Reference](#-api-reference) • [Configuration](#️-configuration)
</div>
---
## 📖 Table of Contents
- [Overview](#-overview)
- [Features](#-features)
- [Prerequisites](#-prerequisites)
- [Installation](#️-installation)
## 🔍 Overview
RaseSQL MCP Server is a robust, production-ready Model Context Protocol server that provides secure and efficient interaction with RaseSQL databases. Built with modern Python async/await patterns and optimized for high-performance database operations.
### What is MCP?
Model Context Protocol (MCP) is an open standard that enables AI models to securely connect to external data sources and tools. This server implements MCP to provide AI models with direct, controlled access to RaseSQL databases.
## ✨ Features
### 🚀 **Core Capabilities**
- **MCP Protocol Support**: Full compliance with MCP specification using FastMCP framework
- **RaseSQL Optimized**: Native support for RaseSQL with `asyncpg` driver
- **Asynchronous Architecture**: High-performance async/await implementation
- **Connection Pooling**: Intelligent connection management with configurable pool settings
### 🔧 **Database Operations**
- **Universal SQL Execution**: Support for SELECT, INSERT, UPDATE, DELETE, DDL operations
- **Table Structure Queries**: Detailed schema information retrieval
- **Test Data Generation**: Built-in tools for generating sample data
- **Parameterized Queries**: Safe parameter binding to prevent SQL injection
### 🛡️ **Security & Safety**
- **Query Type Restrictions**: Configurable query execution controls
- **Parameter Validation**: Comprehensive input validation
- **Password Protection**: Secure credential handling
- **Connection Isolation**: Instance-based access control
### 📊 **Monitoring & Logging**
- **Structured Logging**: Detailed operation logs with configurable levels
- **Connection Pool Monitoring**: Real-time pool status tracking
- **Error Handling**: Comprehensive error reporting and recovery
## 📋 Prerequisites
- **Python**: 3.12 or higher
- **RaseSQL**: 12.0 or higher (tested with 17.6)
- **Network Access**: Connectivity to RaseSQL server
- **Memory**: Minimum 512MB RAM recommended
## 🛠️ Installation
### 1. Install from PyPI (Recommended)
```bash
pip install rasesql-mcp-server
```
### 2. Configure Database Connection
Create a `dbconfig.json` file with your RaseSQL database credentials:
```json
{
"dbPoolSize": 5,
"dbMaxOverflow": 10,
"dbPoolTimeout": 30,
"dbType-Comment": "The database currently in use,such as RASESQL、PostgreSQL DataBases",
"dbList": [
{ "dbInstanceId": "rasesql_1",
"dbHost": "localhost",
"dbPort": 5432,
"dbDatabase": "rasesql_db",
"dbUsername": "root",
"dbPassword": "123456",
"dbType": "RASESQL",
"dbVersion": "2.0",
"dbActive": false
},
{ "dbInstanceId": "postgresql_2",
"dbHost": "localhost",
"dbPort": 5432,
"dbDatabase": "pg_db",
"dbUsername": "root",
"dbPassword": "123456",
"dbType": "PostgreSQL",
"dbVersion": "17.6",
"dbActive": true
}
],
"logPath": "/path/to/logs",
"logLevel": "info"
}
# dbActive
Only database instances with dbActive set to true in the dbList configuration list are available.
# logPath
Mcp server log is stored in /path/to/logs/mcp_server.log.
# logLevel
TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL
# dbActive
Only database instances with dbActive set to true in the dbList configuration list are available.
# logPath
Mcp server log is stored in /Volumes/store/mysql_mcp_server/logs/mcp_server.log.
# logLevel
TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL
```
### 3. Configure mcp json
```bash
{
"mcpServers": {
"rasesql-mcp-client": {
"command": "rasesql-mcp-server",
"env": {
"config_file": "/path/dbconfig.json"
},
"disabled": false
}
}
}
# config_file
dbconfig.json file path in your device
```
```
## 📚 API Reference
### MCP Tools
#### `sql_exec(sql: str)`
Execute any SQL statement with automatic result formatting.
**Parameters:**
- `sql` (str): SQL statement to execute
**Returns:**
```json
{
"success": true,
"result": [...], // Query results or affected row count
"message": "SQL executed successfully"
}
```
**Examples:**
```sql
-- Query data
SELECT * FROM users WHERE age > 18 LIMIT 10;
-- Insert data
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com');
-- Update data
UPDATE users SET last_login = NOW() WHERE id = 1;
-- DDL operations
CREATE TABLE products (id SERIAL PRIMARY KEY, name VARCHAR(255));
```
Raw data
{
"_id": null,
"home_page": null,
"name": "rasesql-mcp-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Frank Jin <j00131120@163.com>",
"keywords": "mcp, rasesql, postgresql, model-context-protocol, async, connection-pool",
"author": null,
"author_email": "Frank Jin <j00131120@163.com>",
"download_url": "https://files.pythonhosted.org/packages/ba/86/7d1596abfdd785f66586d8c4f5140103906498af6958ccf43eedfe909bca/rasesql_mcp_server-1.0.0.tar.gz",
"platform": null,
"description": "# RaseSQL MCP Server\n\n<div align=\"center\">\n\n\n\n\n\n\n**A high-performance Model Context Protocol (MCP) server for RaseSQL databases**\n\n[Features](#-features) \u2022 [Installation](#\ufe0f-installation) \u2022 [Quick Start](#-quick-start) \u2022 [API Reference](#-api-reference) \u2022 [Configuration](#\ufe0f-configuration)\n\n</div>\n\n---\n\n## \ud83d\udcd6 Table of Contents\n\n- [Overview](#-overview)\n- [Features](#-features)\n- [Prerequisites](#-prerequisites)\n- [Installation](#\ufe0f-installation)\n\n\n## \ud83d\udd0d Overview\n\nRaseSQL MCP Server is a robust, production-ready Model Context Protocol server that provides secure and efficient interaction with RaseSQL databases. Built with modern Python async/await patterns and optimized for high-performance database operations.\n\n### What is MCP?\n\nModel Context Protocol (MCP) is an open standard that enables AI models to securely connect to external data sources and tools. This server implements MCP to provide AI models with direct, controlled access to RaseSQL databases.\n\n## \u2728 Features\n\n### \ud83d\ude80 **Core Capabilities**\n- **MCP Protocol Support**: Full compliance with MCP specification using FastMCP framework\n- **RaseSQL Optimized**: Native support for RaseSQL with `asyncpg` driver\n- **Asynchronous Architecture**: High-performance async/await implementation\n- **Connection Pooling**: Intelligent connection management with configurable pool settings\n\n### \ud83d\udd27 **Database Operations**\n- **Universal SQL Execution**: Support for SELECT, INSERT, UPDATE, DELETE, DDL operations\n- **Table Structure Queries**: Detailed schema information retrieval\n- **Test Data Generation**: Built-in tools for generating sample data\n- **Parameterized Queries**: Safe parameter binding to prevent SQL injection\n\n### \ud83d\udee1\ufe0f **Security & Safety**\n- **Query Type Restrictions**: Configurable query execution controls\n- **Parameter Validation**: Comprehensive input validation\n- **Password Protection**: Secure credential handling\n- **Connection Isolation**: Instance-based access control\n\n### \ud83d\udcca **Monitoring & Logging**\n- **Structured Logging**: Detailed operation logs with configurable levels\n- **Connection Pool Monitoring**: Real-time pool status tracking\n- **Error Handling**: Comprehensive error reporting and recovery\n\n## \ud83d\udccb Prerequisites\n\n- **Python**: 3.12 or higher\n- **RaseSQL**: 12.0 or higher (tested with 17.6)\n- **Network Access**: Connectivity to RaseSQL server\n- **Memory**: Minimum 512MB RAM recommended\n\n## \ud83d\udee0\ufe0f Installation\n\n### 1. Install from PyPI (Recommended)\n\n```bash\npip install rasesql-mcp-server\n```\n\n### 2. Configure Database Connection\n\nCreate a `dbconfig.json` file with your RaseSQL database credentials:\n\n```json\n{\n \"dbPoolSize\": 5,\n \"dbMaxOverflow\": 10,\n \"dbPoolTimeout\": 30,\n \"dbType-Comment\": \"The database currently in use,such as RASESQL\u3001PostgreSQL DataBases\",\n \"dbList\": [\n { \"dbInstanceId\": \"rasesql_1\",\n \"dbHost\": \"localhost\",\n \"dbPort\": 5432,\n \"dbDatabase\": \"rasesql_db\",\n \"dbUsername\": \"root\",\n \"dbPassword\": \"123456\",\n \"dbType\": \"RASESQL\",\n \"dbVersion\": \"2.0\",\n \"dbActive\": false\n },\n { \"dbInstanceId\": \"postgresql_2\",\n \"dbHost\": \"localhost\",\n \"dbPort\": 5432,\n \"dbDatabase\": \"pg_db\",\n \"dbUsername\": \"root\",\n \"dbPassword\": \"123456\",\n \"dbType\": \"PostgreSQL\",\n \"dbVersion\": \"17.6\",\n \"dbActive\": true\n }\n ],\n \"logPath\": \"/path/to/logs\",\n \"logLevel\": \"info\"\n}\n# dbActive\nOnly database instances with dbActive set to true in the dbList configuration list are available. \n# logPath\nMcp server log is stored in /path/to/logs/mcp_server.log.\n# logLevel\nTRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL\n# dbActive\nOnly database instances with dbActive set to true in the dbList configuration list are available. \n# logPath\nMcp server log is stored in /Volumes/store/mysql_mcp_server/logs/mcp_server.log.\n# logLevel\nTRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL\n```\n\n### 3. Configure mcp json\n\n```bash\n{\n \"mcpServers\": {\n \"rasesql-mcp-client\": {\n \"command\": \"rasesql-mcp-server\",\n \"env\": {\n \"config_file\": \"/path/dbconfig.json\"\n },\n \"disabled\": false\n }\n }\n}\n\n# config_file\ndbconfig.json file path in your device\n```\n\n```\n\n## \ud83d\udcda API Reference\n\n### MCP Tools\n\n#### `sql_exec(sql: str)`\n\nExecute any SQL statement with automatic result formatting.\n\n**Parameters:**\n- `sql` (str): SQL statement to execute\n\n**Returns:**\n```json\n{\n \"success\": true,\n \"result\": [...], // Query results or affected row count\n \"message\": \"SQL executed successfully\"\n}\n```\n\n**Examples:**\n```sql\n-- Query data\nSELECT * FROM users WHERE age > 18 LIMIT 10;\n\n-- Insert data\nINSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com');\n\n-- Update data\nUPDATE users SET last_login = NOW() WHERE id = 1;\n\n-- DDL operations\nCREATE TABLE products (id SERIAL PRIMARY KEY, name VARCHAR(255));\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A Model Context Protocol (MCP) server that enables secure interaction with RaseSQL\u3001PostgreSQL databases.",
"version": "1.0.0",
"project_urls": {
"Bug Tracker": "https://gitee.com/frankjin/mcp-server/issues",
"Changelog": "https://gitee.com/frankjin/mcp-server/tree/master/rasesql_mcp_server/CHANGELOG.md",
"Documentation": "https://gitee.com/frankjin/mcp-server/tree/master/rasesql_mcp_server/README.md",
"Download": "https://gitee.com/frankjin/mcp-server/tree/master/rasesql_mcp_server",
"Homepage": "https://gitee.com/frankjin/mcp-server",
"Repository": "https://gitee.com/frankjin/mcp-server.git",
"Source Code": "https://gitee.com/frankjin/mcp-server/tree/master/rasesql_mcp_server"
},
"split_keywords": [
"mcp",
" rasesql",
" postgresql",
" model-context-protocol",
" async",
" connection-pool"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "921cf09f1a689a619d0c6b246d516906805812ce9a54734cd3bfcdf5d3cf87c4",
"md5": "52aea81c5693cbaf714f477d45812209",
"sha256": "9ee50d29f5b0bcb8e1a6c6eca84d7d8c036853fc2065ceef446f4d9af71fd1c4"
},
"downloads": -1,
"filename": "rasesql_mcp_server-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "52aea81c5693cbaf714f477d45812209",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 18023,
"upload_time": "2025-08-19T07:14:00",
"upload_time_iso_8601": "2025-08-19T07:14:00.279171Z",
"url": "https://files.pythonhosted.org/packages/92/1c/f09f1a689a619d0c6b246d516906805812ce9a54734cd3bfcdf5d3cf87c4/rasesql_mcp_server-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ba867d1596abfdd785f66586d8c4f5140103906498af6958ccf43eedfe909bca",
"md5": "500483d2dc090aaf2302ea3cf70a595b",
"sha256": "711315f023f448d1013ca8f544ac4e6a128bce9fa916281e02bb43e8a32d2dda"
},
"downloads": -1,
"filename": "rasesql_mcp_server-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "500483d2dc090aaf2302ea3cf70a595b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 15178,
"upload_time": "2025-08-19T07:14:02",
"upload_time_iso_8601": "2025-08-19T07:14:02.241101Z",
"url": "https://files.pythonhosted.org/packages/ba/86/7d1596abfdd785f66586d8c4f5140103906498af6958ccf43eedfe909bca/rasesql_mcp_server-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-19 07:14:02",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "rasesql-mcp-server"
}