Skip to main content
The IBM i MCP Server is configured through environment variables that control transport, authentication, logging, and IBM i connection settings. This guide covers all configuration options with examples and best practices.
Always use a .env file for local development and secure environment variable management in production. Never commit sensitive credentials to version control.

Loading Your Configuration

The server loads one .env file at startup: the file named by the MCP_SERVER_CONFIG environment variable, otherwise .env in the directory the server is started from. Parent directories are not searched.
A relative MCP_SERVER_CONFIG resolves from the working directory. If the file does not exist, the server prints a warning and falls back to .env in the working directory.
Precedence: variables already set in the process environment win over the file. CLI arguments (like --transport http) override both.

Minimal Working Configuration

Start here if you’re setting up for the first time. This minimal configuration is sufficient to get the server running:
What’s next? This minimal config gets you started. Add authentication, observability, and SQL tools configuration as your needs grow.

Quick Setup

Create your configuration file from the template:
Then edit .env with your IBM i connection details using the minimal configuration above.
For a step-by-step walkthrough, see the Quick Start Guide. For production deployment, refer to the Production Deployment guide.

Core Server Configuration

Below is the reference for core server configuration options. Each section includes detailed explanations, examples, and guidance on when to use specific settings.

Server Transport

How clients connect to your MCP server. The transport type determines whether clients connect via standard input/output (stdio) for local processes or HTTP for remote/web-based connections. Most production deployments use HTTP transport for flexibility and multi-client support.

TLS Listener

By default the server listens on plain HTTP. With MCP_TLS_CERT_FILE and MCP_TLS_KEY_FILE both set, it listens with HTTPS on the same port and needs no TLS-terminating proxy. This works in every auth mode.
  • Setting only one of the two stops startup, as does a file that cannot be read or that does not hold a certificate and its key.
  • The files are read once at startup. Restart the server after renewing the certificate.
  • A plain-HTTP request to a TLS listener gets no answer. Health checks must use https; the container image’s built-in health check does not (see Docker).
  • The built-in IBM i sign-on requires the TLS listener unless MCP_HTTP_HOST is a loopback address.

Behind a Reverse Proxy

By default the server ignores X-Forwarded-For and X-Forwarded-Proto: any caller can write those headers. The client address is the TCP peer. Behind a reverse proxy or ingress, set MCP_TRUSTED_PROXIES to the proxy’s address, as a comma-separated list of IP addresses and CIDR ranges:
The headers are believed only when the TCP peer is inside that list. The server then takes:
  • the client address from X-Forwarded-For: the right-most entry that is not itself inside the list. Entries further left are whatever the caller sent and are not read. With several proxies in a row, list all of them, or every client appears at the address of the proxy before the last. An entry that is not a plain IP address (one with a port, for example) cannot be used, and the proxy’s own address is taken instead. X-Real-IP is not read.
  • the scheme from X-Forwarded-Proto. It is used by the HTTPS check on /api/v1/auth (deprecated IBM i authentication). For a request from a listed proxy only this header counts, also when the proxy’s own connection to the server uses TLS (MCP_TLS_CERT_FILE): the client may have reached the proxy in clear.
The client address is used for rate limiting, in logs, and by the built-in IBM i sign-on to decide who may reach the sign-in page. Without the setting, every client behind the proxy shares the proxy’s address and with it one per-address rate-limit budget, and /api/v1/auth refuses every request with HTTPS/TLS is required for authentication endpoints.
Configure the proxy to set X-Forwarded-For itself: overwrite it with the client address, or append the client address to it. A proxy that passes the header through unchanged lets a client choose its own address. Do not list an address in MCP_TRUSTED_PROXIES that clients can connect from directly.A malformed entry in MCP_TRUSTED_PROXIES stops startup.
The built-in IBM i sign-on is stricter: its sign-in page and token endpoint refuse a request that carries X-Forwarded-For, Forwarded or X-Real-IP without coming from a listed proxy, and a request from a listed proxy without a usable X-Forwarded-For entry.

