run-sql-connectorx

by gigamori

266 downloads
Not rated
GitHub

About

Execute SQL (PostgreSQL, MariaDB, BigQuery, MS SQL Server, RedShift, etc.) via ConnectorX and stream results to CSV/Parquet. MCP tool: run_sql.

Details

Author
gigamori
Downloads
266
Categories
Other, Database

- Efficient streaming via Arrow RecordBatch chunks
- Token-efficient file-based data exchange for MCP
- Cross-database support through ConnectorX
- Robust I/O: CSV headers, Parquet validation, error cleanup
- Output formats: CSV (UTF‑8) and Parquet (PyArrow defaults)

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name run-sql-connectorx
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install via uvx and invoke with the required --conn <connection_token> option. Optionally set --csv-token-threshold <int> to enable per‑line CSV token counting. The server returns the string "OK" on success or "Error: <message>" on failure.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "run-sql-connectorx": {
            "run-sql-connectorx": {
                "command": "uvx",
                "args": [
                    "--from",
                    "git+https://github.com/gigamori/mcp-run-sql-connectorx",
                    "run-sql-connectorx",
                    "--conn",
                    "<connection_token>",
                    "--csv-token-threshold",
                    "500000"
                ]
            }
        }
    }
}

McpServers

{
    "run-sql-connectorx": {
        "command": "uvx",
        "args": [
            "--from",
            "git+https://github.com/gigamori/mcp-run-sql-connectorx",
            "run-sql-connectorx",
            "--conn",
            "<connection_token>",
            "--csv-token-threshold",
            "500000"
        ]
    }
}

Output formats: csv or parquet
CSV: UTF-8, header row is always written
Parquet: PyArrow defaults; schema mismatch across batches raises an error
Return value: the string "OK" on success, or "Error: <message>" on failure
On failure the partially written output file is deleted
CSV token counting (optional): per-line token counting via tiktoken (o200k_base) with a warning threshold

Why this library?



- Efficient streaming: handles large results in Arrow RecordBatch chunks
- Token-efficient for MCP: exchanges data via files instead of inline payloads
- Cross-database via ConnectorX: one tool works across many backends
- Robust I/O: CSV header handling, Parquet schema validation, safe cleanup on errors

Supported data sources (ConnectorX)



ConnectorX supports many databases. Common examples include:

- PostgreSQL
- MySQL / MariaDB
- SQLite
- Microsoft SQL Server
- Amazon Redshift
- Google BigQuery

For the complete and up-to-date list of supported databases and connection-token (conn) formats, see the official docs:

- ConnectorX repository: <https://github.com/sfu-db/connector-x/>
- Database connection tokens: <https://github.com/sfu-db/connector-x/tree/main/docs/databases>

Getting Started



``bash
uvx run-sql-connectorx \
--conn "<connection_token>" \
--csv-token-threshold 500000
`

<connection_token> is the connection token (conn) used by ConnectorX—SQLite, PostgreSQL, BigQuery, and more.

CLI options



-
--conn <connection_token> (required): ConnectorX connection token (conn)
-
--csv-token-threshold <int> (default 0): when > 0, enable CSV per-line token counting using tiktoken(o200k_base)`; the value is a warning threshold

Further reading



ConnectorX repository: <https://github.com/sfu-db/connector-x/>
Connection-token formats for each database: <https://github.com/sfu-db/connector-x/tree/main/docs/databases>

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.