SQL Tools Overview
The IBM i MCP Server’s SQL Tools system allows you to create powerful database operations using simple YAML configurations. This approach enables rapid development of IBM i-specific tools without requiring TypeScript programming skills.YAML SQL Tools vs. TypeScript Tools: While TypeScript tools offer maximum flexibility, YAML SQL tools provide a faster path to creating database operations with built-in security, parameter validation, and IBM i integration.
Why YAML SQL Tools?
For IBM i environments, most AI agent interactions involve querying database tables, views, and system services. YAML SQL tools are specifically designed for this use case:Rapid Development
Create new tools in minutes using familiar SQL statements and simple parameter definitions
Built-in Security
Automatic SQL injection protection, parameter validation, and authority checking
IBM i Integration
Native support for QSYS2 services, system catalogs, and IBM i SQL features
Zero Code Required
No TypeScript knowledge needed - everything is configured in YAML
YAML Tool Structure
Every YAML configuration file follows a consistent structure that defines sources, tools, and toolsets:Architecture Decision: The YAML approach separates data access configuration from application code, making it easier for IBM i professionals to create and maintain database tools while ensuring security and consistency.
Component Breakdown
Sources
Sources define database connections with environment variable support for secure credential management:- Basic Connection
- Multiple Environments
- Advanced Options
Tools
Tools are individual SQL operations that AI agents can execute. Each tool includes metadata, parameters, and the SQL statement:Tool Parameters
Parameters provide type-safe input validation and enable dynamic SQL execution:String Parameters
String Parameters
- Pattern validation with regex
- Length constraints
- Required/optional flags
- Default values
Integer Parameters
Integer Parameters
- Range validation (min/max)
- Default values
- Automatic type conversion
Enum Parameters
Enum Parameters
- Controlled value lists
- Default selection
- AI-friendly descriptions
Optional Parameters
Optional Parameters
- NULL handling in SQL
- Conditional filtering
- Optional validation
Toolsets
Toolsets organize related tools into logical groups that can be deployed together:Security Features
YAML SQL tools include comprehensive security features designed for enterprise environments:SQL Injection Protection
All parameters are bound using prepared statements, preventing SQL injection attacks:Security Configuration
Tools can include security metadata for enhanced protection:Security Best Practice: Always mark potentially sensitive operations with
security.audit: true
to ensure comprehensive audit logging for compliance and security monitoring.Authority Integration
The MCP server integrates with IBM i’s security model:- User Authentication: All queries execute with authenticated user credentials
- Object Authority: Respects IBM i object-level permissions
- Special Authority: Honors special authorities like
*ALLOBJ
and*AUDIT
- Program Adoption: Supports adopted authority for stored procedures
Tool Discovery and Organization
The YAML system supports sophisticated tool organization for complex environments:Domain Classification
Metadata Enhancement
Environment-Specific Tools
Configuration Management
File Organization
Environment Variables
All connection details and sensitive information use environment variables:Toolset Selection
Control which tools are loaded using environment configuration:Complete YAML Configuration Example
Here’s a complete YAML configuration that demonstrates real-world usage patterns with tools from the prebuilt configurations:- Multiple Parameter Types: String, integer, enum parameters with validation
- Parameter Validation: Required fields, defaults, min/max values, enum options
- Complex SQL: Table functions, stored procedure calls, conditional logic
- IBM i Integration: QSYS2 system services and proper IBM i SQL syntax
- Toolset Organization: Logical grouping of related tools for agent filtering
- Real-world Usage: Based on actual prebuilt configurations used in production
Best Practices
SQL Statement Guidelines
SQL Statement Guidelines
- Use IBM i system services (QSYS2 views/procedures) when available
- Include appropriate row limiting (
FETCH FIRST n ROWS ONLY
) - Handle NULL parameters with conditional logic
- Use descriptive column aliases for better AI understanding
- Consider performance impact on production systems
Parameter Design
Parameter Design
- Provide clear, AI-friendly parameter descriptions
- Use appropriate validation (patterns, ranges, enums)
- Set sensible defaults for optional parameters
- Follow IBM i naming conventions
- Include examples in descriptions when helpful
Security Considerations
Security Considerations
- Always use parameter binding (never string concatenation)
- Mark sensitive operations with
security.audit: true
- Use read-only flags where appropriate
- Include authority requirements in descriptions
- Test with least-privileged users
Documentation Standards
Documentation Standards
- Write descriptions for the AI agent audience
- Include business context in tool descriptions
- Specify units for numeric values
- Document any special authority requirements
- Provide usage examples and common scenarios
Integration with MCP Agents
YAML SQL tools seamlessly integrate with MCP agents, providing:- Automatic Schema Generation: Parameters become typed inputs for agents
- Response Formatting: Results are automatically formatted for agent consumption
- Error Handling: Comprehensive error messages help agents understand issues
- Tool Discovery: Agents can enumerate and understand available tools
To understand how to build agents that effectively use SQL tools, see the Agent Development Guide. For server architecture details, review the Server Architecture documentation.
Next Steps
Ready to create your own SQL tools?Building Tools
Step-by-step guide to creating custom YAML SQL tools
Testing & Development
Learn how to test and debug your SQL tools effectively
Examples & Use Cases
Explore real-world examples and common usage patterns
Configuration Reference
Complete reference for environment variables and settings
Design Philosophy: YAML SQL tools democratize AI agent development for IBM i environments by enabling database professionals to create sophisticated tools using their existing SQL expertise, while the MCP server handles all the complexity of agent integration, security, and protocol management.