Protocol Versions and Sessions

The server is stateless. One endpoint serves MCP protocol revision 2026-07-28 and clients on earlier revisions, over both HTTP and stdio. It issues no Mcp-Session-Id and keeps no per-client state between requests, so there is nothing to configure. The MCP endpoint accepts POST only; GET and DELETE return 405.

Rate Limiting (HTTP Only)

Control request rate limiting for the HTTP transport. Rate limiting prevents abuse and manages server load. For agentic AI workflows that make many parallel tool calls (e.g., Agno AgentOS), you can increase the limit or disable rate limiting entirely.
Use for: Standard deployments with moderate request volumes
What is counted:
  • No authentication: every request counts against the client address.
  • With authentication (oauth or ibmi): an authenticated request counts against the token’s subject (the client id when the token has no subject), so users behind one address do not share a budget. A request that authentication refuses (401/403) counts against the client address, as do fetches of the OAuth metadata and, with the built-in IBM i sign-on, requests to its sign-in page, token endpoint and client registration. Once an address has used up its budget, further requests from it that authentication refuses get 429 until the window ends. Requests with a valid token are still served: they never count against the address.
  • POST /api/v1/auth (deprecated IBM i authentication) has its own fixed budget of 10 requests per minute per client address. It follows MCP_RATE_LIMIT_ENABLED and MCP_RATE_LIMIT_SKIP_DEV.
The limiter tracks at most 10,000 keys; the oldest window is dropped first.
Client address: the TCP peer address. Behind a reverse proxy that is the proxy, so all clients share one budget; set MCP_TRUSTED_PROXIES to the proxy’s address to use the address the proxy reports. See Behind a Reverse Proxy.

Connection Pool Timeouts

These two settings do not apply to the built-in IBM i sign-on, which has no connection pools: each signed-on user has one connection, closed after OAUTH_IDLE_CLOSE_MINUTES, and a statement is abandoned after a fixed 120 seconds.
Control automatic cleanup of idle database connections and query timeouts. In cloud deployments (Railway, Heroku, etc.), reverse proxies silently kill idle TCP connections. The Mapepire connection pool may still report as initialized, but queries sent over a dead WebSocket will hang indefinitely. These settings prevent that by proactively closing idle pools and aborting stale queries.
Use for: Most deployments — 5-minute idle timeout and 30-second query timeout
How it works: The idle timer checks pools at an interval of max(10s, timeout/2). When a pool exceeds the idle timeout, it is closed automatically. The next query triggers a transparent re-initialization through the existing lazy-init path — no manual intervention needed. When a statement times out, the pool is marked unhealthy (/healthz reports degraded) and closed, and it is re-created on the next request. Other statements running on that pool fail at once with Request cancelled: connection pool '<id>' was closed while the statement was running. Such a statement had already been sent to IBM i and may or may not have completed, so check before running it again.With the SSH transport, a timed-out query closes the shared SSH session (it has a single SQL job, which may be stuck). In-flight queries on it fail, and the next request re-creates the session.
Connection failures:
  • Lost connections. When a pool has no usable connection left (IBM i IPL, Mapepire restart, network reset), the server re-initializes it once and runs the statement. If that fails the error is Connection to IBM i was lost and could not be re-established on pool '<id>'.
  • Rejected sign-on. After IBM i rejects the user or password, the server does not attempt another sign-on with those credentials for 60 seconds, so that repeated tool calls do not disable the user profile. Calls in that time fail with IBM i sign-on failed: the system rejected the user or password. .... Other initialization failures (host unreachable, for example) are retried after 5 seconds. Both intervals are fixed. Pools that use the same host, user and password sign on one at a time, so several of them starting together make one attempt, and a connection that a pool adds later under load is held back by the same intervals.
  • Pool start-up. A pool opens one connection first and the remaining starting connections only after it succeeds.
Setting MCP_POOL_QUERY_TIMEOUT_MS=0 disables query timeouts entirely. This means queries on dead connections will hang until the client’s own timeout fires. Only disable this in trusted, stable network environments.

Pagination

Controls the per-fetch page size and the safety ceiling used when SQL tools paginate large result sets. fetchAllRows: true tools and the built-in execute_sql tool share these values. YAML tools override per-call via rowsToFetch; these env vars govern the defaults.
Why these defaults: At 1000 rows/fetch, the server makes at most 30 round-trips before hitting the 30,000-row ceiling — around 3 seconds of tail latency on a healthy WebSocket link. The ceiling itself is the practical LLM-ingestion limit: 30k rows typically serialize to 3-6M tokens, already beyond most context windows. Operators running bulk CLI exports can raise IBMI_PAGINATION_MAX_ROWS; LLM-facing deployments rarely should.

Authentication Configuration

Authentication applies to the HTTP transport. The stdio transport does not authenticate.

Choosing an Authentication Mode

No authentication. All SQL runs with the configured DB2i_USER credentials.With IBM i credentials configured, an unauthenticated HTTP server only starts on a loopback bind (MCP_HTTP_HOST=127.0.0.1, the default) unless you set MCP_ALLOW_UNAUTHENTICATED_HTTP=true.
With OAUTH_ISSUER_URL unset the server is its own OAuth 2.1 authorization server. Users sign on at a page it serves with their IBM i user profile and password, and every tool runs SQL as that user. There is no service account, and DB2i_PASS must be unset.Setup: MCP_RESOURCE_URL, DB2i_HOST, TLS for the server, and a way to verify the Mapepire certificate. See Built-in IBM i Sign-On.
With OAUTH_ISSUER_URL set the server acts as an OAuth 2.1 resource server as defined by the MCP authorization specification. It verifies JWT access tokens issued by your authorization server (identity provider) and publishes the metadata clients need to find that server.A token identifies the caller only. All SQL runs as the DB2i_USER service account.Setup: MCP_RESOURCE_URL and OAUTH_ISSUER_URL. See External Authorization Server.
Each user exchanges IBM i credentials for a server-issued token and gets a connection pool under their own profile.This mode is deprecated and will be removed in a future major release; the built-in sign-on of oauth replaces it. See IBM i Authentication.

Authentication Mode Configuration

The server refuses to start when any environment variable fails validation (an unknown MCP_AUTH_MODE, a non-numeric port, and so on): stderr names the variables at fault and the process exits with code 1.
Use for: Local development, stdio

OAuth Settings

Used when MCP_AUTH_MODE=oauth. OAUTH_ISSUER_URL selects the flavour. External authorization server (OAUTH_ISSUER_URL set): Built-in IBM i sign-on (OAUTH_ISSUER_URL unset). OAUTH_JWKS_URI and OAUTH_AUDIENCE stop startup in this flavour; OAUTH_REQUIRED_SCOPES has no effect. The built-in sign-on also needs DB2i_HOST, refuses DB2i_PASS and DB2i_SSH_KEY, limits DB2i_JDBC_OPTIONS to a short list of keys, and needs the TLS listener unless MCP_HTTP_HOST is a loopback address. With a loopback MCP_HTTP_HOST and a public MCP_RESOURCE_URL, MCP_TRUSTED_PROXIES must hold a loopback entry (127.0.0.0/8 or ::1) for the proxy on the same host, whether or not the server has a TLS listener. It works with mapepire-server 2.x and requires no particular version.

OAuth Authentication Guide →

Both flavours in full: how the built-in sign-on works and what it stores, setup, the sign-on budget, IBM i setup, limitations, and the external authorization server.

IBM i Authentication Settings

Deprecated. IBM i HTTP token authentication will be removed in a future major release. It still works; the server logs one deprecation warning at startup. Use OAuth for new deployments: its built-in IBM i sign-on also runs SQL under each user’s own profile.

IBM i Authentication Guide →

Complete setup guide: For detailed instructions on IBM i HTTP authentication including RSA key generation, token management, security best practices, and troubleshooting, see the IBM i Authentication page.

Setting Up RSA Encryption Keys

The deprecated IBM i authentication mode requires RSA keypairs to protect credentials during transmission. The authentication flow uses RSA and AES encryption to securely exchange IBM i credentials between clients and the server.
1

Create Secrets Directory

Create a dedicated directory for storing encryption keys:
Store the secrets/ directory outside of version control. Add it to your .gitignore file.
2

Generate RSA Private Key

Generate a 2048-bit RSA private key:
What this does:
  • Creates a new RSA private key with 2048-bit encryption strength
  • Saves it to secrets/private.pem
  • This key will be used by the server to decrypt credentials sent by clients
3

Extract Public Key

Extract the corresponding public key from the private key:
What this does:
  • Derives the public key from your private key
  • Saves it to secrets/public.pem
  • Clients use this public key to encrypt credentials before sending them to the server
4

Set Secure File Permissions

Restrict access to your private key:
Critical Security Step: The private key (private.pem) must be protected. Anyone with access to this file can decrypt client credentials.
5

Configure Environment Variables

Add the keypair paths to your .env file:
Key Configuration:
  • IBMI_AUTH_KEY_ID: Identifier for this keypair (used for key rotation)
  • IBMI_AUTH_PRIVATE_KEY_PATH: Path to your private key file
  • IBMI_AUTH_PUBLIC_KEY_PATH: Path to your public key file
How the Encryption Works:
  1. Client requests public key from server (/api/v1/auth/public-key)
  2. Client generates a random AES-256-GCM session key
  3. Client encrypts IBM i credentials with the session key
  4. Client encrypts the session key with the server’s RSA public key
  5. Server decrypts the session key using its RSA private key
  6. Server decrypts the credentials using the session key
  7. Server authenticates against IBM i and issues an access token
Key Rotation: To rotate keys, generate a new keypair, point the key paths at it, set a different IBMI_AUTH_KEY_ID, and restart the server. The server loads a single active keypair, so clients must fetch the new public key after rotation.
Security Best Practices:
  • Always use HTTPS: Set IBMI_AUTH_ALLOW_HTTP=false
  • Rotate keys regularly: Generate new keypairs every 90-180 days
  • Use strong key sizes: 2048-bit minimum, 4096-bit recommended for high-security environments
  • Monitor key access: Enable file auditing on the secrets/ directory
  • Backup keys securely: Store encrypted backups in a secrets management system
  • Private key: chmod 600 secrets/private.pem (owner read/write only)
  • Public key: chmod 644 secrets/public.pem (world-readable is safe)
  • Secrets directory: chmod 700 secrets/ (owner access only)
  • Owner: Ensure files are owned by the service account running the MCP server
  • Never commit keys: Add secrets/ to .gitignore
  • Never commit .env: Environment files often contain paths to secrets
  • Use environment-specific keys: Different keypairs for dev/staging/production
  • Document setup process: Include key generation in deployment documentation
For production environments, consider using a secrets management system:
  • AWS Secrets Manager: Store keys in encrypted AWS vault
  • HashiCorp Vault: Centralized secrets management with audit logs
  • Azure Key Vault: Microsoft’s cloud-based secrets storage
  • Kubernetes Secrets: For containerized deployments
Update IBMI_AUTH_PRIVATE_KEY_PATH to reference the mounted secret location.

IBM i Database Connection

Connect to IBM i DB2 for i databases via Mapepire. These settings configure the connection to your IBM i system through the Mapepire database server. The server uses these credentials to execute SQL tools and access DB2 for i data. All connections are pooled. SQL runs with these credentials unless users sign on with their own IBM i profile (the built-in IBM i sign-on of MCP_AUTH_MODE=oauth, or the deprecated IBM i authentication mode).

Connection Settings

Security Alert: DB2i_IGNORE_UNAUTHORIZED=true disables TLS certificate verification, making connections vulnerable to man-in-the-middle attacks.Use this setting:
  • ✅ Development with self-signed Mapepire certificates
  • ❌ Production environments (use proper TLS certificates)
