Introduction

by OpenLinkSoftware

12 380 downloads Not rated yet MIT
GitHub

About

Typescript based Model Context Procotol (MCP) Server for Open Database Connectivity (ODBC)

Details

License
MIT

Explore

- Provides generic ODBC data access for LLMs via MCP.
- Supports SQL, SPASQL, and SPARQL queries.
- Offers schema and table inspection tools.
- Includes a Virtuoso-specific AI assistant tool.
- Returns query results in JSON, JSONL, or Markdown format.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Introduction
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

1. Run

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

2. Change directory
   cd mcp-odbc-server

3. Run
   npm init -y

4. Run
   npm install @modelcontextprotocol/sdk zod tsx odbc dotenv

While the examples that follow are oriented toward the Virtuoso ODBC Connector, this guide will also work with other ODBC Connectors. We strongly encourage code contributions and submissions of usage demos related to other database management systems (DBMS) for incorporation into this project.

1. Check installation configuration (i.e., location of key INI files) by running:

   odbcinst -j

2. List available data source names (DSNs) by running:
   odbcinst -q -s

As good security practice, you should use the .env file situated in the same directory as the mcp-ser to set bindings for the ODBC Data Source Name (ODBC_DSN), the User (ODBC_USER), the Password (ODBC_PWD), the ODBC INI (ODBCINI), and, if you want to use the OpenLink AI Layer (OPAL) via ODBC, the target Large Language Model (LLM) API Key (API_KEY).

API_KEY=sk-xxx
ODBC_DSN=Local Virtuoso
ODBC_USER=dba
ODBC_PASSWORD=dba
ODBCINI=/Library/ODBC/odbc.ini 

which brew # Should point to /opt/homebrew/bin/brew

arch -arm64 brew install unixodbc


3. Rebuild the Node.js ODBC module for ARM64:

bash

export npm_config_arch=arm64

npm install odbc --build-from-source


4. Verify the module is now ARM64:

bash
file node_modules/odbc/lib/bindings/napi-v8/odbc.node

The path for this config file is: ~{username}/Library/Application Support/Claude/claude_desktop_config.json.

{
    "mcpServers": {
        "ODBC": {
            "command": "/path/to/.nvm/versions/node/v21.1.0/bin/node",
            "args": [
                "/path/to/mcp-odbc-server/node_modules/.bin/tsx",
                "/path/to/mcp-odbc-server/src/main.ts"
            ],
            "env": {
                "ODBCINI": "/Library/ODBC/odbc.ini",
                "NODE_VERSION": "v21.1.0",
                "PATH": "~/.nvm/versions/node/v21.1.0/bin:${PATH}"
            },
            "disabled": false,
            "autoApprove": []
        }
    }
}

1. Start the application.
2. Apply configuration (from above) via Settings | Developer user interface.
3. Ensure you have a working ODBC connection to a Data Source Name (DSN).
4. Present a prompt requesting query execution, e.g.,

   Execute the following query: SELECT TOP  from Demo..Customers

Claude Desktop

The path for this config file is: ~{username}/Library/Application\ Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

