openlinksoftware_mcp_server_odbc

openlinksoftware_mcp_server_odbc

by OpenLinkSoftware
A lightweight MCP server for ODBC, built with FastAPI, pyodbc, and SQLAlchemy, compatible with Virtuoso DBMS and other backends.

MCP ODBC Server with SQLAlchemy Integration

Overview

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.

Features

  • 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.

Prerequisites

  1. Install uv:
    shell pip install uv
    Or use Homebrew:
    shell brew install uv

  2. 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

  3. SQLAlchemy URL Binding: Use the format:
    plaintext virtuoso+pyodbc://user:password@VOS

Installation

Clone this repository:

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

Configuration

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"
      }
    }
  }
}

Examples of Database URL Configuration

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

Debugging

For easier debugging:

  1. Install the MCP Inspector:
    shell npm install -g @modelcontextprotocol/inspector

  2. 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.

About

A simple MCP ODBC server using FastAPI, ODBC and SQLAlchemy.

Resources

Readme

License

Apache-2.0 license

Features & Capabilities

Categories
mcp_server model_context_protocol python fastapi sqlalchemy odbc database api_integration

Implementation Details

Stats

0 Views
4 GitHub Stars

Repository Info

OpenLinkSoftware Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300