With the built-in IBM i sign-on only DB2i_HOST, DB2i_PORT and DB2i_JDBC_OPTIONS are used. DB2i_PASS and DB2i_SSH_KEY stop startup and DB2i_USER is ignored. The Mapepire certificate is verified against DB2i_SERVER_CERT_FILE, DB2i_CA_FILE or Node.js’s trust store, unless DB2i_IGNORE_UNAUTHORIZED=true is set explicitly: users’ passwords are then sent to a server whose identity is not checked, and a warning is logged at startup. The default of true in the table above does not apply to this mode, and DB2i_IGNORE_UNAUTHORIZED=true together with either certificate file stops startup (see OAuth Settings). DB2i_HOST must be a host name or an IPv4 address. DB2i_JDBC_OPTIONS may hold only naming, libraries, date format, date separator, time format, time separator, decimal separator, transaction isolation and access; the server adds prompt=false itself.
IBM i Requirements:
  • User profile must have appropriate database authorities
  • Access to QSYS2 system services
  • Mapepire daemon must be running on the specified port (not needed with the SSH transport)

SSH Transport

Connect over SSH instead of the Mapepire daemon. The server opens an SSH session to the IBM i and starts mapepire-server on demand through an SSH exec channel (mapepire-js ssh-single transport). No Mapepire daemon or port 8076 is needed. A connection uses SSH when it has an SSH key. A password means the Mapepire daemon. There is no separate switch: Each YAML source connects to its own host as its own user, so one tools file can hold sources for several systems.
Set DB2i_SSH_KEY. Existing tools files need no change.
The YAML source fields ssh-key and ssh-host-key-sha256 are described in the Sources Reference.
SSH uses key authentication only. No password is ever sent over SSH. On an SSH connection DB2i_PASS and a source’s password are not used. This also means a password is never sent to a host whose key was not verified.With DB2i_SSH_KEY set you can delete the DB2i_PASS line from .env: a tools file that says password: ${DB2i_PASS} still loads. Do not leave the line blank (DB2i_PASS=), because a blank value is rejected at startup.
SSH key setup
  • The private key stays on the machine that runs the MCP server. The public key (.pub) goes on the IBM i, in the ~/.ssh/authorized_keys of the user profile that connects:
  • On the IBM i, ~/.ssh must be 700, authorized_keys must be 600, and the home directory must not be group- or world-writable, otherwise sshd silently ignores the key.
  • Check it before starting the server: ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes -o BatchMode=yes MYUSER@my-ibmi.company.com "echo OK" must print OK without a password prompt.
  • Supported key formats: OpenSSH-format Ed25519, RSA (2048 bit or more) and ECDSA keys, and RSA in PEM (BEGIN RSA PRIVATE KEY). Passphrase-protected keys work with DB2i_SSH_PASSPHRASE.
  • Not supported: ECDSA in PEM (BEGIN EC PRIVATE KEY) and PKCS#8 (BEGIN PRIVATE KEY). Generate a new key with ssh-keygen -t ed25519.
  • Whether the IBM i accepts a given key type depends on its sshd configuration.
  • If authentication fails the server logs All configured authentication methods failed. There is no password fallback, so fix the key.
  • The server refuses to start when DB2i_SSH_KEY points to a file it cannot read. A YAML source whose ssh-key cannot be read fails to load with the source name in the error.
Host key verification
  • Get the fingerprint from a trusted channel: ssh-keyscan -t ed25519 my-ibmi.company.com | ssh-keygen -lf - (use the key type the IBM i offers).
  • For one system, set DB2i_SSH_HOST_KEY_SHA256=SHA256:.... For several systems, set ssh-host-key-sha256 on each YAML source, because each host has its own key. A source without its own value is checked against DB2i_SSH_HOST_KEY_SHA256.
  • With a fingerprint set, a different host key is refused and the log says IBM i SSH host key does not match the configured fingerprint.
  • Without it any host key is accepted and a warning is logged each time a session is opened.
