Skip to main content
The IBM i MCP Server includes 7 built-in tools compiled directly into the server. These tools provide a complete text-to-SQL workflow out of the box — from schema discovery to query execution — without any YAML configuration or --tools flag.
Built-in vs YAML tools: Built-in tools are TypeScript implementations compiled into the server binary. YAML tools are user-defined SQL queries loaded at runtime via --tools. Both types coexist and appear identically to AI agents.

Quick Start

Enable built-in tools with the --builtin-tools and --execute-sql flags:
  • --builtin-tools enables the 5 schema discovery tools (list_schemas, list_tables_in_schema, get_table_columns, get_related_objects, validate_query)
  • --execute-sql enables execute_sql for running queries
  • describe_sql_object is always available regardless of flags
Use --builtin-tools without --execute-sql to let agents explore the schema but route query execution through curated YAML tools with parameterized queries and security controls.

The built-in tools are designed to be chained in a progressive discovery pattern:
1

Discover schemas

Use list_schemas to find available libraries/schemas on the system.
2

Browse tables

Use list_tables_in_schema to list tables, views, and physical files within a schema.
3

Inspect columns

Use get_table_columns to understand a table’s structure before writing queries.
4

Check dependencies

Optionally use get_related_objects for impact analysis or describe_sql_object to view DDL.
5

Validate SQL

Use validate_query to check syntax and verify that referenced objects exist.
6

Execute query

Use execute_sql to run the validated query and retrieve results.

Tool Reference

list_schemas

List available schemas/libraries on the IBM i system. Use this as the first step in schema discovery to find which schemas contain relevant tables. Catalog view: QSYS2.SYSSCHEMAS

Parameters

Response columns

Pagination: The response includes hasMore: true when additional rows are available beyond the current page. Increment offset by limit to fetch the next page.

list_tables_in_schema

List tables, views, and physical files in a specific schema with metadata including row counts. Use after list_schemas to find tables before querying column details. Catalog views: QSYS2.SYSTABLES joined with QSYS2.SYSTABLESTAT

Parameters

Response columns


get_table_columns

Get column metadata for a table including names, data types, lengths, nullability, defaults, and descriptions. Use this to understand table structure before writing SQL queries. Catalog view: QSYS2.SYSCOLUMNS2

Parameters

Response columns

Null or undefined values are automatically stripped from each row to reduce response size. Only columns with values are included in the output.

Get all objects that depend on a database file — views, indexes, triggers, foreign keys, logical files, and more. Use for impact analysis before schema changes or to understand a table’s dependency graph. Catalog function: SYSTOOLS.RELATED_OBJECTS

Parameters

Valid object_type_filter values: ALIAS, FOREIGN KEY, FUNCTION, HISTORY TABLE, INDEX, KEYED LOGICAL FILE, LOGICAL FILE, MASK, MATERIALIZED QUERY TABLE, PERMISSION, PROCEDURE, TEXT INDEX, TRIGGER, VARIABLE, VIEW, XML SCHEMA

Response columns


validate_query

Validate SQL query syntax and verify that referenced tables, columns, functions, and procedures exist in the system catalog. This tool performs multi-step validation:
  1. Syntax check — Uses QSYS2.PARSE_STATEMENT to parse the SQL statement
  2. Table verification — Cross-references parsed table names against QSYS2.SYSTABLES
  3. Column verification — Checks columns against QSYS2.SYSCOLUMNS
  4. Routine verification — Verifies functions/procedures against QSYS2.SYSROUTINES

Parameters

Response structure

Confidence levels: Table validation is high-confidence — invalid tables will definitely cause query failures. Column and routine validation is advisory — CTE columns, UDTF outputs, and unqualified references may appear as false positives.

execute_sql

Execute a SQL query on the IBM i database and return the results. Use this after validating your query with validate_query.

Parameters

Response structure

Security

execute_sql applies two layers of validation before running any query:
  1. AST/regex validation via SqlSecurityValidator — checks read-only mode constraints and query length
  2. Native IBM i validation via QSYS2.PARSE_STATEMENT — confirms SQL_STATEMENT_TYPE = 'QUERY' when in read-only mode
By default, only SELECT queries are allowed (IBMI_EXECUTE_SQL_READONLY=true). Set IBMI_EXECUTE_SQL_READONLY=false to allow INSERT, UPDATE, DELETE, and other statement types.

describe_sql_object

Generate the SQL DDL statement for an IBM i database object. Use this to see the full CREATE definition of a table, view, index, procedure, function, or other object. Catalog procedure: QSYS2.GENERATE_SQL

Parameters

Valid object_type values: ALIAS, CONSTRAINT, FUNCTION, INDEX, MASK, PERMISSION, PROCEDURE, SCHEMA, SEQUENCE, TABLE, TRIGGER, TYPE, VARIABLE, VIEW, XSR

Response structure


Pagination

Tools that support pagination (list_schemas, list_tables_in_schema) use a consistent pattern: The response includes a hasMore boolean indicating whether additional pages exist. To paginate:
The server internally fetches limit + 1 rows to determine hasMore, then returns only limit rows. This avoids an extra count query.

Configuration

Built-in tools are controlled via CLI flags or environment variables. CLI flags take precedence over environment variables.

CLI Flags

Combine both flags for the complete text-to-SQL workflow. Each flag can also be used independently.

Environment Variables

describe_sql_object is always registered regardless of these flags. It generates DDL definitions and does not modify data.

Examples


Tool Annotations

All built-in tools include MCP tool annotations that help AI agents understand tool behavior: *execute_sql annotations change based on IBMI_EXECUTE_SQL_READONLY: when true (default), readOnlyHint=true and destructiveHint=false; when false, readOnlyHint=false and destructiveHint=true.

Next Steps

YAML Tools Overview

Build custom SQL tools with zero TypeScript using YAML configuration

Using Default YAML Tools

Load pre-built YAML tool collections for system admin, security, and performance

Quickstart

Get the server running with your first AI agent

Server Configuration

Complete environment variable and server configuration reference