How to Access Live DB2 Data in Visual Studio Code via Cline

Jerod Johnson
Jerod Johnson
Senior Technology Evangelist
Run the CData MCP Server for DB2 on Windows Subsytem for Linux (WSL) and connect to live DB2 data from the Cline extension in Visual Studio Code.

Cline is an autonomous coding agent right in your IDE, capable of creating/editing files, running commands, using the browser, and more with your permission every step of the way. When paired with the CData MCP Server for DB2, you get live access to CRM data within your IDE, enabling you to build, test, and validate data-driven features using real-time schema and records without ever leaving your development environment.

This article outlines how to run the CData MCP Server for DB2 on WSL (Windows Subsystem for Linux) and connect to it from the Cline extension in Visual Studio Code on Windows.

Background

CData MCP Servers are typically designed for clients like Claude Desktop. However, when attempting to use the server via the Cline extension in Windows VS Code, the following error occurred:

MCP error -32000: Connection closed

This issue is suspected to be caused by I/O handling problems in the stdio transport implementation on the Windows version of the Cline extension.

Prerequisites

  • Visual Studio Code installed on Windows
  • Cline extension installed and configured in VS Code
  • Windows Subsystem for Linux (WSL) installed with a working Linux distribution (e.g., Ubuntu)
  • Java 21+ JRE installed in WSL
  • CData MCP Server for DB2 installed on Windows

Step 1: Authenticate with DB2 (on Windows)

Before running the MCP Server in WSL, you must complete authentication flow in a Windows environment. This ensures all necessary credentials are generated and stored properly. Find and run the "CData MCP Server for DB2" or execute the MCP Server JAR file to open the configuration wizard.

java -jar "C:\Program Files\CData\CData MCP Server for DB2 2024\lib\cdata.mcp.db2.jar"

Connecting to DB2

Set the following properties to connect to DB2:

  • Server: Set this to the name of the server running DB2.
  • Port: Set this to the port the DB2 server is listening on.
  • Database: Set this to the name of the DB2 database.
  • User: Set this to the username of a user allowed to access the database.
  • Password: Set this to the password of a user allowed to access the database.

You will also need to install the corresponding DB2 driver:

  • Windows: Install the IBM Data Server Provider for .NET.

    On Windows, installing the IBM Data Server Provider is sufficient, as the installation registers it in the machine.config.

  • Java: Install the IBM Data Server Driver for JDBC.

    In the Java version, place the IBM Data Server Driver JAR in the www\WEB-INF\lib\ folder for this application.

Configuring the CData MCP Server

Name your MCP Server (e.g. cdatadb2), enter the required connection properties, and click "Connect."

Upon successful connection, the following directory and files will be created:

C:\Users\<username>\AppData\Roaming\CData\db2 Provider\
 |-- cdatadb2.mcp
 |-- (other supporting config files)

Step 2: Copy the MCP Server Configuration into WSL

Next, copy the entire configuration folder from Windows into your WSL environment.

mkdir -p ~/.config/CData/
cp -r /mnt/c/Users/<username>/AppData/Roaming/CData/"db2 Provider" ~/.config/CData/

Ensure the destination path matches exactly: ~/.config/CData/db2 Provider/.

Step 3: Install the MCP Server on WSL

Install Java and place the MCP Server JAR in the desired location within WSL:

sudo apt update
sudo apt install openjdk-21-jre-headless
sudo mkdir -p /opt/cdata/mcp_db2/lib
sudo cp /mnt/c/Program\ Files/CData/CData\ MCP\ Server\ for\ DB2\ 2024/lib/cdata.mcp.db2.jar /opt/cdata/mcp_db2/lib/

Step 4: Configure Cline

Now, configure the Cline extension to launch the MCP Server inside WSL using the wsl command.

Create or update cline_mcp_settings.json with the following content:

{
  "mcpServers": {
    "cdatadb2": {
      "autoApprove": ["*"],
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "wsl",
      "args": [
        "-d",
        "Ubuntu", // Replace with your installed WSL distro name
        "--",
        "/usr/bin/java",
        "-jar",
        "/opt/cdata/mcp_db2/lib/cdata.mcp.db2.jar",
        "cdatadb2"
      ],
      "env": {
        "JAVA_TOOL_OPTIONS": "-Xmx2g"
      }
    }
  }
}

Note: Replace Ubuntu with your actual WSL distribution name (e.g., Ubuntu-22.04). Run wsl -l in PowerShell or CMD to confirm.

Step 5: Interact with Live Data in Cline

From within Visual Studio Code, you can now run MCP commands through the Cline extension.

cdatadb2_get_tables
cdatadb2_get_columns Orders

If configured correctly, these commands will return a list of available DB2 objects and metadata, allowing you to interact with your CRM schema in real time.

Try natural language prompts like:

  • "Generate a React form to create a new DB2 Lead."
  • "Write a Python function to pull Opportunities closed this quarter."

Connect your AI to your data today!

CData MCP Servers make it easier than ever for LLMs to work with live enterprise data. To explore the technology hands-on, download a free, 30-day trial or visit the CData Community to share insights, ask questions, and help shape the future of enterprise-ready AI.

Ready to get started?

Download a free IBM DB2 MCP Server to get started:

 Download Now

Learn more:

IBM DB2 Icon IBM DB2 MCP Server

The CData MCP Server for IBM DB2 allows you to connect with live IBM DB2 data, directly from LLMs that support MCP.