An MCP server turns Db2 for i into tools an agent can call. Connecting one takes an afternoon. Governing it takes seven controls IBM i already has, each with a check you can run.
Short answer. Before an agent reaches Db2 for i through an MCP server, give the server a profile of its own with no special authorities, grant that profile read access to chosen views only, keep the server's tools read-only, limit Mapepire to that profile from that host, audit what it reads, and name the person who owns it. Then prove what it can't do.
The IBM i MCP Server is IBM's open-source MCP server for IBM i (Apache 2.0). It turns SQL statements defined in YAML into tools an agent can call, and it reaches Db2 for i through Mapepire, IBM's open-source database server for IBM i, on port 8076. The Db2 for i MCP Server is a community project (MIT) that reads Db2 for i through the JT400 JDBC driver and is read-only by design.
Either way, every tool call becomes SQL that runs under one IBM i profile. Whatever that profile can do, the agent can do. The server's own settings are checks inside the server. The profile's authority is a check IBM i enforces. You want both, and the one IBM i enforces is the one to lead with.
The controls below apply to either server. The Mapepire ones apply where Mapepire is in the path.
Before you run the checks
<MCP_PROFILE> with the profile the server signs on with, <APPLIB> with the library that holds the application's data, and <AGENT_HOST> with the address the server connects from.Who it is · what it can reach
On IBM i: User profiles · special authorities · group profiles
The check. The server's connection settings (DB2i_USER in the IBM i MCP Server) name one profile. Make it a profile that belongs to this server and nothing else: not a person's, not a batch profile, and not one shared with another server. Then confirm it has no special authorities, directly or through a group.
-- The server's profile, and what it inherits from its group
SELECT u.authorization_name, u.status, u.special_authorities,
u.group_profile_name, g.special_authorities AS group_special_authorities,
u.supplemental_group_list, u.limit_capabilities,
u.initial_menu_name, u.initial_program_name, u.text_description
FROM qsys2.user_info u
LEFT JOIN qsys2.user_info g ON g.authorization_name = u.group_profile_name
WHERE u.authorization_name = '<MCP_PROFILE>';A good result
SPECIAL_AUTHORITIES is empty, and so is the group's, if there is a group. No supplemental groups, or none with special authorities.LIMIT_CAPABILITIES is *YES and INITIAL_MENU_NAME is *SIGNOFF, so the profile can't be used for a green-screen session.TEXT_DESCRIPTION names the server and its owner, so anyone who finds the profile knows whose it is.Watch for
.env file on a laptop is shared with everyone who can read that laptop.On IBM i: Object authority · *PUBLIC · SQL views
The check. Decide what the agent needs to read and build SQL views for it: the columns it needs, the rows it needs, nothing more. Grant the profile *USE on those views and nothing on the tables under them. Then list every object the profile has authority to, and what *PUBLIC can reach in the application library, because *PUBLIC authority applies to this profile too.
-- Every object the server's profile holds a private authority to SELECT system_object_schema, system_object_name, object_type, object_authority FROM qsys2.object_privileges WHERE authorization_name = '<MCP_PROFILE>' ORDER BY 1, 2;
-- What *PUBLIC can reach in the application library (the server's profile gets this too) SELECT system_object_name, object_type, object_authority FROM qsys2.object_privileges WHERE system_object_schema = '<APPLIB>' AND authorization_name = '*PUBLIC' AND object_authority <> '*EXCLUDE' ORDER BY 1;
A good result
Watch for
AND system_object_schema = '<APPLIB>'.QSYS2.AUTHORIZATION_LIST_USER_INFO shows the lists.In the server: tool definitions · On IBM i: Db2 authority
The check. In the IBM i MCP Server, each tool is an SQL statement written in YAML, with its parameters bound rather than pasted into the SQL. Mark each tool read-only, expose only the toolsets the agent needs, and leave the built-in execute_sql tool off. It is off by default (IBMI_ENABLE_EXECUTE_SQL=false), and read-only by default when it is on (IBMI_EXECUTE_SQL_READONLY=true).
# One tool: a fixed statement, a bound parameter, a row limit, read-only
tools:
open_orders_for_customer:
source: ibmi-system
description: "Open orders for one customer"
parameters:
- name: customer_id
type: string
pattern: "^[0-9]{1,9}$"
statement: |
SELECT order_id, order_date, status, total
FROM <APPLIB>.open_orders_v
WHERE customer_id = :customer_id
FETCH FIRST 100 ROWS ONLY
security:
readOnly: trueThen prove the floor holds on IBM i. On a test system, as the server's profile, try one change against something it can read. This is the one statement on the page that tries to change something, and it should fail. If you can't sign on as that profile, switch your session to it first (you need *USE to the profile), and reconnect afterwards.
-- Test system only. Expected: SQLSTATE 42501, SQL0551 (not authorized) SET SESSION AUTHORIZATION = '<MCP_PROFILE>'; UPDATE <APPLIB>.open_orders_v SET status = status WHERE 1 = 0;
A good result
readOnly: true, and the toolsets loaded are the ones the agent's job needs.How it gets in · what is kept
On IBM i: Mapepire rules · database server exit points · TLS
The check. Mapepire keeps its own connection rules in /QOpenSys/etc/mapepire/iprules.conf, one allow or deny line per user and address, and the last rule that matches wins. Start with a line that denies everyone, then allow the server's profile from the server's address. Mapepire also uses the database server's exit points, like any JDBC client, but every Mapepire connection looks local to an exit program, so rules there work by user, not by address.
# /QOpenSys/etc/mapepire/iprules.conf: deny everyone first, then allow one profile from one host deny *@* allow <MCP_PROFILE>@<AGENT_HOST>
-- Mapepire's rules as they stand. No rows means no rules: Mapepire then accepts any profile from any address. SELECT line_number, line FROM TABLE(qsys2.ifs_read(path_name => '/QOpenSys/etc/mapepire/iprules.conf')) ORDER BY line_number;
-- Database server exit points, with how many exit programs each has (0 = nothing in front of that door)
SELECT p.exit_point_name, p.exit_point_format, COUNT(g.exit_program) AS exit_programs
FROM qsys2.exit_point_info p
LEFT JOIN qsys2.exit_program_info g
ON g.exit_point_name = p.exit_point_name AND g.exit_point_format = p.exit_point_format
WHERE p.exit_point_name LIKE 'QIBM_QZDA%'
GROUP BY p.exit_point_name, p.exit_point_format
ORDER BY p.exit_point_name;-- Is Mapepire using a certificate you put there? No rows means it is using its own self-signed one.
SELECT path_name, data_change_timestamp
FROM TABLE(qsys2.ifs_object_statistics(start_path_name => '/QOpenSys/etc/mapepire/cert',
subtree_directories => 'NO'))
WHERE path_name LIKE '%server.jks';A good result
deny *@* and allows the server's profile from one address. No rows is a fail, not a clean result, and so is a missing file./QOpenSys/etc/mapepire/cert/server.jks, or a Let's Encrypt certificate for the host), and the server checks it: DB2i_IGNORE_UNAUTHORIZED=false. That setting defaults to true so that self-signed certificates work while you try things out.Watch for
CLIENT_WRKSTNNAME special register.In the server: transport · authentication · logs · secrets
The check. On one person's machine, the server can run over stdio for that person's tools. Once it runs over HTTP for agents, it is a network service in front of your database, and it needs the controls a network service needs. No SQL here: read the server's settings.
MCP_HTTP_HOST, MCP_HTTP_PORT). If you change the address, say who can reach it.MCP_AUTH_MODE defaults to none. The other modes are jwt, oauth and ibmi. The IBM i mode also needs IBMI_HTTP_AUTH_ENABLED=true; keep IBMI_AUTH_ALLOW_HTTP=false so sign-ins only travel over HTTPS.debug (MCP_LOG_LEVEL), written to LOGS_DIR. Decide what level you keep, where the logs go and who reads them, since they can carry the SQL that ran.DB2i_PASS belongs in your secrets store, not in a file in source control.A good result
On IBM i: Audit journal (QAUDJRN) · object auditing
The check. Confirm security auditing is on. Then turn on object auditing for the views the server reads (CHGOBJAUD, OBJAUD(*ALL)), so each read is recorded against the profile, and look for authority failures by that profile.
-- Auditing switched on, and what it records
SELECT system_value_name, current_character_value
FROM qsys2.system_value_info
WHERE system_value_name IN ('QAUDCTL', 'QAUDLVL', 'QAUDLVL2');-- Authority failures by the server's profile in the last 7 days SELECT entry_timestamp, user_name, violation_type, object_library, object_name, object_type FROM TABLE(systools.audit_journal_af(starting_timestamp => CURRENT TIMESTAMP - 7 DAYS)) WHERE user_name = '<MCP_PROFILE>' ORDER BY entry_timestamp DESC;
A good result
QAUDCTL includes *AUDLVL and *OBJAUD; QAUDLVL includes at least *AUTFAIL and *SECURITY.Watch for
On IBM i: the profile's text · Off IBM i: your agent register
The check. Name one person who answers for the server: what its tools return, who may call it, and when its profile is disabled. Put that name in the profile's text (control I shows it) and in the register of agents your shop keeps, with the toolsets the server exposes and the level it runs at.
A good result
The seven controls decide what the server can do. OneLens4i shows what it did. It is the governance view for AI agents on IBM i, and it follows each request from the agent on Linux to the job and the record on IBM i, as it happens.
On our own IBM i it runs today on test traffic. OneLens4i comes with a pilot at no additional cost. See OneLens4i →
The server can do what the profile it signs on with can do. Start on a test system with a profile of its own, read access to chosen views only, read-only tools, Mapepire rules limited to that profile and host, and auditing on. Promote it when those checks pass.
It is a check inside the server. The control IBM i enforces is the profile's authority: *USE on the views it needs and nothing on the tables. Have both, and test that a change fails.
Yes. Mapepire uses the database server's exit points like any JDBC client, but every connection looks local, so exit program rules work by user, not by address. Mapepire's own rules file limits which user may connect from which address.
IBM's IBM i MCP Server offers ready-made SQL toolsets and reaches Db2 for i through Mapepire. The community Db2 for i MCP Server is read-only and uses the JT400 JDBC driver. The controls on this page apply to either.
The order matters more than the server you pick. Profile, views and read-only first; Mapepire and the server's own door next; the record and the owner before the first agent calls. Then connect it.
For the rest of the system around the server, Eight checks before an agent touches your IBM i covers exit points, profiles, journaling and change control. Governance & security covers the four gates and the governed crossing. The Built In thread MCP on Db2 for i follows the servers as they change.
The IBM i MCP Server and Mapepire are IBM open-source projects; the Db2 for i MCP Server is a community project. Settings and defaults are as documented by each project in December 2026; check your version. Pegasus4i is an IBM Business Partner.