change_directory
Navigate to a specified directory path to change the current working directory for 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 handler function for the 'change_directory' tool. It is decorated with @mcp.tool() which registers it with FastMCP using the function name as the tool name. 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)}"