mcp-server-db2i
Summary: mcp-server-db2i is a read-only MCP server that lets AI assistants explore, query, and profile IBM Db2 for i databases over stdio or HTTP.
Run read-only SQL -
execute_queryruns SELECT statements with row limits, parameter binding, and automatic truncation.Explore schemas and tables -
list_schemas,list_tables,search_tables,search_columns, anddescribe_tablemap out libraries, tables, and columns.Inspect structure -
list_views,list_indexes, andget_table_constraintscover views, indexes, primary/foreign/unique keys.Work with routines -
list_routinesanddescribe_routinesurface procedures and functions, including parameters, return values, and call templates.Validate before running -
validate_queryparses SQL and checks tables, columns, and routines without executing anything.Recover object definitions -
get_object_ddlreturns reconstructed DDL;get_related_objectslists dependent objects.Support replication and BI -
get_journal_infochecks journaling and primary keys;index_adviceandprofile_tablehelp with ETL tuning and data profiling.Discover IBM i services -
search_ibmi_servicesfinds QSYS2/SYSTOOLS services with release info and examples.Apply business context -
get_business_contextreturns YAML-defined descriptions, row filters, and relations.Connect flexibly - Local stdio or remote Streamable HTTP with OAuth 2.1/bearer tokens, multiple IBM i systems via
DB2I_PROFILES, and ODBC, JT400 JDBC, or Mapepire-over-SSH drivers.Keep it safe and manageable - Read-only enforcement, schema allowlists, column masking, rate limiting, query timeouts, audit logging, tool selection, and token-saving compact/markdown responses.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-db2i list the columns for the INV_HEADER table in the ERP_DATA schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Db2 for i MCP Server
mcp-server-db2i is a Model Context Protocol (MCP) server for IBM Db2 for i (Db2i) on IBM i (AS/400). It enables AI assistants like Claude and Cursor to query and inspect IBM i databases through the IBM i Access ODBC driver, or optionally the JT400 JDBC driver or Mapepire over SSH.
Listed in the MCP Registry as io.github.Strom-Capital/mcp-server-db2i.
Website: db2i-mcp.com, with a blog that explains each release. Docs: docs.db2i-mcp.com.
Architecture
AI clients connect to the MCP Server in one of two ways. Local clients such as Claude Desktop, Claude Code and Cursor can start it as a process and talk over stdio. Remote clients connect over Streamable HTTP at /mcp, signing in with OAuth 2.1 (claude.ai custom connectors) or a bearer token (custom agents). Local clients can also use the HTTP endpoint. The server executes read-only queries against Db2 for i using the IBM i Access ODBC driver (default, no Java), the optional JT400 JDBC driver (DB2I_DRIVER=jt400), or Mapepire over SSH (DB2I_DRIVER=mapepire) for systems where only SSH is reachable. One server can reach several IBM i systems through connection profiles, each with its own driver.
graph LR
subgraph clients ["AI Clients"]
local("Claude Desktop, Claude Code, Cursor")
remote("claude.ai connectors")
agents("Custom Agents")
end
subgraph server ["MCP Server"]
stdio["stdio"]
http["Streamable HTTP + Auth"]
tools[["MCP Tools"]]
profiles{{"System profiles"}}
odbc["IBM i Access ODBC"]
jdbc["JT400 JDBC (optional)"]
mapepire["Mapepire over SSH (optional)"]
end
subgraph prod ["IBM i: prod"]
db2prod[("Db2 for i")]
end
subgraph test ["IBM i: test"]
db2test[("Db2 for i")]
end
subgraph dev ["IBM i: dev"]
db2dev[("Db2 for i")]
end
local -->|local process| stdio
local -.->|remote URL| http
remote -->|OAuth 2.1| http
agents -->|bearer token| http
stdio & http --> tools
tools --> profiles
profiles --> odbc & jdbc & mapepire
odbc -->|ODBC| db2prod
jdbc -->|JDBC| db2test
mapepire -->|SSH| db2devRelated MCP server: db2-mcp-server
Features
Read-only SQL queries - Execute SELECT statements safely with automatic result limiting, and a query timeout that cancels runaway statements on the IBM i
Schema inspection - List all schemas/libraries with optional filtering
Table metadata - List tables, describe columns, view indexes and constraints
View inspection - List and explore database views
Secure by design - Only SELECT queries allowed, credentials via environment variables
Docker support - Run as a container for easy deployment
HTTP Transport - MCP over Streamable HTTP with token authentication for remote clients and agents
OAuth for Remote Clients - Built-in OAuth 2.1 sign-in with the user's own IBM i profile, so claude.ai custom connectors can connect. The sign-in page can carry your company's name, logo, colors and language (Customize for your company)
Current MCP spec - Speaks 2026-07-28 and still serves stateless 2025-era clients
Dual Transport - Run stdio and HTTP simultaneously
Multiple systems - Reach several IBM i systems from one server with
DB2I_PROFILES, each with its own driver, credentials, and library allowlist. Tools take an optionalsystemargument. See Multiple systemsSSH-only systems - With
DB2I_DRIVER=mapepire, reach an IBM i where only SSH is open. Mapepire starts inside the SSH session, with no server install and a host key check. See Using the Mapepire driverTool selection - Enable or disable individual tools, e.g. a metadata-only mode without
execute_queryBusiness SQL tools - Load read-only ERP queries and table notes from YAML, and check the files with
mcp-server-db2i validate-toolsbefore the server starts. See Business SQL toolsServer instructions - Send the rules no query may miss, such as which flag marks a deleted row, to the model at the start of every session. See Instructions
Charts in the chat - Hosts that support MCP Apps show query results as a sortable grid under the tool call, with a chart one click away. When the user asks for a chart, or a YAML tool sets one, it opens on the chart. See Result view
Compact responses - Compact JSON by default, or markdown tables to save tokens
Statement checks and DDL - Validate object names, return the SQL that recreates an object, and list what depends on a table
Catalog search and profiling - Find tables and columns across libraries, check journaling, and profile a table's row counts and value ranges
Column masking - Redact sensitive columns, or show only their last four characters, in query results. See Column masking
Query exports - Hand the user a CSV or Excel file of a query's results, as a file path over stdio or a short-lived download link over HTTP. The rows never pass through the model. See Query exports
Audit log - Record every tool call and sign-in as one JSON line, with the SQL hashed by default. Optionally record the model's reason for each call (
MCP_TOOL_INTENT). See Audit logTool reload - Reload YAML tool files when they change, with
MCP_CUSTOM_TOOLS_WATCH=trueResources and prompts - Read table columns and DDL as MCP resources, and start from prompts that explore a library, explain a table, or write a query. See Resources and prompts
Quick Start
Installation
npm install -g mcp-server-db2iThe default odbc driver needs unixODBC and the IBM i Access ODBC Driver on the machine. No Java is needed. The other drivers' packages are not installed by default, so add them next to the server:
npm install -g mcp-server-db2i node-jt400 # DB2I_DRIVER=jt400, needs a JDK to install and a JRE to run
npm install -g mcp-server-db2i @ibm/mapepire-js ssh2 # DB2I_DRIVER=mapepire, when only SSH reaches the IBM iWith npx, pass them with -p, for example npx -y -p mcp-server-db2i@latest -p node-jt400 mcp-server-db2i. See Installing the jt400 and mapepire packages.
Or with Docker:
docker build -t mcp-server-db2i . # odbc image (amd64; add --platform linux/amd64 on arm64)
docker build --target jt400 -t mcp-server-db2i . # jt400 image (builds natively on arm64)Configuration
Create a .env file with your IBM i credentials:
DB2I_HOSTNAME=your-ibm-i-host.com
DB2I_USERNAME=your-username
DB2I_PASSWORD=your-password
DB2I_SCHEMA=your-default-schema # OptionalClient Setup
Add to your MCP client config (e.g., ~/.cursor/mcp.json):
{
"mcpServers": {
"db2i": {
"command": "npx",
"args": ["-y", "mcp-server-db2i@latest"],
"env": {
"DB2I_HOSTNAME": "${env:DB2I_HOSTNAME}",
"DB2I_USERNAME": "${env:DB2I_USERNAME}",
"DB2I_PASSWORD": "${env:DB2I_PASSWORD}"
}
}
}
}This uses environment variable expansion to keep credentials out of config files. Set the variables in your shell profile (~/.zshrc or ~/.bashrc).
See the Client Setup Guide for Cursor, Claude Desktop, Claude Code, and Docker setup options.
No MCP client? The example web app is a browser chat with result tables, exports and the business SQL tools. Users sign in with their IBM i user profile and bring their own model API key.
Available Tools
Tool | Description |
| Execute read-only SELECT queries, with an optional |
| Write every row of a read-only query to a CSV or XLSX file: a path over stdio, a short-lived download link over HTTP. Off unless |
| List schemas/libraries (with optional filter) |
| List tables in a schema (with optional filter) |
| Find tables by name or description across libraries |
| Find columns by name or description across libraries |
| Get detailed column information |
| List views in a schema (with optional filter) |
| List SQL indexes for a table |
| Get primary keys, foreign keys, unique constraints |
| List SQL procedures and functions in a library, with language, external program, and SQL data access |
| Parameters, return value or result columns, and a call template for a procedure or function |
| Check a statement without running it, including catalog names |
| Return the SQL DDL that recreates an object |
| List objects that depend on a table |
| List journal, images, and primary key per table, and flag tables a replication tool cannot read |
| List the indexes the query optimizer asked for in a library, merged and ranked by temporary index use |
| Row count, last change, and per-column distinct and null counts from stored statistics or a scan |
| List business descriptions, row filters and relations loaded from YAML |
| Find IBM i services by keyword or category, with the release that added each one and an example query |
In hosts that support MCP Apps, results from execute_query, profile_table and business SQL tools open as a grid and a chart under the tool call. See Result view.
Filter Syntax
The list tools support pattern matching:
CUST- Contains "CUST"CUST*- Starts with "CUST"*LOG- Ends with "LOG"
Resources and prompts
Clients that support MCP resources can read a table's context without a tool call, and complete library and table names as you type.
Resource | Contents | Registered when |
| Columns from the catalog, plus the YAML business description, column notes, and relations |
|
| SQL from |
|
| Every annotation loaded from |
|
| The result view MCP Apps hosts show under tool results |
|
resources/list offers the annotated tables, for example db2i://MYLIB/ORDERS. Percent-encode # and other reserved characters in names (ORD%23X for ORD#X). A library outside QUERY_ALLOWED_SCHEMAS is rejected with the same message execute_query gives, and completion offers only allowed libraries. Reads and completions that query IBM i count against the rate limit, and reads are written to the audit log. Completion fetches a library's name list once and reuses it for 60 seconds, so typing a name costs one query rather than one per keystroke.
Prompt | Arguments | What it asks for |
|
| List the tables, describe the central ones, and summarize how they join |
|
| Explain rows, columns, keys, and relations in plain language |
|
| Write one SELECT from the table's real columns and YAML relations, then validate and run it when those tools are enabled |
A prompt is listed only when the tools it tells the model to call are enabled: explore_library needs list_tables and describe_table, and the other two need describe_table. None of them asks for a write.
Use cases
I've used this server on projects where the source system was the Iptor DC1 ERP on IBM i. The same patterns work with any IBM i ERP.
Building REST APIs - The agent finds the ERP tables and keys, checks its SQL with
validate_query, tests it on sample rows, and then writes the endpoint.ETL and ELT pipelines for BI - Profile source tables, generate staging DDL with
get_object_ddl, and draft incremental extracts and code mappings for the warehouse.Near-real-time replication to BI - Check which tables are journaled, and with which images, before a journal-based tool such as Fivetran streams changes to the warehouse.
Ad-hoc analysis - Connect Claude or Cursor directly to the ERP and ask business questions in plain language, with vetted Business SQL tools and column masking for sensitive fields.
See Use cases for sample prompts and the guardrails that go with each one.
Example Usage
Once connected, you can ask the AI assistant:
"List all schemas that contain 'PROD'"
"Show me the tables in schema MYLIB"
"Describe the columns in MYLIB/CUSTOMERS"
"What indexes exist on the ORDERS table?"
"Run this query: SELECT * FROM MYLIB.CUSTOMERS WHERE STATUS = 'A'"
"Find the order header and line tables in MYLIB and write a GET /orders/:orderNo endpoint"
"Draft an incremental extract of MYLIB.ORDERHDR rows changed since yesterday"
Documentation
Guide | Description |
Built-in tools, filter syntax, MCP resources, and prompts | |
HTTP API, auth, and protocol versions | |
All environment variables and driver options | |
Credentials, rate limiting, query validation | |
YAML tools for orders, ledgers, and master data | |
REST APIs, BI pipelines, replication, and ad-hoc analysis | |
Cursor, Claude, Claude Code setup | |
Browser chat with your own model key and IBM i sign-in | |
Container deployment | |
Contributing and local setup |
Compatibility
IBM i V7R3 and later (V7R5 recommended)
validate_queryand theexecute_queryparse check needQSYS2.PARSE_STATEMENT(IBM i 7.3 with Db2 PTF group SF99703 level 3, or 7.4 and later)get_related_objectsneeds IBM i 7.3 Technology Refresh 9, IBM i 7.4 Technology Refresh 3, or a later releaseget_journal_infoneeds the journal columns ofQSYS2.OBJECT_STATISTICS(IBM i 7.3 Technology Refresh 2 or later)search_ibmi_servicesneedsQSYS2.SERVICES_INFO, which ships with the Db2 for i PTF groupThe
causeandrecoveryon a failed statement come fromSYSTOOLS.SQLCODE_INFO. Without it, errors return the SQLSTATE, SQLCODE and message onlyNode.js 22 or higher
unixODBC with the IBM i Access ODBC Driver for the default
odbcdriver, a JDK at install time and a JRE 11 or higher at runtime for the optionaljt400driver, or SSH access and Java 8 or higher on the IBM i for the optionalmapepiredriver (see Database Drivers)MCP spec 2026-07-28, plus stateless clients from the 2025-era revisions (through 2025-11-25)
Related Projects
IBM ibmi-mcp-server - IBM's official MCP server for IBM i systems. Offers YAML-based SQL tool definitions and AI agent frameworks. Requires Mapepire. This project's
mapepiredriver uses Mapepire's SSH mode, which needs no Mapepire server running on the IBM i.
Contributing
Contributions are welcome! See the Development Guide for setup instructions.
License
MIT License - see LICENSE for details.
Trademarks
IBM, IBM i and Db2 are trademarks of International Business Machines Corporation. This project is not affiliated with or endorsed by IBM.
Acknowledgments
node-jt400 - JT400 JDBC driver wrapper for Node.js
node-odbc - ODBC bindings for Node.js, maintained by IBM
mapepire-js - Mapepire client for Node.js, maintained by IBM
Model Context Protocol - The protocol specification
@modelcontextprotocol/server - Official TypeScript SDK (spec 2026-07-28, with stateless 2025-era clients)
Available Tools
19 toolsdescribe_routineDescribe RoutineARead-onlyIdempotent
Describe an SQL procedure or function from QSYS2.SYSPARMS: parameters in order with mode, data type, and default; the return value of a scalar function; and the result columns of a table function. An overloaded name returns every overload unless specific_name picks one. call_template is a statement with a ? marker per parameter. callable_with_execute_query says whether execute_query can run it: procedures (CALL) and functions that modify SQL data cannot, and note says why. Uses the system's default schema if not provided.
Inputs: name, schema, specific_name. Returns: data, cause, count, error, +6 more
describe_tableDescribe TableARead-onlyIdempotent
Get detailed column information for a specific table including data types, lengths, nullability, defaults, and CCSID. Uses the system's default schema if not provided.
Inputs: table (required), schema. Returns: data, count, error, filters, +3 more
execute_queryExecute SQL QueryARead-onlyIdempotent
Execute a read-only SQL SELECT query against the IBM Db2i database. Only SELECT statements are allowed for security. Results are limited by default to prevent large result sets. Pass chart only when the user asks for a chart or graph. Otherwise leave it out: the result opens as a table and the user can switch to a chart.
Inputs: sql (required), chart, limit, params. Returns: data, cause, chart, error, +12 more
get_business_contextGet Business ContextARead-onlyIdempotent
List business entities, row filters most queries need (such as leaving out deleted rows), table and column descriptions, and relations that the catalog does not declare as foreign keys. Filter by entity or table. Omit both to return every annotation loaded from MCP_CUSTOM_TOOLS. An unknown entity name falls back to names that partly match it, and when nothing matches, the result lists the loaded entity names.
Inputs: table, entity. Returns: data, hint, count, error, +4 more
get_journal_infoGet Journal InfoARead-onlyIdempotent
List the physical data files in a library with their journal, journal library, journal images, omitted entries, and whether they have a primary key, using QSYS2.OBJECT_STATISTICS. needs_attention is true when a table is not journaled, or has no primary key and does not journal both images, which journal-based replication tools need. Requires IBM i 7.3 Technology Refresh 2 or later.
Inputs: limit, filter, schema. Returns: data, count, error, schema, +3 more
get_object_ddlGet Object DDLARead-onlyIdempotent
Return the SQL DDL that recreates a database object, using QSYS2.GENERATE_SQL. Does not run the generated statements. Requires IBM i 7.3 or later.
Inputs: type (required), object (required), schema. Returns: ddl, type, error, object, +2 more
get_table_constraintsGet Table ConstraintsBRead-onlyIdempotent
Get all constraints (primary keys, foreign keys, unique constraints) for a specific table. Uses the system's default schema if not provided.
Inputs: table (required), schema. Returns: data, count, error, success
index_adviceIndex AdviceARead-onlyIdempotent
List the indexes the query optimizer asked for on the tables of a library, from the IBM i index advisor (QSYS2.SYSIXADV). Rows with the same table, key columns, and index type are merged into one, with counts summed and reason codes described. Sorted by mti_used, then times_advised: advice where the optimizer kept building and reusing a maintained temporary index (MTI) is the strongest signal. key_columns are in CREATE INDEX order and can end in DESC. last_advised and since are in the system's local time. This tool only reads the advice; it does not create indexes.
Inputs: limit, since, table, schema. Returns: data, cause, count, error, +8 more
list_indexesList IndexesBRead-onlyIdempotent
List all indexes for a specific table including uniqueness and column information. Uses the system's default schema if not provided.
Inputs: table (required), schema. Returns: data, count, error, success
list_routinesList RoutinesARead-onlyIdempotent
List SQL procedures and functions in a library from QSYS2.SYSROUTINES, one row per specific routine, so overloads appear once each. Shows the type (procedure, scalar function, or table function), language, external program, SQL data access, result sets, and text. Use describe_routine for parameters and a call template. Uses the system's default schema if not provided.
Inputs: type, limit, filter, schema. Returns: data, cause, count, error, +6 more
list_schemasList SchemasARead-onlyIdempotent
List all schemas (libraries) in the IBM Db2i database. Optionally filter by name pattern using * as wildcard.
Inputs: filter. Returns: data, count, error, success
list_tablesList TablesBRead-onlyIdempotent
List all tables in a schema (library). Uses the system's default schema if not provided. Optionally filter by name pattern using * as wildcard.
Inputs: filter, schema. Returns: data, count, error, success
list_viewsList ViewsARead-onlyIdempotent
List all views in a schema (library). Uses the system's default schema if not provided. Optionally filter by name pattern using * as wildcard.
Inputs: filter, schema. Returns: data, count, error, success
profile_tableProfile TableARead-onlyIdempotent
Profile a table for ETL work: row count, deleted rows, size, and last change from QSYS2.SYSTABLESTAT, plus per-column distinct count, null count, and low and high values. By default column numbers come from stored statistics in QSYS2.SYSCOLUMNSTAT (low and high are the second-lowest and second-highest values), and columns without collected statistics report source "none". Set compute to true to scan the table for exact numbers on up to 20 columns. Masked columns keep their counts and return no values.
Inputs: table (required), schema, columns, compute. Returns: sql, data, mode, cause, +12 more
search_columnsSearch ColumnsARead-onlyIdempotent
Find columns by name or description text across libraries. Matches COLUMN_NAME, SYSTEM_COLUMN_NAME, and COLUMN_TEXT. Use * as a wildcard. When a schema allowlist is configured, only those libraries are searched. Otherwise system libraries (Q* and SYS*) are skipped unless include_system is true.
Inputs: filter (required), limit, schema, include_system. Returns: data, count, error, success, +1 more
search_ibmi_servicesSearch IBM i ServicesARead-onlyIdempotent
Find IBM i SQL services (views, table functions, procedures, and more in QSYS2 and SYSTOOLS) in the catalog QSYS2.SERVICES_INFO, with the release that added each one and an example query. Call it before writing SQL that uses an IBM i service, instead of guessing names and parameters. With no query and no category, it lists the categories with a count each. This tool only reads the catalog. Running an example with execute_query still needs the IBM i authority the service documents and, when QUERY_ALLOWED_SCHEMAS is set, the service's schema in that list. Table functions must be qualified, as in TABLE(QSYS2.ACTIVE_JOB_INFO(DETAILED_INFO => 'NONE')), with plain values as arguments.
Inputs: limit, query, category, include_example, +1 more. Returns: data, count, error, success, +2 more
search_tablesSearch TablesARead-onlyIdempotent
Find tables by name or description text across libraries. Matches TABLE_NAME, SYSTEM_TABLE_NAME, and TABLE_TEXT. Use * as a wildcard. When a schema allowlist is configured, only those libraries are searched. Otherwise system libraries (Q* and SYS*) are skipped unless include_system is true.
Inputs: filter (required), limit, schema, include_system. Returns: data, count, error, success, +1 more
validate_queryValidate SQL QueryARead-onlyIdempotent
Check a SQL statement without running it. Parses it with QSYS2.PARSE_STATEMENT and checks that referenced tables, columns, and qualified routines exist in the catalog. Also reports read-only and schema-allowlist findings.
Inputs: sql (required). Returns: cause, error, valid, sqlcode, +10 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools have clearly distinct purposes (listing vs searching vs describing vs profiling), and descriptions carefully delineate boundaries. Minor overlap exists between list_tables and search_tables, and between describe_table and profile_table, but descriptions clarify the difference (single-schema listing vs cross-library search; structure vs data profiling).
Strong verb_noun convention throughout: list_*, search_*, describe_*, get_*, execute_query, validate_query, profile_table. Only index_advice breaks the pattern by using a noun-only name, a minor deviation in an otherwise predictable scheme.
19 tools is slightly heavy but each covers a genuinely distinct capability spanning schema/table/column/routine inspection, query validation, DDL generation, and IBM i-specific services. No redundant tools inflate the count, so it stays reasonable for a database-exploration server.
The surface covers discovery (schemas, tables, columns, views, indexes, routines), introspection (describe, DDL, constraints, related objects), and IBM i specifics (journal info, services, index advice, business context). Read-only querying is intentionally the only execution path; no write/DML tools exist, which is a deliberate rather than missing scope.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with IBM i systems through the Model Context Protocol, providing secure SQL-based access to Db2 for i databases for querying, monitoring, and executing operations.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables read-only interaction with IBM DB2 databases, including listing tables and retrieving table metadata.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to securely interact with IBM i (AS/400) systems via ODBC, supporting SQL queries, CL commands, source code reading, compilation, and spoolfile analysis.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to safely query and explore SQL Server and PostgreSQL databases with read-only access, supporting schema discovery, relationship exploration, and query execution.3MIT