Skip to main content
Glama

list_directory

Browse and view files and directories within your local development projects to navigate your codebase structure and locate specific files.

Instructions

List files and directories in a given path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to directory (relative to projects directory or absolute)

Implementation Reference

  • The main handler function for the 'list_directory' tool. It resolves the directory path, reads the contents using fs.readdir with file types, maps entries to formatted strings with icons, and returns a text content block listing the items.
    async listDirectory(dirPath) { const resolvedPath = this.resolvePath(dirPath); const entries = await fs.readdir(resolvedPath, { withFileTypes: true }); const items = entries.map((entry) => { const icon = entry.isDirectory() ? '📁' : '📄'; return `${icon} ${entry.name}`; }); return { content: [ { type: 'text', text: `Contents of ${resolvedPath}:\n\n${items.join('\n')}`, }, ], }; }
  • Input schema for the 'list_directory' tool, defining the required 'path' parameter as a string.
    inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to directory (relative to projects directory or absolute)', }, }, required: ['path'], },
  • index.js:101-114 (registration)
    Registration of the 'list_directory' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    { name: 'list_directory', description: 'List files and directories in a given path', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to directory (relative to projects directory or absolute)', }, }, required: ['path'], }, },
  • index.js:172-173 (registration)
    Dispatch/registration of the 'list_directory' handler in the CallToolRequestSchema switch statement.
    case 'list_directory': return await this.listDirectory(args.path);

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/talentedmrweb/local-dev-bridge-mcp'

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