What is a Tool?
A tool is a function that:- Has a well-defined interface (name, parameters, schema)
- Performs a specific operation
- Returns a result to the agent
- Can be called by the LLM during agent execution
Tool Anatomy
Every tool consists of:Name
- Use
snake_case - Be descriptive but concise
- Prefix with domain if needed (e.g.,
file_read,db_query)
read_filesearch_codeexecute_command
rf(too short)readTheContentsOfAFile(too verbose)do_stuff(not descriptive)
Description
Provide a clear description that explains:- What the tool does
- When to use it
- Important limitations or requirements
Input Schema
Define parameters using JSON Schema:Implementing Tool Logic
Basic Implementation
Parameter Extraction Helpers
Create helper functions for common parameter types:Tool Design Patterns
1. Read-Only Tools
Tools that only read data, never modify:2. Write/Modify Tools
Tools that modify state:3. Query Tools
Tools that search or filter:4. Action Tools
Tools that perform actions:Error Handling
Informative Error Messages
Provide context in error messages:Validation Errors
Permission Errors
Return Types
Text Results
Most common return type:Structured Data
Return JSON for structured data:Multiple Content Items
Return multiple pieces of content:Best Practices
1. Single Responsibility
Each tool should do one thing well: Good:read_file- reads a filewrite_file- writes a filelist_files- lists files
file_operations- does everything
2. Idempotency
When possible, make tools idempotent:3. Safe Defaults
Choose safe defaults for optional parameters:4. Timeouts
Set reasonable timeouts for long operations:5. Input Validation
Validate inputs thoroughly:6. Progress for Long Operations
For operations that may take time, provide feedback:Testing Tools
Unit Tests
Integration Tests
Test tools through the extension manager:Examples from Goose
See real tool implementations in:crates/goose-mcp/src/memory/- Memory storage toolscrates/goose-mcp/src/computercontroller/- Desktop automationcrates/goose-mcp/src/autovisualiser/- Visualization generation
Next Steps
- Learn about Extension Development
- Understand the MCP Protocol
- Build Providers