# IBM Db2 for i [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/Strom-Capital/mcp-server-db2i  
**GitHub Stars:** 31  
**npm Downloads (last month):** 9202  
**Views:** 3  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/ibm-db2-for-i

## Description
Read-only SQL queries and schema inspection for IBM Db2 for i over ODBC, JT400 or Mapepire (SSH).

## Tools
Capabilities this server exposes over MCP:

- **execute_query** — 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.
- **list_schemas** — List all schemas (libraries) in the IBM Db2i database. Optionally filter by name pattern using * as wildcard.
- **list_tables** — List all tables in a schema (library). Uses the system's default schema if not provided. Optionally filter by name pattern using * as wildcard.
- **search_tables** — 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.
- **search_columns** — 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.
- **describe_table** — 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.
- **list_views** — List all views in a schema (library). Uses the system's default schema if not provided. Optionally filter by name pattern using * as wildcard.
- **list_indexes** — List all indexes for a specific table including uniqueness and column information. Uses the system's default schema if not provided.
- **get_table_constraints** — Get all constraints (primary keys, foreign keys, unique constraints) for a specific table. Uses the system's default schema if not provided.
- **list_routines** — 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.
- **describe_routine** — 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.
- **validate_query** — 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.
- **get_object_ddl** — 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.
- **get_related_objects** — List views, indexes, triggers, and other objects that depend on a table, using SYSTOOLS.RELATED_OBJECTS. Requires IBM i 7.3 Technology Refresh 9, IBM i 7.4 Technology Refresh 3, or a later release.
- **get_journal_info** — 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.
- **search_ibmi_services** — 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.
- **index_advice** — 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.
- **profile_table** — 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.
- **get_business_context** — 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.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "ibm-db2-for-i": {
    "command": "npx",
    "args": ["-y","-p","mcp-server-db2i@latest","-p","node-jt400","mcp-server-db2i"],
    "env": {
      "DB2I_HOSTNAME": "",
      "DB2I_USERNAME": "",
      "DB2I_PASSWORD": ""
    }
  }
}
```

**Requires environment variables:** `DB2I_HOSTNAME`, `DB2I_USERNAME`, `DB2I_PASSWORD` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What IBM Db2 for i does

IBM Db2 for i exposes a read-only database interface through MCP for IBM i and AS/400 environments. Its query tool accepts SELECT statements only and applies result limits by default. The server also provides catalog-oriented tools for exploring schemas, tables, views, columns, routines, indexes, constraints, and related objects.

Beyond basic metadata, it can validate SQL without executing it, return recreating DDL, inspect journal configuration, read index-advisor information, profile table statistics, search IBM i SQL services, and retrieve business context loaded from MCP_CUSTOM_TOOLS. Query results can be returned as compact JSON or markdown tables. Query exports can produce CSV or Excel files without passing the rows through the model.

## How it works

MCP clients communicate with the server over local stdio or Streamable HTTP at `/mcp`. The server then connects to one or more IBM i systems through a configured connection profile. ODBC is the default path and uses the IBM i Access ODBC driver without Java. JT400 JDBC can be selected for environments using Java, while Mapepire can connect over SSH when the IBM i system is reachable only through SSH.

Multiple systems can be configured with `DB2I_PROFILES`; tools accept an optional system selector. Individual tools can also be enabled or disabled, allowing a metadata-only deployment that excludes query execution. SQL queries have a timeout, and result limits help avoid unexpectedly large responses. Column masking can redact sensitive values or expose only their last four characters.

## Setup and configuration

Install the npm package globally or run it with `npx`. The default driver requires Node.js 22 or later, unixODBC, and the IBM i Access ODBC Driver. JT400 requires the `node-jt400` package, a JDK for installation, and a JRE at runtime. Mapepire requires `@ibm/mapepire-js` and `ssh2`.

Set `DB2I_HOSTNAME`, `DB2I_USERNAME`, and `DB2I_PASSWORD` for the IBM i connection. `DB2I_SCHEMA` optionally sets the default schema used when a tool does not receive one. Docker images are available for ODBC and JT400 deployments; the ODBC image targets amd64 unless an appropriate platform is specified.

Local configurations can start the process directly. Remote deployments use the HTTP endpoint with bearer-token authentication or OAuth 2.1 sign-in. Claude Desktop, Claude Code, and Cursor are documented as local stdio clients, and they can also use the HTTP endpoint where applicable.

## Tools and capabilities

- Run restricted SELECT queries with optional chart output and bounded results.
- Enumerate and search libraries, tables, columns, views, routines, and IBM i SQL services.
- Inspect table columns, indexes, constraints, routine parameters, return values, and result columns.
- Validate SQL, generate object DDL, and find objects related to a table.
- Review index advice, journal status, row statistics, column distributions, null counts, and value ranges.
- Load business entities, row-filter guidance, descriptions, and non-declared relationships from custom annotations.

`get_object_ddl` requires IBM i 7.3 or later. Related-object lookup requires IBM i 7.3 Technology Refresh 9, IBM i 7.4 Technology Refresh 3, or a later release. Journal inspection requires IBM i 7.3 Technology Refresh 2 or later.

## Limitations and notes

The query interface is intentionally read-only: only SELECT statements are accepted, and generated DDL is returned rather than executed. Procedures and functions that modify SQL data cannot be run through `execute_query`; routine inspection reports whether a callable object is eligible and explains the reason when it is not.

Catalog searches skip Q* and SYS* system libraries by default unless `include_system` is enabled. A configured schema allowlist restricts searches and can also affect IBM i service examples. Table functions must be qualified when called. Profiling with `compute=true` scans the table for exact values on up to 20 columns, while masked columns retain counts but do not return values.

_Full upstream README: https://allmcps.com/mcp/ibm-db2-for-i/readme_

