Skip to main content
Glama
GongRzhe

Terminal Controller for MCP

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

Implementation Reference

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

Other Tools

Related Tools

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