Skip to main content

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 the ToolRegistry class and available system-wide. They are defined in Python and inherit from the Tool base class.

Tool Categories

Tools are organized into categories in tool_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 the MCPRegistry.

MCP Tool Registration Flow

  1. Discovery: Connect to MCP server and list available tools
  2. Registration: Register tool metadata in MCPRegistry
  3. Activation: Load tool schemas on-demand (JIT - Just In Time)
  4. 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

  1. Use descriptive names: Tool and method names should be clear and descriptive
  2. Provide detailed descriptions: Help the LLM understand when to use each tool
  3. Mark core tools appropriately: Core tools are always enabled
  4. Set appropriate weights: Lower weights appear first in tool lists
  5. Cache tool instances: Reuse tool instances when possible for performance
  6. Handle errors gracefully: Always return ToolResult with success/failure status
  7. Document parameters: Use @param decorator for all parameters
  8. 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 return ToolResult: