Skip to main content
Glama
GongRzhe

Terminal Controller for MCP

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
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • 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)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GongRzhe/terminal-controller-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server