Skip to main content
Glama

list_directory

Browse files and directories in a specified path to view local project contents for development tasks.

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 handler function that implements the list_directory tool logic: resolves path, reads directory entries, formats with icons, and returns formatted text content.
    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 'path' parameter.
    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 metadata (name, description, schema) in the ListToolsRequestSchema response.
    { 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