Configuration Paths
Cursor
- macOS/Linux:
~/.cursor/mcp.json - Windows:
%USERPROFILE%\.cursor\mcp.json - Env var syntax:
${env:VAR_NAME}
Claude Desktop
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Claude Code
- All platforms:
~/.claude.json - Project-specific:
.mcp.jsonin project root - Env var syntax:
${VAR_NAME} - CLI:
claude mcp add --scope user db2i -- npx mcp-server-db2i
Setup Options
Using Docker with env file (Recommended)
Store credentials in a separate.env file for security. For production deployments, see Docker Secrets for the most secure approach.
.env file with your credentials:
Using Docker with inline credentials
Security Warning: This stores credentials in plain text in your config file. Only use for local development or testing.
Using docker-compose
Create a.env file in the project root, then:
docker-compose.yml automatically reads from .env in the same directory.
Using npx (Recommended for Cursor)
Use environment variable expansion to keep credentials out of config files.- Set credentials in your shell profile (
~/.zshrcor~/.bashrc):
- Use
${env:VAR}syntax in your Cursor config:
Using npx with inline credentials
Security Warning: This stores credentials in plain text in your config file. Only use for local development or testing.
Local Development
For development or customization:Configuration Options
With Default Schema
Set a default schema to avoid specifying it in every query:With Custom Driver Options
DB2I_ODBC_OPTIONS applies to the default odbc image. With the jt400 image, pass JDBC properties in DB2I_JDBC_OPTIONS instead, for example naming=sql;date format=iso;errors=full. See Configuration.
With Debug Logging
Enable debug logging for troubleshooting:Example Prompts
Once connected, you can ask the AI assistant:Schema Exploration
- “List all schemas that contain ‘PROD’”
- “Show me all schemas on this system”
- “What libraries are available?”
Table Discovery
- “Show me the tables in schema MYLIB”
- “List all tables that start with ‘CUST’”
- “What tables are in the QGPL library?”
Column Information
- “Describe the columns in MYLIB/CUSTOMERS”
- “What’s the structure of the ORDERS table?”
- “Show me the data types for MYLIB.INVENTORY”
Indexes and Constraints
- “What indexes exist on the ORDERS table?”
- “Show me the primary key for CUSTOMERS”
- “List all foreign keys in the SALES schema”
SQL Queries
- “Run this query: SELECT * FROM MYLIB.CUSTOMERS WHERE STATUS = ‘A’”
- “Count the records in ORDERS where YEAR = 2024”
- “Find customers with no orders in the last year”
Troubleshooting
Connection Issues
- Check hostname resolution: Ensure the IBM i hostname is reachable
- Verify credentials: Test with a known-good username/password
- Check port: Default is 446, verify firewall allows access
- Enable debug logging: Set
LOG_LEVEL=debug
Docker Issues
- Image not found: Build the image first with
docker build -t mcp-server-db2i . - Permission denied: Ensure Docker daemon is running
- Network issues: Check Docker network settings if IBM i is not reachable
Tool Errors
- Schema not found: Verify schema name is correct (case-sensitive on IBM i)
- Table not found: Ensure table exists and user has SELECT permission
- Rate limit exceeded: Wait for the window to reset or adjust limits
Viewing Logs
For stdio transport, logs go to stderr. Docker logs can be viewed with:Multiple Connections
You can configure multiple IBM i connections:Claude Code CLI
Claude Code supports environment variable expansion using${VAR} syntax, which is the recommended secure approach.
Secure setup with environment variables
- Set credentials in your shell profile (
~/.zshrcor~/.bashrc):
- Add to
~/.claude.jsonwith variable references:
${VAR} at runtime.