A lightweight MCP (Model Context Protocol) ODBC server built with FastAPI, pyodbc, and SQLAlchemy. This server is compatible with Virtuoso DBMS and DBMS backends supported by SQLAlchemy.
- Get Schemas: Fetch and list all schema names from the connected database.
- Get Tables: Retrieve table information for specific schemas or all schemas.
- Describe Table: Generate a detailed description of table structures, including:
- Column names and data types
- Nullable attributes
- Primary and foreign keys
- Search Tables: Filter and retrieve tables based on name substrings.
- Execute Stored Procedures: In the case of Virtuoso, execute stored procedures and retrieve results.
- Execute Queries:
- JSONL result format: Optimized for structured responses.
- Markdown table format: Ideal for reporting and visualization.
-
Install uv:
pip install uv
Or use Homebrew:
brew install uv
-
ODBC DSN Setup: Configure your ODBC Data Source Name (
~/.odbc.ini) for the target database. Example for Virtuoso DBMS:[VOS] Description = OpenLink Virtuoso Driver = /path/to/virtodbcu_r.so Database = Demo Address = localhost:1111 WideAsUTF16 = Yes -
SQLAlchemy URL Binding: Use the format:
virtuoso+pyodbc://user:password@VOS
Clone this repository:
git clone https://github.com/OpenLinkSoftware/mcp-server-odbc.gitFor Claude Desktop users:
Add the following to claude_desktop_config.json:
{
"mcpServers": {
"my_database": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-server-odbc", "run", "mcp-server-odbc"],
"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:
npm install -g @modelcontextprotocol/inspector
-
Start the inspector:
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-server-odbc run mcp-server-odbc
Access the provided URL to troubleshoot server interactions.