SQL Tool Parameters
SQL tools can accept parameters to make queries dynamic and reusable. All parameters are validated before execution and bound securely to prevent SQL injection. This guide covers all parameter types, constraints, and best practices.Parameters are defined in the
parameters array of a tool definition and referenced in SQL statements using the :parameter_name syntax.Parameter Types
The IBM i MCP Server supports five parameter types:| Type | Description | Use Cases | Constraints Available |
|---|---|---|---|
string | Text values | Library names, object names, patterns | minLength, maxLength, pattern, enum |
integer | Whole numbers | Row limits, IDs, counts | min, max, enum |
float | Decimal numbers | Thresholds, percentages, measurements | min, max, enum |
boolean | True/false values | Flags, enable/disable options | None (inherently constrained) |
array | List of values | Multiple filters, batch operations | minLength, maxLength, itemType (required) |
Parameter Structure
Each parameter requires a minimum ofname and type, with optional properties for validation and documentation:
Common Properties
| Property | Required | Type | Description |
|---|---|---|---|
name | ✅ Yes | string | Parameter name used in SQL (e.g., :library_name) |
type | ✅ Yes | string | One of: string, integer, float, boolean, array |
description | ⭐ Recommended | string | LLM-facing description—clear guidance on usage and examples |
required | No | boolean | true = must be provided, false = optional (default: true unless default is set) |
default | No | varies | Default value if parameter is not provided |
String Parameters
String parameters accept text values and support length constraints, pattern matching, and enumerated values.Available Constraints
minLength: Minimum string lengthmaxLength: Maximum string lengthpattern: Regular expression validationenum: List of allowed values
Example 1: Basic String Parameter
Example 2: String with Length Constraints
Example 3: String with Pattern Validation
Example 4: String with Enum Values
Fromobject-statistics-dev.yaml:
When
enum is provided, the description is automatically enhanced with “Must be one of: ‘ALIAS’, ‘FUNCTION’, …” for LLM clarity.Integer Parameters
Integer parameters accept whole numbers and support minimum/maximum constraints and enumerated values.Available Constraints
min: Minimum value (inclusive)max: Maximum value (inclusive)enum: List of allowed values
Example 1: Basic Integer Parameter
Example 2: Integer with Range Constraints
Fromobject-statistics-dev.yaml:
Example 3: Integer with Enum Values
Example 4: Pagination Parameters
Float Parameters
Float parameters accept decimal numbers and support minimum/maximum constraints.Available Constraints
min: Minimum value (inclusive)max: Maximum value (inclusive)enum: List of allowed values
Example 1: Basic Float Parameter
Example 2: Float for Decimal Precision
Example 3: Performance Multiplier
Fromemployee-info.yaml:
Boolean Parameters
Boolean parameters accepttrue or false values. They do not support additional constraints as they are inherently constrained to two values.
Example 1: Simple Boolean Flag
Example 2: Boolean with Clear Documentation
Example 3: Completed Project Filter
Fromemployee-info.yaml:
Boolean values are automatically converted to 1 (true) or 0 (false) in SQL queries.
Array Parameters
Array parameters accept lists of values and require anitemType to specify the type of elements. They are designed for SQL IN clauses and automatically expand to multiple placeholders.
Array Input Format
Available Constraints
itemType: Required - Type of array elements (string,integer,float, orboolean)minLength: Minimum number of itemsmaxLength: Maximum number of items
Example 1: String Array
Example 2: Integer Array with Constraints
Example 3: Project IDs
Fromemployee-info.yaml:
Using Arrays in SQL
Array parameters are automatically expanded to multiple placeholders for SQLIN clauses. Simply use the array parameter name directly in the IN clause:
- Input JSON:
{"project_ids": ["MA2100", "AD3100", "AD3110"]} - SQL with named parameter:
WHERE PROJNO IN (:project_ids) - Automatic expansion:
WHERE PROJNO IN (?, ?, ?)(one placeholder per array element) - Parameter binding: Each
?is bound to one array element:"MA2100","AD3100","AD3110" - DB2 execution: Standard prepared statement with bound parameters
- ✅ No SQL injection risk - Parameters are safely bound
- ✅ Variable-length arrays - Works with any array size (within constraints)
- ✅ Simple syntax - Just use
IN (:array_param)in your SQL - ✅ Type validation - Each array element is validated against
itemType - ✅ No Db2-specific workarounds needed - Works like standard JDBC parameter binding
SQL IN Clause Behavior: The If you need AND logic (matching ALL values), you’ll need different SQL patterns like subqueries or aggregation.
IN clause uses OR logic - it matches records where the column equals ANY value in the list, not ALL values.Parameter Constraint Summary
| Constraint | Type Support | Description | Example |
|---|---|---|---|
min | integer, float | Minimum value (inclusive) | min: 1 |
max | integer, float | Maximum value (inclusive) | max: 100 |
minLength | string, array | Minimum length/count | minLength: 1 |
maxLength | string, array | Maximum length/count | maxLength: 50 |
pattern | string | Regular expression validation | pattern: "^[A-Z][A-Z0-9]*$" |
enum | string, integer, float, boolean | Allowed values only | enum: [INDEX, TABLE, VIEW] |
itemType | array | Type of array elements (required) | itemType: string |
Best Practices
Parameter Descriptions
Thedescription field is sent directly to the LLM to help it understand how to use the parameter. Follow these guidelines:
✅ DO
✅ DO
- Provide clear, concise descriptions
- Include examples of valid values
- Explain the purpose and impact of the parameter
- Use IBM i terminology when applicable
- Indicate units for numeric values
❌ DON'T
❌ DON'T
- Use vague descriptions:
"A library" - Omit examples:
"Number of months" - Forget to document special values:
"Library name"(should mention*LIBL, etc.)
Using Parameters in SQL
Parameters are referenced in SQL statements using the:parameter_name syntax:
Example: Parameter Binding
Complete Examples
Example 1: Recently Used Objects
Fromobject-statistics-dev.yaml: