IBM Db2 for i — Claude Code MCP server: query IBM i data
Gives an assistant read-only access to Db2 for i: SELECT queries plus schema, table and index metadata. Useful when you need to make sense of AS/400 data without writing SQL by hand.
claude mcp add --env DB2I_HOSTNAME=<DB2I_HOSTNAME> --env DB2I_USERNAME=<DB2I_USERNAME> --env DB2I_PASSWORD=<DB2I_PASSWORD> --env DB2I_SCHEMA=<DB2I_SCHEMA> --env DB2I_PROFILES=<DB2I_PROFILES> --transport stdio ibm-db2-for-i -- npx -y mcp-server-db2iWhat IBM Db2 for i does
The server takes SQL from the model and runs it on IBM i through the IBM i Access ODBC driver. No Java involved. If a box only exposes SSH, switch to the Mapepire driver; JT400 JDBC is the third option. Only SELECT statements pass, results get capped automatically, and a timeout cancels queries that run too long.
Metadata is the other half: libraries, column descriptions, indexes, constraints and views. A single process can hold several connection profiles in DB2I_PROFILES, each with its own driver and allowed-library list. Individual tools can be switched off — a metadata-only setup without execute_query, for instance.
You need network access to the IBM i host and an account allowed to read the libraries in question. Sensitive columns can be masked in results. The install runs npx -y mcp-server-db2i and takes connection details from environment variables, which means the password sits in the client config in plain text — keep that file locked down.
What it helps with
- browse libraries and tables on an IBM i system
- pull a sample of Db2 for i rows without long locks
- read column and index definitions before a code change
- reach an IBM i host where only SSH is open
- hide sensitive columns in query output
Example prompts for the agent
- List the libraries on our IBM i system and find tables holding orders
- Describe the columns of table
ORDERSin libraryPRODLIB - Run a SELECT for the last 50 rows of
PRODLIB.ORDERSand show them as a table
How to install IBM Db2 for i
Platform CLI
claude mcp add --env DB2I_HOSTNAME=<DB2I_HOSTNAME> --env DB2I_USERNAME=<DB2I_USERNAME> --env DB2I_PASSWORD=<DB2I_PASSWORD> --env DB2I_SCHEMA=<DB2I_SCHEMA> --env DB2I_PROFILES=<DB2I_PROFILES> --transport stdio ibm-db2-for-i -- npx -y mcp-server-db2iReplace <…> with your own values. 5 more environment variables are in the server README
Platform CLI
codex mcp add ibm-db2-for-i --env DB2I_HOSTNAME=<DB2I_HOSTNAME> --env DB2I_USERNAME=<DB2I_USERNAME> --env DB2I_PASSWORD=<DB2I_PASSWORD> --env DB2I_SCHEMA=<DB2I_SCHEMA> --env DB2I_PROFILES=<DB2I_PROFILES> -- npx -y mcp-server-db2iReplace <…> with your own values. 5 more environment variables are in the server README
Config file
{
"mcpServers": {
"ibm-db2-for-i": {
"command": "npx",
"args": [
"-y",
"mcp-server-db2i"
],
"env": {
"DB2I_HOSTNAME": "<DB2I_HOSTNAME>",
"DB2I_USERNAME": "<DB2I_USERNAME>",
"DB2I_PASSWORD": "<DB2I_PASSWORD>",
"DB2I_SCHEMA": "<DB2I_SCHEMA>",
"DB2I_PROFILES": "<DB2I_PROFILES>"
}
}
}
}Replace <…> with your own values. 5 more environment variables are in the server README
Config file
{
"servers": {
"ibm-db2-for-i": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-server-db2i"
],
"env": {
"DB2I_HOSTNAME": "<DB2I_HOSTNAME>",
"DB2I_USERNAME": "<DB2I_USERNAME>",
"DB2I_PASSWORD": "<DB2I_PASSWORD>",
"DB2I_SCHEMA": "<DB2I_SCHEMA>",
"DB2I_PROFILES": "<DB2I_PROFILES>"
}
}
}
}Replace <…> with your own values. 5 more environment variables are in the server README
Platform CLI
gemini mcp add -e DB2I_HOSTNAME=<DB2I_HOSTNAME> -e DB2I_USERNAME=<DB2I_USERNAME> -e DB2I_PASSWORD=<DB2I_PASSWORD> -e DB2I_SCHEMA=<DB2I_SCHEMA> -e DB2I_PROFILES=<DB2I_PROFILES> ibm-db2-for-i npx -y mcp-server-db2iReplace <…> with your own values. 5 more environment variables are in the server README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about IBM Db2 for i
How do I install IBM Db2 for i in Claude Code?
Run `claude mcp add mcp-server-db2i -e DB2I_HOSTNAME=<DB2I_HOSTNAME> -e DB2I_USERNAME=<DB2I_USERNAME> -e DB2I_PASSWORD=<DB2I_PASSWORD> -- npx -y mcp-server-db2i with your own values. Or register it with an explicit transport and profiles: claude mcp add --env DB2I_HOSTNAME=<DB2I_HOSTNAME> --env DB2I_USERNAME=<DB2I_USERNAME> --env DB2I_PASSWORD=<DB2I_PASSWORD> --env DB2I_SCHEMA=<DB2I_SCHEMA> --env DB2I_PROFILES=<DB2I_PROFILES> --transport stdio ibm-db2-for-i -- npx -y mcp-server-db2i`.
What does IBM Db2 for i do?
It runs read-only SQL on IBM i on the assistant's behalf and exposes metadata: libraries, tables, columns, indexes and views. Data changes are not possible.
What does the server need to connect?
A host, user and password for IBM i in DB2I_HOSTNAME, DB2I_USERNAME and DB2I_PASSWORD. Where the ODBC port is closed, set DB2I_DRIVER=mapepire to go over SSH.