listdir
Retrieve a list of files and directories within a specified path using the 'listdir' tool on the editor-mcp server, enabling efficient file management and navigation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dirpath | Yes |
Implementation Reference
- src/text_editor/server.py:891-906 (handler)The handler function for the 'listdir' tool that lists directory contents using os.listdir and handles errors.async def listdir(dirpath: str) -> Dict[str, Any]: try: return { "filenames": os.listdir(dirpath), "path": dirpath, } except NotADirectoryError as e: return { "error": "Specified path is not a directory.", "path": dirpath, } except Exception as e: return { "error": f"Unexpected error when listing the directory: {str(e)}" }