How the shared session behaves
  • Connections to the same system share ONE SSH session and ONE SQL job (per host, user, key, technique and JDBC options). The built-in tools and the YAML sources that point to the same system as the same user share it; each other system gets its own session.
  • The first query on a system takes about 10 seconds (SSH connect plus JVM start); later queries reuse the job and are fast.
  • Queries on one system run on that single job, so parallel tool calls are served one after another.
  • If the SSH session drops, the next request re-creates it (one cold start).
  • See Connection Pool Timeouts for what happens when a query times out.
Limits
  • Set a host key fingerprint (see Host key verification). Without it the server accepts any host key.
  • The SSH port, key passphrase and technique are set in the environment only and apply to every SSH connection. Only the key and the host key fingerprint can be set per source.
  • With DB2i_SSH_KEY set, a YAML source cannot opt out of SSH. To mix SSH and Mapepire sources, use ssh-key on the sources instead.
  • SSH is not used with the built-in IBM i sign-on (MCP_AUTH_MODE=oauth without OAUTH_ISSUER_URL). In that mode every statement runs on the Mapepire connection of the user who signed on. The server refuses to start when DB2i_SSH_KEY is set, and ssh-key on a YAML source is not used.
  • Requests that carry an IBM i bearer token (IBMI_HTTP_AUTH_ENABLED=true) still use the WebSocket transport.
  • The ibmi CLI has its own SSH setting per system (sshKey in ~/.ibmi/config.yaml) and keeps an SSH session open between commands. See CLI SSH Connections.
  • Heavy queries such as QSYS2.SYSTEM_STATUS(DETAILED_INFO=>'ALL') can take 25s or more on a cold, small partition. Raise MCP_POOL_QUERY_TIMEOUT_MS if you see timeouts.

DB2i_JDBC_OPTIONS Env Var

Forward any mapepire JDBC option to the underlying driver via a single environment variable. The DB2i_JDBC_OPTIONS env var accepts a semicolon-separated list of key=value pairs modeled on DB2 JDBC URL syntax — letting you set library list, naming convention, date format, and any other JDBC property without editing YAML.

Format Rules

Use for: Resolving unqualified object names. Comma-split within the single libraries= pair.

Precedence and YAML Interaction

DB2i_JDBC_OPTIONS is shallow-merged over the jdbc-options field in each YAML source. Env values win on per-key collisions; YAML-only keys are preserved.
Why env overrides YAML: Operators can enforce a fleet-wide JDBC configuration (for example, forcing naming=system or a standard library list across all environments) without editing per-deployment YAML files.
Example merge:

Security: Log Redaction

The server logs only the libraries field at pool initialization. Other JDBC fields — including potentially sensitive values like key ring password, proxy server, and trace — are intentionally excluded from every log level to prevent credential leakage.
If you need to verify that a non-libraries option took effect, inspect driver behavior directly (for example, run SELECT CHAR(CURRENT_DATE) to confirm date format) rather than searching the logs.
See the YAML Sources Reference → JDBC Options for per-source configuration in YAML.

SQL Tools Configuration

Load and manage YAML-defined SQL tools. These settings control how the server discovers, loads, and reloads SQL tool definitions from YAML configuration files. You can load tools from individual files, entire directories, or use glob patterns to organize tools into logical groups (toolsets) for different use cases.
Path Requirements:
  • TOOLS_YAML_PATH in .env files should use absolute paths to avoid issues when the server is started from different directories
  • For relative paths, use the --tools CLI argument instead: npx -y @ibm/ibmi-mcp-server@latest --tools ./tools
  • CLI arguments override environment variables, so --tools always takes precedence over TOOLS_YAML_PATH
For detailed information on creating SQL tools, see the SQL Tools Overview and Building SQL Tools guides.

YAML Tool Settings

