- Local Python Tools - Custom functions in your codebase
- Remote MCP Tools - External tools via Model Context Protocol
Local Python Tools
Creating a Tool
Add a function toapp/services/local_tools.py and decorate it:
Tool Requirements
- Type hints - Required for automatic schema generation
- Docstring - Used as tool description
- Return value - Must be JSON-serializable
Supported Types
int,float,boolstrlist,dict- Optional types:
int | None,Optional[int]
Example: Calculator Tool
Example: Time Tool
Example: Async Tool
Remote MCP Tools
MCP tools are automatically discovered from configured MCP servers. See MCP Integration for setup.Using MCP Tools
- Configure MCP server in
mcp_config.json - Tools are auto-discovered on server startup
- Include in
allowed_toolsin API requests
Tool Schema Generation
Agent Chassis automatically generates OpenAI-compatible JSON schemas for all tools:Local Tool Schema
MCP Tool Schema
MCP tools are translated from MCPTool format to OpenAI format automatically.
Tool Execution
Agent Tool Calling Flow
- Agent receives request with
allowed_tools - Agent selects tool based on user query
- Tool is executed (local function or MCP call)
- Result is returned to agent
- Agent processes result and responds
Error Handling
Tools should handle errors gracefully:Best Practices
1. Clear Descriptions
Write clear docstrings - they become tool descriptions:2. Type Hints
Always use type hints for automatic validation:3. Input Validation
Validate inputs before processing:4. Async for I/O Operations
Use async for network calls, database queries, etc.:5. Tool Filtering
Always filter tools per request for security:Testing Tools
Unit Testing
Test tools independently:Integration Testing
Test tools via the agent:Tool Registry
Access registered tools programmatically:Next Steps
- See MCP Integration for remote tools
- Check API Reference for tool usage in requests
- Review existing tools in
app/services/local_tools.pyfor examples