Connect Lakebase to AI Assistants With the CData Python MCP Server

Jerod Johnson
Jerod Johnson
Senior Technology Evangelist
Learn how to give AI assistants like Claude direct access to live Lakebase data using the CData Python MCP Server.

The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely access data from external sources. With MCP, you can give AI assistants like Claude direct access to your data sources, allowing them to answer questions and perform actions on live data.

The CData Python MCP Server extends this capability to over 350 data sources by leveraging CData Python Connectors. This means you can connect Claude directly to your Lakebase instance and interact with your data using natural language.

In this guide, we'll set up the CData Python MCP Server for Lakebase and configure it with Claude Desktop. You'll be able to ask Claude questions like "What are my top customers?" or "Update the status of ticket #123" and get responses based on your live Lakebase data.

Let's get started!

Prerequisites

  1. CData Python Connector for Lakebase: Request and download a free Community Edition License here. If you already have a license or are using a trial, you can download or update your CData Python Connector for Lakebase here.
  2. Claude Desktop: Download from claude.ai/download
  3. Python 3.12+ installed on your machine
  4. uv package manager: Install with pip install uv
  5. An active Lakebase account with appropriate API access

How It Works

The CData Python MCP Server acts as a bridge between AI assistants and your data sources:

  1. You ask Claude a question about your Lakebase data
  2. Claude uses MCP to send the request to the CData MCP Server
  3. The server connects to Lakebase using the CData Python Connector
  4. Live data is retrieved and returned to Claude
  5. Claude presents the answer in natural language

The server provides tools for querying data, viewing metadata, executing updates, and calling stored procedures — all through simple conversation with Claude.

Step 1: Set Up the MCP Server

1.1 Clone the Repository

First, clone the CData Python MCP Server repository:

git clone https://github.com/CDataSoftware/cdata-mcp-python.git
cd cdata-mcp-python

1.2 Create Virtual Environment

Set up a Python virtual environment using uv:

uv venv
uv pip install "mcp[cli]"

Note: With uv, you don't need to manually activate the virtual environment. The uv pip and uv run commands automatically use the .venv in the current directory.

Step 2: Install the CData Connector

2.1 Install the Connector Package

Install the CData Python Connector for Lakebase that you downloaded. Make sure you're in the project directory when running this command:

For Windows:

uv pip install "\PATH\TO\cdata_lakebase_connector-##.0.####-cp312-cp312-win_amd64.whl"

For macOS/Linux:

uv pip install ~/PATH/TO/cdata_lakebase_connector-##.0.####-py3-none-any.whl

2.2 Verify Installation

Confirm the connector is installed:

uv pip list | grep cdata
# Should show: cdata-lakebase-connector

2.3 License Activation (If Needed)

Some connectors work without explicit license activation during initial testing. If you encounter license errors, activate your license:

License Activation Steps

Find the License Installer:

import os
import cdata.lakebase
path = os.path.dirname(os.path.abspath(cdata.lakebase.__file__))
print(f"License installer location: {path}/installlic_lakebase/")

Run the Installer:

Windows:
cd .venv\Lib\site-packages\cdata\installlic_lakebase
.\install-license.exe YOUR-LICENSE-KEY
macOS/Linux:
cd .venv/lib/python3.12/site-packages/cdata/installlic_lakebase
./install-license.sh YOUR-LICENSE-KEY

Note: Omitting the License Key argument activates a trial license.

Step 3: Test Your Connection

Before configuring Claude, verify your connector works correctly.

3.1 Set Environment Variables

Export your connection details:


export CONNECTOR_MOD="cdata.lakebase"
export CONNECTION_STRING="
DatabricksInstance=lakebase;
Server=127.0.0.1;
Port=5432;
Database=my_database;
InitiateOAuth=GETANDREFRESH;"

Windows users: Use set instead of export

3.2 Quick Connection Test

uv run python -c "from utils.get_connection import get_connection; print('✅ Connected!' if get_connection() else '❌ Failed')"

