Skip to main content

Tool Schema

Each tool is defined with a JSON schema that Claude uses to understand how to call it.

read_file

Read the contents of a file.
{
  "name": "read_file",
  "description": "Read the contents of a file at the specified path",
  "input_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path to the file to read"
      }
    },
    "required": ["path"]
  }
}
Returns
string
The contents of the file as a string

write_file

Write content to a file.
{
  "name": "write_file",
  "description": "Write content to a file. Creates parent directories as needed.",
  "input_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path where the file should be written"
      },
      "content": {
        "type": "string",
        "description": "The content to write to the file"
      }
    },
    "required": ["path", "content"]
  }
}
Returns
string
Success message with character count

edit_file

Make targeted edits to existing files.
{
  "name": "edit_file",
  "description": "Edit a file by replacing a specific string with new content",
  "input_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path to the file to edit"
      },
      "old_string": {
        "type": "string",
        "description": "The exact string to find and replace"
      },
      "new_string": {
        "type": "string",
        "description": "The string to replace it with"
      }
    },
    "required": ["path", "old_string", "new_string"]
  }
}
Returns
string
Success message

list_directory

List the contents of a directory.
{
  "name": "list_directory",
  "description": "List the contents of a directory",
  "input_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The directory path to list"
      }
    },
    "required": []
  }
}
Returns
string
Formatted list of files and directories

bash

Execute a bash command.
{
  "name": "bash",
  "description": "Execute a bash command and return the output",
  "input_schema": {
    "type": "object",
    "properties": {
      "command": {
        "type": "string",
        "description": "The bash command to execute"
      },
      "timeout": {
        "type": "number",
        "description": "Timeout in milliseconds (default: 30000)"
      }
    },
    "required": ["command"]
  }
}
Returns
string
Command output (stdout and stderr)

search_files

Search for files matching a glob pattern.
{
  "name": "search_files",
  "description": "Search for files matching a glob pattern",
  "input_schema": {
    "type": "object",
    "properties": {
      "pattern": {
        "type": "string",
        "description": "Glob pattern (e.g., '**/*.js')"
      },
      "path": {
        "type": "string",
        "description": "Base directory to search in"
      }
    },
    "required": ["pattern"]
  }
}
Returns
string
List of matching file paths

grep

Search for a pattern in files.
{
  "name": "grep",
  "description": "Search for a pattern in files",
  "input_schema": {
    "type": "object",
    "properties": {
      "pattern": {
        "type": "string",
        "description": "The regex pattern to search for"
      },
      "path": {
        "type": "string",
        "description": "File or directory to search in"
      },
      "file_pattern": {
        "type": "string",
        "description": "Optional glob to filter files"
      }
    },
    "required": ["pattern"]
  }
}
Returns
string
Matching lines with file paths and line numbers

Error Handling

All tools throw errors on failure:
try {
  const result = await executeToolCall(toolName, input);
  // Success
} catch (error) {
  // Handle error
  return {
    type: 'tool_result',
    tool_use_id: id,
    content: `Error: ${error.message}`,
    is_error: true,
  };
}
Nelson gracefully handles tool errors and often retries with a different approach.