Skip to main content

A Model Context Protocol (MCP) server that enables secure interaction with RaseSQL、PostgreSQL databases.

Project description

RaseSQL MCP Server

Python RaseSQL License FastMCP

A high-performance Model Context Protocol (MCP) server for RaseSQL databases

FeaturesInstallationQuick StartAPI ReferenceConfiguration


📖 Table of Contents

🔍 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)

pip install rasesql-mcp-server

2. Configure Database Connection

Create a dbconfig.json file with your RaseSQL database credentials:

{
    "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

{
  "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:

-- 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));

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

rasesql_mcp_server-1.0.2.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rasesql_mcp_server-1.0.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file rasesql_mcp_server-1.0.2.tar.gz.

File metadata

  • Download URL: rasesql_mcp_server-1.0.2.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for rasesql_mcp_server-1.0.2.tar.gz
Algorithm Hash digest
SHA256 069663d3d57949c80ff834749944d10ab67f6a43d354ca2b14e38d0a11adbdff
MD5 863023f7a7e0d79ae3182cdcac875e58
BLAKE2b-256 f66d5f6492d58fca1e471d5db84ffee8bba5c4fbd571d4216273ac76fa1592a1

See more details on using hashes here.

File details

Details for the file rasesql_mcp_server-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for rasesql_mcp_server-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 347037252c3fdd64aced7d7f1427fe17a0b777448e2e8368acfa458640a6e191
MD5 ee132e3ebb26e0cd2b95af6a9d978969
BLAKE2b-256 ab43024b79d16958e94378570b7bfe998bbbde30e7a6ff25a3c466050486f6d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page