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

Before starting the server, set the MCP_SERVER_CONFIG environment variable to point to your configuration file:
The server loads the file specified by MCP_SERVER_CONFIG on startup.
How it works: The MCP_SERVER_CONFIG environment variable tells the server where to find your configuration file. Without it, you’d need to pass each variable individually as environment variables. CLI arguments (like --transport http) override values in the config file.

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.

Session Management (HTTP Only)

Control how HTTP connections maintain state. Session modes determine whether the server maintains persistent connections (stateful) or treats each request independently (stateless). The auto mode intelligently detects client capabilities and chooses the optimal strategy.
Session Modes:
  • auto: Automatically detects client capabilities (recommended)
  • stateful: Maintains persistent sessions with connection state
  • stateless: Each request is independent, no session state

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
Docker / Reverse Proxy: The server reads X-Forwarded-For and X-Real-IP headers for client identification. When these headers are absent (e.g., behind Docker without proxy header forwarding), the server falls back to the TCP socket’s remote address. Configure your reverse proxy to forward these headers for accurate per-client rate limiting.

Connection Pool Timeouts

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. The query timeout uses Promise.race() to abort queries on stale connections, marking the pool unhealthy so it is re-created on the next request.
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

Choosing an Authentication Mode

Which auth mode should you use? Select based on your deployment scenario:
No authentication, shared credentialsBenefits:
  • Quick setup for local development
  • Ideal for testing and prototyping
  • No additional configuration required
Limitations:
  • Never use in production environments
  • No per-user tracking or authorities
  • Security risk for networked deployments
Setup: Simply set MCP_AUTH_MODE=none in your .env file
Per-user IBM i authentication with RSA encryptionBenefits:
  • Each user connects with their own IBM i credentials
  • Respects individual IBM i object authorities
  • Full audit trail per user
  • Enterprise-grade security
Requirements:
  • RSA keypair generation (public/private keys)
  • IBM i HTTP authentication endpoints enabled
  • Per-user credential management
Setup: Requires IBMI_AUTH_PRIVATE_KEY_PATH, IBMI_AUTH_PUBLIC_KEY_PATH, and IBMI_HTTP_AUTH_ENABLED=true
External OAuth/OIDC authenticationBenefits:
  • Integrate with existing enterprise auth systems
  • Support for SSO (Single Sign-On)
  • Centralized identity management
  • Industry-standard OAuth 2.0 / OIDC protocols
Requirements:
  • OAuth provider configuration (issuer URL, audience)
  • Token validation infrastructure
  • External identity provider setup
Setup: Configure OAUTH_ISSUER_URL and OAUTH_AUDIENCE for your identity provider
JSON Web Token authenticationBenefits:
  • Custom authentication logic and workflows
  • Token-based stateless auth
  • Flexible integration with existing systems
  • Control over token generation and validation
Requirements:
  • You manage token generation and signing
  • Shared secret key (minimum 32 characters)
  • Custom token issuance logic
Setup: Set MCP_AUTH_SECRET_KEY with a secure secret (min 32 chars)

Authentication Mode Configuration

Use for: Development, internal networks, trusted environments

IBM i Authentication Settings

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

IBM i authentication 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 with a different IBMI_AUTH_KEY_ID. The server can support multiple keypairs simultaneously, allowing gradual migration without service interruption.
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 for efficiency and support both shared (development) and per-user (production) authentication modes.

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)
IBM i Requirements:
  • User profile must have appropriate database authorities
  • Access to QSYS2 system services
  • Mapepire daemon must be running on the specified port

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:

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, level-specific log files, 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

Log Files Created

The server creates 6 log files with automatic rotation: Rotation behavior:
  • Logs rotate when they reach 10MB OR at midnight daily (whichever comes first)
  • Rotated files are numbered sequentially: combined.log.1, combined.log.2, etc.
  • Current file + 5 historical versions are kept (6 total files per log level)
  • When the 7th file would be created, the oldest file is automatically deleted
  • Daily rotation re-uses the existing file if still within the same day
Directory structure:
Note: Once combined.log.6 would be created, combined.log.5 is deleted and files shift: .4.5, .3.4, etc.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, console logs are plain JSON to stderr (MCP spec requirement):
Output: Structured JSON to stderr (no colors, no pretty-printing)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 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.

Session Correlation with OpenTelemetry

How to correlate logs across server restarts: Since logs now append across server sessions (rather than creating timestamped files), use structured logging fields to filter by session:
Best practice: Enable OpenTelemetry for distributed tracing across restarts:
This adds traceId and spanId to every log entry, making it easy to:
  • Filter logs by specific server sessions
  • Correlate requests across services
  • Track performance over time
  • Debug issues with full request context

OpenTelemetry

Enable distributed tracing and metrics collection. OpenTelemetry (OTel) provides enterprise-grade observability by tracking every request through the system, measuring performance, and exporting telemetry data to monitoring platforms like Jaeger, Zipkin, or cloud providers. Essential for production monitoring and performance optimization.
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 Authentication and Production Deployment guides.