Skip to main content
Tools are the primary way extensions provide functionality to Goose. This guide covers best practices for designing and implementing effective tools.

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
Tools are exposed via MCP and called by the agent when needed.

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)
Good:
  • read_file
  • search_code
  • execute_command
Bad:
  • 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:
Usage:

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 file
  • write_file - writes a file
  • list_files - lists files
Bad:
  • 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 tools
  • crates/goose-mcp/src/computercontroller/ - Desktop automation
  • crates/goose-mcp/src/autovisualiser/ - Visualization generation

Next Steps