Sandbox
@raeudigerRaeffi/turbular

MCP server for database schema and query access

Turbular sits between an agent and a database so the agent can ask for schema details and execute SQL through one API. It supports several database types, normalizes schemas for LLM use, and can transform normalized queries back to the source layout.

99 starsβ€’13 forksβ€’Pythonβ€’Updated 1y ago
Who it's for

Builders who want their agents to connect to PostgreSQL, MySQL, SQLite, BigQuery, Oracle, SQL Server, or Redshift.

What it delivers

You can let an agent inspect a database and run queries without wiring each database type by hand.

What it does

Multi-database API

Provides one interface for PostgreSQL, MySQL, SQLite, BigQuery, Oracle, MS SQL, and Redshift.

Schema normalization

Returns schemas in an LLM-friendly form and can map normalized queries back to the original schema.

Query execution

Accepts SQL, optimizes it, and returns results with options like `max_rows` and `autocommit`.

Database file uploads

Includes endpoints for uploading BigQuery service account keys and SQLite database files.

Docker setup

Includes Docker and Docker Compose files for local development and production.

How to get it

  1. 1Clone the repository
    git clone https://github.com/raeudigerRaeffi/turbular.git
    cd turbular
  2. 2Start the development environment
    docker-compose -f docker-compose.dev.yml up --build
  3. 3Test the connection
    ./scripts/test_connection.py
  4. 4Install dependencies
    pip install -r requirements.txt
  5. 5Run the server
    uvicorn app.main:app --reload
  6. 6Create a development environment
    docker-compose -f docker-compose.dev.yml up --build

README

Turbular

FastAPI Python License

Turbular is an open-source Model Context Protocol (MCP) server that enables seamless database connectivity for Language Models (LLMs). It provides a unified API interface to interact with various database types, making it perfect for AI applications that need to work with multiple data sources.

✨ Features

  • πŸ”Œ Multi-Database Support: Connect to various database types through a single API
  • πŸ”„ Schema Normalization: Automatically normalize database schemas to correct naming conventions for LLM compatibility
  • πŸ”’ Secure Connections: Support for SSL and various authentication methods
  • πŸš€ High Performance: Optimizes your LLM generated queries
  • πŸ“ Query Transformation: Let LLM generate queries against normalized layouts and transform them into their unnormalized form
  • 🐳 Docker Support: Easy deployment with Docker and Docker Compose
  • πŸ”§ Easy to Extend: Adding new database providers can be easily done by extending the BaseDBConnector interface

πŸ—„οΈ Supported Databases

Database TypeStatusIcon
PostgreSQLβœ…
MySQLβœ…
SQLiteβœ…
BigQueryβœ…
Oracleβœ…
MS SQLβœ…
Redshiftβœ…

πŸš€ Quick Start

Using Docker (Recommended)

  1. Clone the repository:

    git clone https://github.com/raeudigerRaeffi/turbular.git
    cd turbular
    
  2. Start the development environment:

    docker-compose -f docker-compose.dev.yml up --build
    
  3. Test the connection:

    ./scripts/test_connection.py
    

Manual Installation

  1. Install Python 3.11 or higher

  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the server:

    uvicorn app.main:app --reload
    

πŸ”Œ API Reference

Database Operations

Get Database Schema

POST /get_schema

Retrieve the schema of a connected database for your LLM agent.

Parameters:

  • db_info: Database connection arguments
  • return_normalize_schema (optional): Return schema in LLM-friendly format

Execute Query

POST /execute_query

Optimizes query and then execute SQL queries on the connected database.

Parameters:

  • db_info: Database connection arguments
  • query: SQL query string
  • normalized_query: Boolean indicating if query is normalized
  • max_rows: Maximum number of rows to return
  • autocommit: Boolean for autocommit mode

File Management

Upload BigQuery Key

POST /upload-bigquery-key

Upload a BigQuery service account key file.

Parameters:

  • project_id: BigQuery project ID
  • key_file: JSON key file

Upload SQLite Database

POST /upload-sqlite-file

Upload a SQLite database file.

Parameters:

  • database_name: Name to identify the database
  • db_file: SQLite database file (.db or .sqlite)

Utility Endpoints

Health Check

GET /health

Verify if the API is running.

List Supported Databases

GET /supported-databases

Get a list of all supported database types.

πŸ”§ Development Setup

  1. Fork and clone the repository

  2. Create a development environment:

    docker-compose -f docker-compose.dev.yml up --build
    
  3. The development server includes:

    • FastAPI server with hot reload
    • PostgreSQL test database
    • Pre-configured test data
  4. Access the API documentation:

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Check out our contribution guidelines
  2. Look for open issues
  3. Submit pull requests with improvements
  4. Help with documentation
  5. Share your feedback

Development Guidelines

  • Follow PEP 8 style guide
  • Write tests for new features
  • Update documentation as needed
  • Use meaningful commit messages

Roadmap

  1. Add more testing, formatting and commit hooks
  2. Add SSH support for database connection
  3. Add APIs as datasources using steampipe
  4. Enable local schema saving for databases to which the server has already connected
  5. Add more datasources (snowflake, mongodb, excel, etc.)
  6. Add authentication protection to routes

πŸ§ͺ Testing

Run the test suite:

pytest

For development tests with the included PostgreSQL:

./scripts/test_connection.py

πŸ“š Documentation

πŸ“ Connection Examples

PostgreSQL

connection_info = {
    "database_type": "PostgreSQL",
    "username": "user",
    "password": "password",
    "host": "localhost",
    "port": 5432,
    "database_name": "mydb",
    "ssl": False
}

BigQuery

connection_info = {
    "database_type": "BigQuery",
    "path_cred": "/path/to/credentials.json",
    "project_id": "my-project",
    "dataset_id": "my_dataset"
}

SQLite

connection_info = {
    "type": "SQLite",
    "database_name": "my_database"
}

πŸ™ Acknowledgments

πŸ“ž Support


Made with ❀️ by the Turbular Team

Files in the repo

Repository payloadβ€’15 top-level entries
  • .github
  • .idea
  • app
  • docs
  • scripts
  • tests
  • .gitignore
  • CONTRIBUTING.md
  • docker-compose.dev.yml
  • docker-compose.prod.yml
  • Dockerfile
  • LICENSE
  • README.md
  • requirements.dev.txt
  • requirements.txt

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph β€” average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code β€” use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300Β΅s in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up β€” it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k