Open source · MCP server for Db2 for i
Ask your IBM i in plain language.
Claude, Cursor and other AI assistants can read your Db2 for i data, look up tables and check their own SQL. Read-only by design. It connects through the host servers your IBM i already runs, or over SSH, so there is nothing new to install on the system.
npx mcp-server-db2iWhich customers have the most open orders right now?
describe_tableMYLIB.ORDERHDRTable note: STATUS = 'O' means open.
execute_queryread-onlySELECT C.NAME, COUNT(*) AS OPEN_ORDERS
FROM MYLIB.ORDERHDR H
JOIN MYLIB.CUSTOMERS C ON C.CUSTNO = H.CUSTNO
WHERE H.STATUS = 'O'
GROUP BY C.NAME
ORDER BY OPEN_ORDERS DESC
FETCH FIRST 3 ROWS ONLYThree customers account for most of the open orders:
| Customer | Open orders |
|---|---|
| Acme Tools | 14 |
| Birch Supply | 9 |
| Harbor Parts | 7 |
What you get
Built for production IBM i systems
The read-only checks are always on. The allowlist, masking and audit log are one setting each. Every control is documented, so your IBM i team can see exactly what is enforced and where.
Read-only by design
A read-only database connection, a SQL validator that only accepts queries, and a timeout that cancels runaway statements on the IBM i itself.
Library allowlist and masking
Limit queries and catalog browsing to the libraries you choose. Redact sensitive columns, or show only their last four characters.
Sign in as yourself
Built-in OAuth 2.1. People add one URL in claude.ai, Cursor or Claude Code, sign in with their own IBM i profile and keep the authority they already have.
Three ways to connect
The IBM i Access ODBC driver by default, JT400 if you prefer JDBC, or Mapepire over SSH when only port 22 is open.
Several systems, one server
Development, test and production side by side, each with its own driver, credentials and library allowlist.
Your business definitions
Describe tables and status codes in YAML, and turn your vetted queries into named tools with bound parameters.
IBM i checks the SQL
validate_query parses a statement on the IBM i and checks every table and column against the catalog before anything runs.
Find your way around
Search tables and columns across libraries, profile a table, read DDL, and look up procedures, functions and index advice.
Audit log
Every tool call written as one JSON line, with the SQL hashed by default, ready for your log pipeline.
How it fits together
From a question to Db2 for i and back
The server sits between your AI assistant and the IBM i. Every request passes the same checks, whichever client or driver you use.
- AI assistantClaude, Cursor, Claude CodeAny client that speaks the Model Context Protocol.
- mcp-server-db2istdio, or HTTP with OAuth
- Read-only SQL validation
- Library allowlist
- Column masking
- Rate limits and audit log
- DriverODBC, JT400 or MapepireHost server ports, or SSH only.
- IBM iDb2 for iRuns with the user's own authority. Exit programs still apply.
Install
Pick how you run it
The default ODBC driver needs unixODBC and the IBM i Access ODBC Driver on the machine that runs the server. Nothing is installed on the IBM i.
Add the server to your MCP client config. Claude Desktop, Cursor and Claude Code all use this shape.
{
"mcpServers": {
"db2i": {
"command": "npx",
"args": ["mcp-server-db2i"],
"env": {
"DB2I_HOSTNAME": "ibmi.example.com",
"DB2I_USERNAME": "${env:DB2I_USERNAME}",
"DB2I_PASSWORD": "${env:DB2I_PASSWORD}",
"QUERY_ALLOWED_SCHEMAS": "MYLIB"
}
}
}
}Client setup guide →Run it as a container: started by your MCP client over stdio, or as a shared HTTP server for your team.
git clone https://github.com/Strom-Capital/mcp-server-db2i
cd mcp-server-db2i
docker build -t mcp-server-db2i .
# stdio: your MCP client starts the container
docker run -i --rm --env-file .env mcp-server-db2i
# HTTP for a team: uncomment "ports" in docker-compose.yml
docker-compose up -dDocker guide →Run the server over HTTPS with OAuth. Everyone else adds one URL and signs in with their own IBM i profile.
MCP_TRANSPORT=http
MCP_OAUTH_ENABLED=true
MCP_PUBLIC_URL=https://mcp.example.com
MCP_OAUTH_SECRET=<a long random string>
# Then, in claude.ai: Settings > Connectors > Add custom connector
# URL: https://mcp.example.com/mcpRemote clients and OAuth →Other options
Which MCP server fits you
IBM maintains its own open-source MCP server for IBM i. Both are free, and they start from different places. Here is how to choose.
From the blog
What's new, and why
What "open order" means at your company
How your own business definitions, written down once, keep an AI assistant from guessing about your ERP data. Explained without the technical detail.
New questions for the ERP data you already have
How an AI assistant can answer the one-off questions between reports, against live ERP data on IBM i, alongside the screens, Excel workbooks and BI tools you already use.
Services, timeouts and routines (2.10 and 2.11)
A query timeout that cancels on the IBM i, IBM i services search, SQL errors with cause and recovery text, index advice, and procedures and functions.
Free, open source, and yours to run
MIT licensed. It runs on your own machines and talks only to your IBM i. Questions, ideas and bug reports are welcome on GitHub.