Skip to main content
Glama
Rahii123

Advanced MCP Server

by Rahii123

list_directory

View files and folders in a local directory to explore system contents safely. Specify a path or use current location by default.

Instructions

List the contents of a local directory. Default is current directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo.

Implementation Reference

  • server.py:66-77 (handler)
    The handler function for the 'list_directory' tool. It lists the contents of the specified directory using os.listdir, formats them as a bullet list, and handles errors. Registered via @mcp.tool() decorator.
    @mcp.tool() def list_directory(path: str = ".") -> str: """List the contents of a local directory. Default is current directory.""" try: items = os.listdir(path) if not items: return f"The directory '{path}' is empty." return "\n".join([f"- {item}" for item in items]) except Exception as e: return f"Error reading directory: {str(e)}"
Install Server

Other 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/Rahii123/mcp'

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