Single File:
Directory (loads all .yaml files):
Specific Toolsets:
Glob Pattern:
Loading rules:
  • Files are merged in sorted path order. With YAML_ALLOW_DUPLICATE_TOOLS=true or YAML_ALLOW_DUPLICATE_SOURCES=true, the last file wins.
  • Loading is all-or-nothing. A file that fails to parse or validate stops startup with Invalid tool configuration in <file>: <problems>. On auto-reload the error is logged and the previous tools stay in place.
  • A path that does not exist is treated as a glob pattern when it contains *, ?, [, ], { or }. Quote patterns on the command line: --tools 'tools/**/*.yaml'.
  • A YAML tool that has the name of an enabled built-in tool stops startup. Rename the YAML tool or leave the built-in tool off.
  • With the built-in IBM i sign-on every tool runs on the signed-on user’s connection. A source’s user and password are ignored, its host must be DB2i_HOST, and a source that sets jdbc-options stops startup.
See Sources and Tools for what a tool file may contain.

Built-in Tools

Control access to compiled SQL tools. The server includes built-in tools for schema discovery, query validation, and SQL execution. All are disabled by default (except describe_sql_object) and must be explicitly enabled via CLI flags or environment variables.
Use --builtin-tools --execute-sql together for the full text-to-SQL workflow. Use --builtin-tools alone to let agents discover schema while routing queries through curated YAML tools. See the Built-in Tools Reference for complete parameter and response documentation.

Configuration Variables

Security: execute_sql allows clients to run ad-hoc SQL queries. By default (IBMI_EXECUTE_SQL_READONLY=true), only SELECT queries are allowed. Set IBMI_EXECUTE_SQL_READONLY=false to enable write operations (INSERT, UPDATE, DELETE). Enable only in development or trusted environments. Production deployments should use YAML-defined tools for controlled query access.
Use for: Development with full text-to-SQL capability
Tool Capabilities:
Five read-only tools that query IBM i system catalog views:
  • list_schemas: Browse available schemas via QSYS2.SYSSCHEMAS
  • list_tables_in_schema: Find tables, views, physical files via QSYS2.SYSTABLES
  • get_table_columns: Inspect column metadata via QSYS2.SYSCOLUMNS2
  • get_related_objects: Dependency analysis via SYSTOOLS.RELATED_OBJECTS
  • validate_query: Multi-step SQL validation via QSYS2.PARSE_STATEMENT
All are safe, read-only catalog queries with zero risk to data.
Generates SQL DDL for IBM i database objects using QSYS2.GENERATE_SQL:
  • Input: Object name, library, type (TABLE, VIEW, INDEX, etc.)
  • Output: Complete DDL with constraints, indexes, and properties
  • Security: Read-only, describes objects without modification
  • Use case: Schema discovery, documentation, AI context
Executes ad-hoc SQL queries with multi-layered security controls:
  • Readonly by default: Only SELECT/QUERY statements allowed when IBMI_EXECUTE_SQL_READONLY=true (default)
  • Write operations opt-in: Set IBMI_EXECUTE_SQL_READONLY=false to enable INSERT, UPDATE, DELETE, etc.
  • PARSE_STATEMENT validation: Uses IBM i’s native SQL parser (QSYS2.PARSE_STATEMENT) for authoritative statement type detection
  • AST/Regex validation: Fast pattern matching to catch dangerous SQL keywords
  • Fail-closed security: All validation failures result in query rejection
  • Query length limit: Maximum 10,000 characters per query
  • Use case: Development exploration, debugging queries, ad-hoc data analysis
Built-in vs YAML Tools:
  • Built-in tools: Compiled TypeScript, controlled by feature flags, runtime validation with PARSE_STATEMENT
  • YAML tools: User-defined, curated queries with parameters, explicit query control
  • Security: Built-in tools use IBM i’s SQL parser for defense-in-depth; YAML tools use explicit query whitelisting
  • Recommendation: Use YAML tools in production for explicit query control and parameterization
See SQL Tools Overview for creating YAML tools.

Observability & Monitoring

Track server performance, debug issues, and monitor operations. Observability features help you understand server behavior through logging, distributed tracing (OpenTelemetry), and performance metrics. These settings are crucial for production deployments and troubleshooting.

Server Settings

Basic server identification and environment configuration. These variables set the server’s identity in logs and telemetry data, control the runtime environment, and determine where log files are stored.

