listdir
Lists files and directories in a specified folder path to help users navigate and manage file systems within the editor-mcp server.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"dirpath": "<dirpath>"
},
"name": "listdir"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dirpath | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/text_editor/server.py:891-906 (handler)The handler function for the 'listdir' tool. It lists the contents of the specified directory using os.listdir() and returns the filenames along with the path. Handles cases where the path is not a directory or other exceptions occur.
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)}" }