Step 4: Configure Claude Desktop

4.1 Edit Claude Configuration

Open the Claude Desktop configuration file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Add your MCP server configuration:


{
    "mcpServers": {
        "lakebase_server": {
            "command": "uv",
            "args": [
                "--directory",
                "/absolute/path/to/cdata-mcp-python",
                "run",
                "--active",
                "main.py"
            ],
            "env": {
                "CONNECTOR_MOD": "cdata.lakebase",
                "CONNECTION_STRING": "
DatabricksInstance=lakebase;
Server=127.0.0.1;
Port=5432;
Database=my_database;
InitiateOAuth=GETANDREFRESH;"
            }
        }
    }
}

Important: Replace /absolute/path/to/cdata-mcp-python with the actual path to your cloned repository.

4.2 Restart Claude Desktop

  1. Completely quit Claude (not just close the window)
  2. Reopen Claude Desktop
  3. Look for the MCP icon next to your server name

Step 5: Use Claude with Your Lakebase Data

Now you can interact with your Lakebase data through natural conversation!

Example Questions to Ask Claude:

  • "What tables are available in my Lakebase instance?"
  • "Show me the schema for the [primary_table] table"
  • "List the first 10 records from [primary_table]"
  • "How many [records] were created this month?"
  • "Update the status of [record] ID 123"
  • "What stored procedures are available?"

Available MCP Tools

Claude can use these tools automatically based on your questions:

Tool Purpose Example Trigger
get_tables Lists all available tables/objects "What tables are available?"
get_columns Shows fields for a specific table "What fields are in the Customer table?"
run_query Executes SELECT queries "Show me all active customers"
run_nonquery Executes INSERT/UPDATE/DELETE "Update the email for customer 123"
get_procedures Lists stored procedures "What actions can I perform?"
call_procedure Executes stored procedures "Run the RefreshCache procedure"

Advanced Configuration

Performance Optimization

For large datasets, optimize your queries:

  • Use LIMIT clauses: SELECT * FROM Customers LIMIT 100
  • Add WHERE filters: SELECT * FROM Orders WHERE OrderDate > '2024-01-01'
  • Select specific columns: SELECT Id, Name, Email FROM Contacts

Troubleshooting

Server Not Appearing in Claude

  1. Ensure Claude is completely quit (check Task Manager/Activity Monitor)
  2. Verify your config file is valid JSON: python -m json.tool claude_desktop_config.json
  3. Check the absolute path to the repository is correct
  4. Look for syntax errors (missing commas, quotes)

Connection Errors

  1. Test your connection string using the test script
  2. Verify your Lakebase credentials are correct
  3. Check network access (firewall, VPN requirements)
  4. For OAuth: Ensure callback URLs are configured

License Issues

  1. Run the license activation steps
  2. Check if your trial has expired (30 days)
  3. Ensure you're using the correct Python version (3.12+)

Security Considerations

  • Credentials: Store sensitive connection strings securely. Consider using environment variables or secure credential stores.
  • Permissions: Use Lakebase accounts with appropriate read/write permissions based on your needs.
  • Network: The MCP server runs locally on your machine and connects directly to Lakebase.

Conclusion

You've successfully connected Claude to your Lakebase data using the CData Python MCP Server! This powerful integration allows you to:

  • Query live data using natural language
  • Perform updates and modifications through conversation
  • Analyze and understand your data with AI assistance
  • Automate routine data tasks

The same setup process works for over 350 data sources supported by CData Python Connectors, from CRMs like Salesforce to databases like MongoDB to APIs like REST endpoints.

Start your free trial or get a Community License today and give your AI assistants direct access to your enterprise data.

Ready to get started?

Download a Community License of the Lakebase Connector to get started:

 Download Now

Learn more:

Lakebase Icon Lakebase Python Connector

Python Connector Libraries for Lakebase Data Connectivity. Integrate Lakebase with popular Python tools like Pandas, SQLAlchemy, Dash & petl.