Logging Configuration

Control log output, verbosity, and file storage. The server uses Pino for structured logging with automatic log rotation and support for both console and file outputs. Logs help you debug issues, track server behavior, and comply with audit requirements.

Log Settings

Log Levels Explained:
  • debug: Detailed diagnostic information (verbose)
  • info: General informational messages (recommended)
  • notice: Significant events worth noting
  • warning: Warning conditions that should be addressed
  • error: Error conditions that need attention
  • crit, alert, emerg: Critical system failures

Log Directory Configuration

Where logs are stored depends on how you specify the path:
Default location: ~/.ibmi-mcp-server/logs/Use for: Production with npx, user-specific installationsBenefits:
  • Works consistently with npx @ibm/ibmi-mcp-server
  • Persists across package updates
  • Doesn’t require write permissions to npm cache
  • Follows OS conventions for user data
Path Resolution:
  • Absolute paths (/var/log/...) are used as-is
  • Relative paths (./logs) resolve from current working directory, not package location
  • Tilde paths (~/logs) expand to your home directory
  • When using npx, relative paths resolve from where you run the command
An unusable LOGS_DIR does not stop the server. If the directory cannot be created or written to (a read-only container file system, for example), the server prints one line on stderr, Warning: cannot write logs to LOGS_DIR '<path>' (<reason>). File logging is disabled; ..., and logs to stderr instead: at the configured level with the HTTP transport, at warn and above with the stdio transport.

Log Files Created

The server writes two log files with automatic rotation: Rotation behavior:
  • Logs rotate when they reach 10MB OR at midnight daily (whichever comes first)
  • Files are numbered sequentially: combined.1.log, combined.2.log, etc. The highest number is the file currently being written (there is no un-numbered file)
  • Current file + 5 previous files are kept (6 total files per log file), including files left by earlier runs of the server: at each rotation the oldest files beyond that are deleted
  • Daily rotation re-uses the existing file if still within the same day
Versions up to 0.6.x named the files combined.log.N and could fill LOGS_DIR with millions of empty files on the day daylight saving time ends, which makes the server slow to start and to stop. If ~/.ibmi-mcp-server/logs holds files named *.log.N, stop every server that uses it and delete them.
Directory structure:
Sample log entry (JSON format):

Console Output & Colors

Console behavior depends on environment and transport mode:
In development with HTTP transport, console logs are colored and pretty-printed to stderr:
Output: Human-readable colored logs to stderrDisable colors: Set NO_COLOR=1 or FORCE_COLOR=0
With STDIO transport, there is no console log output; logs go to the log files only:
Output: Log files in LOGS_DIR only. If LOGS_DIR cannot be written to, records at warn and above go to stderr as JSON.Why: MCP protocol requires clean JSON-RPC on stdout with no ANSI codes
In production, logs are structured JSON regardless of transport:
Output: JSON to stderr (HTTP transport only) and log files
NO_COLOR Support: The server respects the NO_COLOR environment variable standard. Set NO_COLOR=1 to disable all colored output, useful for CI/CD pipelines and log aggregation systems.

Filtering Logs

Logs append across server restarts (rather than creating timestamped files), so use the structured fields of each record to filter. Records written while a request is handled carry its requestId:
Example: Filter by Request ID
Log records do not carry OpenTelemetry trace or span ids.

OpenTelemetry

Enable tracing. With OTEL_ENABLED=true the server records one span per tool execution (tool_execution:<tool name>) and one span per outgoing fetch call (the OAuth issuer metadata and JWKS requests), and exports them to an OTLP endpoint such as Jaeger or a collector. Incoming HTTP requests are not traced. Without OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, each finished span is written to the server log as a Trace Span End record at info level.
Supported OTEL_LOG_LEVEL values: NONE, ERROR, WARN, INFO, DEBUG, VERBOSE, ALL

Environment-Specific Examples

For additional security considerations and IBM i authority requirements, see the OAuth Authentication and Production Deployment guides.