OneSQL MCP Server
by yicui2004
README.md
# OneSQL MCP Server
Model Context Protocol (MCP) server for OneSQL - AI-powered SQL query generation and table extraction.
## Features
- **SQL Generation** (Paid): Convert natural language to SQL queries using Qwen2.5-Coder-7B + OneSQL PEFT
- **Schema Management** (Paid): Upload, list, and delete database schemas
- **Table Extraction** (FREE): Extract tables from text documents - no API key required!
## Installation
### Quick Install
```bash
pip install onesql-mcp-server
```
### Manual Install
```bash
# Download the script
curl -O https://us-central1-onekq-public.cloudfunctions.net/onesql-main/mcp-server.py
# Make it executable
chmod +x onesql_mcp_server.py
```
## Setup
### 1. Get API Key
For paid SQL features, get your API key from:
- AWS: https://aws.marketplace.amazon.com/pp/prodview-onesql
- GCP: Contact support@onekq.ai
### 2. Configure Claude Desktop
Add to your `claude_desktop_config.json`:
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"onesql": {
"command": "python",
"args": ["/path/to/onesql_mcp_server.py"],
"env": {
"ONESQL_API_KEY": "your-api-key-here"
}
}
}
}
```
### 3. Restart Claude Desktop
The OneSQL tools will appear in Claude Desktop's tool list.
## Usage
### Free Table Extraction (No API Key Required!)
```
Extract tables from this text:
| Name | Age | City |
|------|-----|------|
| John | 25 | NYC |
| Jane | 30 | LA |
```
### SQL Generation (Requires API Key)
```
Generate SQL to find all users who signed up in the last 30 days
```
First, upload your schema:
```
Upload my database schema:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255),
created_at TIMESTAMP
);
```
## Available Tools
| Tool | Cost | Description |
|------|------|-------------|
| `sql_generate_query` | š° Paid | Generate SQL from natural language |
| `sql_upload_schema` | š° Paid | Upload database schema for better accuracy |
| `sql_list_schemas` | š° Paid | List your saved schemas |
| `sql_delete_schema` | š° Paid | Delete a schema |
| `extract_tables` | š **FREE** | Extract tables from text (no API key!) |
## Architecture
```
Claude Desktop
ā
OneSQL MCP Server (local bridge)
ā
OneSQL GCP API
ā
āā Schema Service (Firestore)
āā SQL Generation (GPU - Qwen2.5-Coder-7B)
```
## Pricing
- **Table Extraction**: FREE - unlimited usage, no API key required
- **SQL Generation**: Pay-per-query via AWS/GCP Marketplace
- **Schema Management**: Included with SQL subscription
## API Endpoint
The MCP server connects to:
```
https://us-central1-onekq-public.cloudfunctions.net/onesql-main/mcp
```
## Development
### Run Locally
```bash
export ONESQL_API_KEY="your-key"
python onesql_mcp_server.py
```
The server reads JSON-RPC requests from stdin and writes responses to stdout.
### Test with MCP Inspector
```bash
npx @modelcontextprotocol/inspector python onesql_mcp_server.py
```
## Troubleshooting
### "ONESQL_API_KEY environment variable is required"
- Set the environment variable in Claude Desktop config (see Setup above)
- For free table extraction, you can use a dummy key or leave it blank
### "Network error" / "Timeout"
- Check your internet connection
- Verify the API endpoint is accessible: `curl https://us-central1-onekq-public.cloudfunctions.net/onesql-main/mcp`
### Tools not appearing in Claude Desktop
- Restart Claude Desktop after config changes
- Check Claude Desktop logs for errors
## Support
- Issues: https://github.com/onekq/onesql-mcp-server/issues
- Email: support@onekq.ai
- Docs: https://docs.onekq.ai
## License
MIT License - see LICENSE file for details
## Links
- MCP Protocol: https://modelcontextprotocol.io
- OneSQL: https://onekq.ai
- AWS Marketplace: https://aws.marketplace.amazon.com/pp/prodview-onesql
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues