SQLAlchemy ODBC Bridge MCP server

Provides a bridge between databases and SQL/SPARQL queries through ODBC connections, enabling schema exploration, table management, and query execution with formatted results.
Back to servers
Provider
OpenLink Software
Release date
Mar 31, 2025
Language
Python
Stats
10 stars

The MCP Server ODBC via SQLAlchemy is a lightweight server that connects your AI models to databases through ODBC using FastAPI, pyodbc, and SQLAlchemy. It allows AI assistants to interact with databases by fetching schemas, retrieving table information, executing SQL queries, and more.

Prerequisites

Install uv

pip install uv

Or using Homebrew:

brew install uv

Check unixODBC Configuration

  1. View installation configuration:

    odbcinst -j
    
  2. List available data source names:

    odbcinst -q -s
    

ODBC DSN Setup

Configure your ODBC Data Source Name in ~/.odbc.ini. Example for Virtuoso DBMS:

[VOS]
Description = OpenLink Virtuoso
Driver = /path/to/virtodbcu_r.so
Database = Demo
Address = localhost:1111
WideAsUTF16 = Yes

SQLAlchemy URL Format

Use the following format for Virtuoso:

virtuoso+pyodbc://user:password@VOS

Installation

Clone the repository:

git clone https://github.com/OpenLinkSoftware/mcp-sqlalchemy-server.git
cd mcp-sqlalchemy-server

Environment Configuration

Update your .env file to override the defaults:

ODBC_DSN=VOS
ODBC_USER=dba
ODBC_PASSWORD=dba
API_KEY=xxx

Claude Desktop Configuration

For Claude Desktop users, add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "my_database": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp-sqlalchemy-server", "run", "mcp-sqlalchemy-server"],
      "env": {
        "ODBC_DSN": "dsn_name",
        "ODBC_USER": "username",
        "ODBC_PASSWORD": "password",
        "API_KEY": "sk-xxx"
      }
    }
  }
}

Database Connection URLs

Here are tested pyodbc URL examples for different database systems:

Database URL Format
Virtuoso DBMS virtuoso+pyodbc://user:password@ODBC_DSN
PostgreSQL postgresql://user:password@localhost/dbname
MySQL mysql+pymysql://user:password@localhost/dbname
SQLite sqlite:///path/to/database.db

Available Tools

Core Database Tools

  • podbc_get_schemas: Lists all accessible database schemas
  • podbc_get_tables: Lists tables in a selected schema
  • podbc_describe_table: Provides detailed table structure information
  • podbc_filter_table_names: Finds tables matching a substring pattern
  • podbc_query_database: Executes SQL queries with JSON results
  • podbc_execute_query: Executes SQL queries with JSONL results
  • podbc_execute_query_md: Executes SQL queries with Markdown table results

Virtuoso-Specific Tools

  • podbc_spasql_query: Executes SPASQL (SQL/SPARQL hybrid) queries
  • podbc_sparql_query: Executes SPARQL queries
  • podbc_virtuoso_support_ai: Interacts with Virtuoso's AI assistant

Tool Details

podbc_get_schemas

Retrieves all schema names from the connected database.

Parameters:

  • user (optional): Database username (default: "demo")
  • password (optional): Database password (default: "demo")
  • dsn (optional): ODBC data source name (default: "Local Virtuoso")

Returns: JSON array of schema names

podbc_get_tables

Lists table information for a specified schema.

Parameters:

  • schema (optional): Database schema (default: connection default)
  • user (optional): Database username (default: "demo")
  • password (optional): Database password (default: "demo")
  • dsn (optional): ODBC data source name (default: "Local Virtuoso")

Returns: JSON with table information (catalog, schema, name, type)

podbc_describe_table

Provides detailed information about a table's structure.

Parameters:

  • schema (required): Database schema name
  • table (required): Table name to describe
  • user (optional): Database username (default: "demo")
  • password (optional): Database password (default: "demo")
  • dsn (optional): ODBC data source name (default: "Local Virtuoso")

Returns: JSON with table column details (names, types, sizes, constraints)

podbc_filter_table_names

Searches for tables containing a specific substring.

Parameters:

  • q (required): Substring to search for in table names
  • schema (optional): Database schema to search in
  • user (optional): Database username (default: "demo")
  • password (optional): Database password (default: "demo")
  • dsn (optional): ODBC data source name (default: "Local Virtuoso")

Returns: JSON with matching table information

podbc_query_database / podbc_execute_query

Executes SQL queries and returns results in JSON format.

Parameters:

  • query (required): SQL query to execute
  • user (optional): Database username (default: "demo")
  • password (optional): Database password (default: "demo")
  • dsn (optional): ODBC data source name (default: "Local Virtuoso")

Returns: Query results as JSON

Troubleshooting

For easier debugging:

  1. Install the MCP Inspector:

    npm install -g @modelcontextprotocol/inspector
    
  2. Start the inspector:

    npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-sqlalchemy-server run mcp-sqlalchemy-server
    
  3. Access the provided URL to monitor server interactions

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later