Official Schema: See the JSON Schema definition for the authoritative tool configuration specification.
Tool Structure
Every tool definition follows this structure:Required Fields
All SQL tools must include these fields:| Field | Type | Description |
|---|---|---|
tool_name | string (YAML key) | Unique identifier for the tool, used by AI agents to call it |
source | string | Name of the database connection source (from sources section) |
description | string | Clear explanation of what the tool does, for AI agent consumption |
statement | string | SQL query to execute when the tool is called |
Field Details
- tool_name
- source
- description
- statement
Unique identifier for the toolThe tool name is the YAML key and must be unique across all tools.Naming conventions:
- Use lowercase with underscores:
get_active_jobs - Be descriptive:
find_employees_by_departmentnotemp_search - Prefix by domain if needed:
perf_system_status,sec_audit_trail
Parameters
Parameters define dynamic inputs for SQL tools. Each parameter specifies type, validation rules, and usage information.Complete Parameter Guide
See the full Parameter Guide for detailed examples of all parameter types, validation patterns, and best practices for building SQL tools with parameters.
Parameter Structure
Parameter Types
- String
- Integer
- Float
- Boolean
- Array
Text values with validationValidation options:
pattern- Regular expression for validationminLength- Minimum string lengthmaxLength- Maximum string lengthenum- Fixed list of allowed valuesdefault- Default value if not provided
Optional Parameters
Parameters withoutrequired: true or with default values are optional:
Security Configuration
Add security controls to tools for enhanced protection:Security Fields
| Field | Type | Default | Description |
|---|---|---|---|
readOnly | boolean | true | Restrict to read-only operations (SELECT queries) |
maxQueryLength | number | 10000 | Maximum SQL query length in characters |
forbiddenKeywords | array | [] | Additional forbidden SQL keywords beyond defaults |
- readOnly
- maxQueryLength
- forbiddenKeywords
Mark tools as read-only (SELECT queries only):Default:
Best Practice: Mark all tools that don’t modify data as
readOnly: true. This provides clear documentation and can be used for access control.true (for safety - tools are read-only by default)Response Formatting
Control how tool results are formatted for AI agents:responseFormat
Type:string
Options: json (default), markdown
- json - Structured data (default, best for AI processing)
- markdown - Formatted text with markdown syntax
Fetch-Row Controls
Control how many rows are fetched from the database per tool call. These are distinct frommaxDisplayRows, which only truncates the rendered markdown table.
Database vs. display limits:
rowsToFetch / fetchAllRows change how many rows the server pulls from Db2 for i. maxDisplayRows only affects how many rows appear in the formatted output. A tool can fetch 500 rows from the database but render only the first 100 in markdown.Fields
The two fields compose:fetchAllRows is the pagination policy; rowsToFetch, when set, is the per-fetch size in pagination mode, or a single-shot row cap when fetchAllRows is off.
| Field | Type | Default | Description |
|---|---|---|---|
rowsToFetch | integer (≥ 1) | 100 (mapepire default) | With fetchAllRows: true, the number of rows per fetchMore call. Without fetchAllRows, a single-shot cap applied to FETCH FIRST :limit ROWS ONLY-style queries. |
fetchAllRows | boolean | false | When true, paginate until the database reports is_done or the safety ceiling (IBMI_PAGINATION_MAX_ROWS, default 30000) is reached. |
Composition
| Config | Behavior |
|---|---|
rowsToFetch: N alone | Single-shot execute(N) — up to N rows, one round-trip |
fetchAllRows: true alone | Paginate with IBMI_PAGINATION_DEFAULT_PAGE_SIZE (default 1000) per fetch |
fetchAllRows: true, rowsToFetch: N | Paginate with N rows per fetch — tune per tool for wide rows |
IBMI_PAGINATION_MAX_ROWS, the server truncates the rows returned and emits a warning log. The CLI surfaces the truncation in the output footer so callers know the result was clipped.
- rowsToFetch (single-shot)
- fetchAllRows (paginate)
- Paginate with custom page size
- Default (neither)
Lift the 100-row cap for a single callUse when:
- Your
FETCH FIRST :limit ROWS ONLYclause needs more than 100 rows - You know the expected result size and want a predictable ceiling
- You want row-count safety without running paginated fetches
Setting
rowsToFetch alone does not automatically raise your SQL’s FETCH FIRST clause — you still need a parameter or literal that matches. rowsToFetch is the ceiling at the driver level.Metadata
Add descriptive metadata for tool organization and discovery:Metadata Fields
title
title
Human-readable title for the tool
version
version
Semantic version for tracking tool changes
author
author
keywords
keywords
Search keywords for tool discovery
lastUpdated
lastUpdated
Date of last modification (ISO format)
domain
domain
Business domain classification (monitoring, security, business, etc.)
category
category
Functional category within domain
environment
environment
Target environment (production, development, testing)
Complete Tool Examples
Simple Query (No Parameters)
String Parameter with Validation
Multiple Parameters with Different Types
Tool with Security Configuration
Array Parameter Tool
Best Practices
SQL Statement Design
SQL Statement Design
Optimization:
- Always include
FETCH FIRST n ROWS ONLYto limit results - Use
LEFT JOINinstead ofINNER JOINwhen relationships are optional - Add
ORDER BYfor consistent result ordering - Use column aliases for better AI understanding
Parameter Validation
Parameter Validation
Always validate:
- String patterns for IBM i names:
^[A-Z][A-Z0-9_]*$ - String lengths:
maxLength: 10for library names - Integer ranges:
minimum: 1, maximum: 1000 - Required vs optional: Mark appropriately
Description Quality
Description Quality
Write for AI agents:
- Be specific about what data is returned
- Mention any special authority requirements
- Include parameter examples in descriptions
- Note any result limits or performance considerations
Security Considerations
Security Considerations
Mark sensitive tools:
- Set
audit: truefor all tools accessing user data - Use
readOnly: truefor SELECT-only operations - Document required authorities in
security.requiredAuthority - Add warnings for potentially destructive operations
Next Steps
Sources Reference
Configure database connection sources
Toolsets Reference
Organize tools into logical groups
Building SQL Tools
Step-by-step guide with examples
Parameter Validation
Deep dive into validation rules
Tool Design Philosophy: Effective tools are discoverable (clear names and descriptions), safe (proper validation and security), and performant (optimized SQL with result limits). Write tools for AI agent consumption, not just human readability.