A lightweight MCP (Model Context Protocol) server for ODBC built with FastAPI, pyodbc, and SQLAlchemy. This server is compatible with Virtuoso DBMS and other DBMS backends that implement a SQLAlchemy provider.
Install uv:
shell
pip install uv
Or use Homebrew:
shell
brew install uv
ODBC DSN Setup: Configure your ODBC Data Source Name (~/.odbc.ini
) for the target database. Example for Virtuoso DBMS:
ini
[VOS]
Description = OpenLink Virtuoso
Driver = /path/to/virtodbcu_r.so
Database = Demo
Address = localhost:1111
WideAsUTF16 = Yes
SQLAlchemy URL Binding: Use the format:
plaintext
virtuoso+pyodbc://user:password@VOS
Clone this repository:
git clone https://github.com/OpenLinkSoftware/mcp-sqlalchemy-server.git
For Claude Desktop users: Add the following to claude_desktop_config.json
:
{
"mcpServers": {
"my_database": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-sqlalchemy-server", "run", "mcp-sqlalchemy-server"],
"env": {
"DB_URL": "virtuoso+pyodbc://user:password@VOS"
}
}
}
}
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 |
For easier debugging:
Install the MCP Inspector:
shell
npm install -g @modelcontextprotocol/inspector
Start the inspector:
shell
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-sqlalchemy-server run mcp-sqlalchemy-server
Access the provided URL to troubleshoot server interactions.
A simple MCP ODBC server using FastAPI, ODBC and SQLAlchemy.