Overview
Kortix uses a tool registry system to manage available tools for agents. Tools are registered automatically at system initialization and can be accessed through the agent configuration.Tool Registration Architecture
The tool registration system operates at two levels:1. Native AgentPress Tools
Native tools are registered in theToolRegistry class and available system-wide. They are defined in Python and inherit from the Tool base class.
Tool Categories
Tools are organized into categories intool_registry.py:
Tool Class Structure
Each tool is implemented as a Python class:2. MCP (Model Context Protocol) Tools
MCP tools are registered from external servers (Composio, custom MCPs) and managed through theMCPRegistry.
MCP Tool Registration Flow
- Discovery: Connect to MCP server and list available tools
- Registration: Register tool metadata in
MCPRegistry - Activation: Load tool schemas on-demand (JIT - Just In Time)
- Execution: Create ephemeral connection for each tool call
MCP Tool Info Structure
Tool Registration Methods
Register Native Tool
Register MCP Tool
Tool Schema Format
All tools expose OpenAPI-compatible schemas:Tool Discovery
Get All Tool Summaries
Get Tool by Category
Get Tool Metadata
Get Tool Usage Guide
Runtime Tool Access
Get Available Functions
Get Tool Schemas
MCP Schema Caching
MCP tool schemas are cached in Redis for performance:Tool Metadata Decorators
@tool_metadata
Defines tool-level metadata:@openapi_schema
Defines method schemas for LLM consumption:Cache Invalidation
Best Practices
- Use descriptive names: Tool and method names should be clear and descriptive
- Provide detailed descriptions: Help the LLM understand when to use each tool
- Mark core tools appropriately: Core tools are always enabled
- Set appropriate weights: Lower weights appear first in tool lists
- Cache tool instances: Reuse tool instances when possible for performance
- Handle errors gracefully: Always return
ToolResultwith success/failure status - Document parameters: Use
@paramdecorator for all parameters - Keep schemas updated: Invalidate caches when tools change
Performance Considerations
- Tool schemas are cached after first registration
- OpenAPI schemas are cached and reused across requests
- MCP schemas are cached in Redis with 24-hour TTL
- Tool instances are cached when registered without kwargs
- Function lookups use cached dictionaries for fast access
Error Handling
All tool methods should returnToolResult: