DB2 for LUW MCP Server
A Model Context Protocol (MCP) server for interacting with DB2 for LUW databases.
Features
- Establish connections to DB2 databases
- Execute SQL queries
- Call stored procedures
Setup
- Clone this repository
- Configure your database connection in the
.envfile - Install dependencies
python3 -m venv db2_x86_env
source db2_x86_env/bin/activate
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
Usage
Starting the server
source ./db2_x86_env/bin/activate && python3 server.py
./python_x86_wrapper.sh server.py # (for Apple M1/M2 chips)
MCP config for Cursor or cherry studio
Cursor
{
"mcpServers": {
"db2-mcp": {
"autoApprove": [
"connect_db"
],
"disabled": false,
"timeout": 60,
"command": "/Users/zlx/Desktop/zlx/3.Coding/AI/db2-mcp/python_x86_wrapper.sh",
"args": [
"/Users/zlx/Desktop/zlx/3.Coding/AI/db2-mcp/server.py"
],
"env": {
"DB2_DATABASE": "tpcc",
"DB2_HOSTNAME": "192.168.0.100",
"DB2_PORT": "50000",
"DB2_USERNAME": "db2user",
"DB2_PASSWORD": "db2user@2025"
},
"transportType": "stdio"
}
}
}
Cherry Studio
"ECvXtBighSOVs1JMd1GBy": {
"name": "db2-mcp",
"type": "stdio",
"description": "",
"isActive": true,
"command": "/Users/zlx/Desktop/zlx/3.Coding/AI/db2-mcp/python_x86_wrapper.sh",
"args": [
"/Users/zlx/Desktop/zlx/3.Coding/AI/db2-mcp/server.py"
],
"env": {
"DB2_DATABASE": "tpcc",
"DB2_HOSTNAME": "192.168.0.100",
"DB2_PORT": "50000",
"DB2_USERNAME": "db2user",
"DB2_PASSWORD": "db2user@2025"
},
}
MCP Tools
connect_db
Establishes a connection with the target DB2 database.
run_sql
Executes a read-only SQL query and returns the results.
call_sp
Calls a stored procedure or function with the specified parameters.
Recommend MCP Servers 💡
neondatabase-labs/mcp-server-neon
An open-source MCP server that enables natural language interaction with Neon Postgres databases via the Neon Management API.
mcp-mongo-server
A Model Context Protocol server that enables LLMs to interact with MongoDB databases, providing capabilities for inspecting collection schemas and executing MongoDB operations.
Prisma-Remote
A remote Model-Context-Protocol (MCP) server provided by Prisma, designed for AI platforms to enable AI agents to manage database workflows, including creating backups, managing connection strings, executing SQL queries, and introspecting schemas.
querypie-mcp-server
MCP server for QueryPie enabling administrators to manage data, monitor resources, and detect suspicious behavior.
logfire-mcp@latest
This MCP server enables LLMs to retrieve your application's telemetry data, analyze distributed traces, and make use of the results of arbitrary SQL queries executed using the Pydantic Logfire APIs.
@Teradata/teradata-mcp-server
The Teradata MCP server provides tools and prompts for interacting with Teradata databases, enabling AI agents and users to query, analyze, and manage data efficiently.