change_directory
Switch the current working directory to a specified path within the terminal, enabling efficient navigation and management of file system operations.
Instructions
Change current working directory
Args:
path: Directory path to switch to
Returns:
Operation result information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- terminal_controller.py:180-199 (handler)The main handler function for the 'change_directory' tool. It is decorated with @mcp.tool() which handles both registration and schema inference from the function signature and docstring. The function changes the current working directory using os.chdir() and returns success or error messages.@mcp.tool() async def change_directory(path: str) -> str: """ Change current working directory Args: path: Directory path to switch to Returns: Operation result information """ try: os.chdir(path) return f"Switched to directory: {os.getcwd()}" except FileNotFoundError: return f"Error: Directory '{path}' does not exist" except PermissionError: return f"Error: No permission to access directory '{path}'" except Exception as e: return f"Error changing directory: {str(e)}"