{
  "mcpServers": {
    "ODBC": {
      "command": "/path/to/.nvm/versions/node/v21.1.0/bin/node",
      "args": [
        "/path/to/mcp-odbc-server/node_modules/.bin/tsx",
        "/path/to/mcp-odbc-server/src/main.ts"
      ],
      "env": {
        "ODBCINI": "/Library/ODBC/odbc.ini",
        "NODE_VERSION": "v21.1.0",
        "PATH": "/path/to/.nvm/versions/node/v21.1.0/bin:${PATH}"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

1. Use Shift+Command+P to open the Command Palette.
2. Type in: Cline.
3. Select: Cline View, which opens the Cline UI in the VSCode sidebar.
4. Use the four-squares icon to access the UI for installing and configuring MCP servers.
6. Apply the Cline Config (from above).
7. Return to the extension's main UI and start a new task requesting processing of the following prompt:

   "Execute the following query: SELECT TOP 5  from Demo..Customers"

Cline Extension

Use the settings gear to open the configuration menu that includes the MCP menu item for registering and configuring mcp servers.

1. Use the Command+I or Control+I key combination to open the Chat Interface.
2. Select Agent from the drop-down at the bottom left of the UI, where the default is Ask.
3. Enter your prompt, qualifying the use of the mcp-server for odbc using the pattern: @odbc {rest-of-prompt}.
4. Click on "Accept" to execute the prompt.

Cursor Editor

After successful installation, the following tools will be available to MCP client applications.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "introduction": {
            "ODBC": {
                "command": "/Users/kidehen/.nvm/versions/node/v21.1.0/bin/node",
                "args": [
                    "/Users/kidehen/Documents/Management/Development/modelcontextprotocol/mcp-odbc-server/node_modules/.bin/tsx",
                    "/Users/kidehen/Documents/Management/Development/modelcontextprotocol/mcp-odbc-server/main.ts"
                ],
                "env": {
                    "ODBCINI": "/Library/ODBC/odbc.ini",
                    "NODE_VERSION": "v21.1.0",
                    "PATH": "/Users/kidehen/.nvm/versions/node/v21.1.0/bin:${PATH}"
                },
                "disabled": false,
                "autoApprove": []
            }
        }
    }
}

McpServers

{
    "ODBC": {
        "command": "/Users/kidehen/.nvm/versions/node/v21.1.0/bin/node",
        "args": [
            "/Users/kidehen/Documents/Management/Development/modelcontextprotocol/mcp-odbc-server/node_modules/.bin/tsx",
            "/Users/kidehen/Documents/Management/Development/modelcontextprotocol/mcp-odbc-server/main.ts"
        ],
        "env": {
            "ODBCINI": "/Library/ODBC/odbc.ini",
            "NODE_VERSION": "v21.1.0",
            "PATH": "/Users/kidehen/.nvm/versions/node/v21.1.0/bin:${PATH}"
        },
        "disabled": false,
        "autoApprove": []
    }
}

Apple Silicon (ARM64) Compatibility with MCP ODBC Server Issues

Node x86_64 vs arm64 Conflict Issue

The x86_64 rather than arm64 edition of node may be in place, but the ODBC bridge and MCP server are arm64-based components.

You can solve this problem by performing the following steps:

1. Uninstall the x86_64 edition of node by running:

    nvm uninstall 21.1.0

2. Run the following command to confirm your current shell is in arm64 mode:
   arch

- if that returns x86_64, then run the following command to change the active mode:
     arch arm64

3. Install the arm64 edition of node by running:
   nvm install 21.1.0

Node to ODBC Bridge Layer Incompatibility

When attempting to use a Model Context Protocol (MCP) ODBC Server on Apple Silicon machines, you may encounter architecture mismatch errors. These occur because the Node.js ODBC native module (odbc.node) is compiled for ARM64 architecture, but the x86_64-based edition of the unixODBC runtime is being loaded.

Typical error message:

Error: dlopen(...odbc.node, 0x0001): tried: '...odbc.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))

You solve this problem by performing the following steps:

1. Verify your Node.js is running in ARM64 mode:

   node -p "process.arch"  # Should output: arm64
   

2. Install unixODBC for ARM64:

   # Verify Homebrew is running in ARM64 mode
   which brew  # Should point to /opt/homebrew/bin/brew
   
   # Remove existing unixODBC
   brew uninstall --force unixodbc
   
   # Install ARM64 version
   arch -arm64 brew install unixodbc
   

3. Rebuild the Node.js ODBC module for ARM64:

   # Navigate to your project
   cd /path/to/mcp-odbc-server
   
   # Remove existing module
   rm -rf node_modules/odbc
   
   # Set architecture environment variable
   export npm_config_arch=arm64
   
   # Reinstall with force build
   npm install odbc --build-from-source
   

4. Verify the module is now ARM64:

   file node_modules/odbc/lib/bindings/napi-v8/odbc.node
   # Should show "arm64" instead of "x86_64"
   
Key Points

- Both unixODBC and the Node.js ODBC module must be ARM64-compatible
- Using environment variables (export npm_config_arch=arm64) is more reliable than npm config commands
- Always verify architecture with the file command or node -p "process.arch"
- When using Homebrew on Apple Silicon, commands can be prefixed with arch -arm64 to force use of ARM64 binaries

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.