Skip to main content
Glama

fast_list_directory

Retrieve directory listings with automatic chunking and pagination support. Filter files by name, sort by criteria, and manage large directories efficiently.

Instructions

디렉토리 목록을 조회합니다 (자동 청킹 페이징 지원)

Input Schema

NameRequiredDescriptionDefault
auto_chunkNo자동 청킹 활성화
continuation_tokenNo이전 호출의 연속 토큰
pageNo페이지 번호
page_sizeNo페이지당 항목 수
pathYes디렉토리 경로
patternNo파일명 필터 패턴
reverseNo역순 정렬
show_hiddenNo숨김 파일 표시
sort_byNo정렬 기준name

Input Schema (JSON Schema)

{ "properties": { "auto_chunk": { "default": true, "description": "자동 청킹 활성화", "type": "boolean" }, "continuation_token": { "description": "이전 호출의 연속 토큰", "type": "string" }, "page": { "default": 1, "description": "페이지 번호", "type": "number" }, "page_size": { "description": "페이지당 항목 수", "type": "number" }, "path": { "description": "디렉토리 경로", "type": "string" }, "pattern": { "description": "파일명 필터 패턴", "type": "string" }, "reverse": { "default": false, "description": "역순 정렬", "type": "boolean" }, "show_hidden": { "default": false, "description": "숨김 파일 표시", "type": "boolean" }, "sort_by": { "default": "name", "description": "정렬 기준", "enum": [ "name", "size", "modified", "type" ], "type": "string" } }, "required": [ "path" ], "type": "object" }

Implementation Reference

  • The primary handler function for the 'fast_list_directory' tool. It validates the directory path, reads directory entries, applies filters (hidden files, exclude patterns, pattern matching), sorts the entries, implements pagination, fetches stats for each item, and returns structured directory listing information.
    async function handleListDirectory(args: any) { const { path: dirPath, page = 1, page_size, pattern, show_hidden = false, sort_by = 'name', reverse = false } = args; const safePath_resolved = safePath(dirPath); const stats = await fs.stat(safePath_resolved); if (!stats.isDirectory()) { throw new Error('Path is not a directory'); } const pageSize = page_size ? Math.min(page_size, CLAUDE_MAX_DIR_ITEMS) : 50; const entries = await fs.readdir(safePath_resolved, { withFileTypes: true }); let filteredEntries = entries.filter(entry => { if (!show_hidden && entry.name.startsWith('.')) return false; if (shouldExcludePath(path.join(safePath_resolved, entry.name))) return false; if (pattern) { return entry.name.toLowerCase().includes(pattern.toLowerCase()); } return true; }); // 정렬 filteredEntries.sort((a, b) => { let comparison = 0; switch (sort_by) { case 'name': comparison = a.name.localeCompare(b.name); break; case 'type': const aType = a.isDirectory() ? 'directory' : 'file'; const bType = b.isDirectory() ? 'directory' : 'file'; comparison = aType.localeCompare(bType); break; default: comparison = a.name.localeCompare(b.name); } return reverse ? -comparison : comparison; }); const startIdx = (page - 1) * pageSize; const endIdx = startIdx + pageSize; const pageEntries = filteredEntries.slice(startIdx, endIdx); const items = await Promise.all(pageEntries.map(async (entry) => { try { const fullPath = path.join(safePath_resolved, entry.name); const itemStats = await fs.stat(fullPath); return { name: entry.name, type: entry.isDirectory() ? 'directory' : 'file', size: entry.isFile() ? itemStats.size : null, size_readable: entry.isFile() ? formatSize(itemStats.size) : null, modified: itemStats.mtime.toISOString(), created: itemStats.birthtime.toISOString(), permissions: itemStats.mode, path: fullPath }; } catch { return { name: entry.name, type: entry.isDirectory() ? 'directory' : 'file', size: null, size_readable: null, modified: null, created: null, permissions: null, path: path.join(safePath_resolved, entry.name) }; } })); return { path: safePath_resolved, items: items, page: page, page_size: pageSize, total_count: filteredEntries.length, total_pages: Math.ceil(filteredEntries.length / pageSize), has_more: endIdx < filteredEntries.length, sort_by: sort_by, reverse: reverse, timestamp: new Date().toISOString() }; }
  • Input schema definition for the 'fast_list_directory' tool, specifying parameters like path, pagination, filtering, sorting options. Part of the MCP_TOOLS registration array.
    { name: 'fast_list_directory', description: '디렉토리 목록을 조회합니다 (페이징 지원)', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '디렉토리 경로' }, page: { type: 'number', description: '페이지 번호', default: 1 }, page_size: { type: 'number', description: '페이지당 항목 수' }, pattern: { type: 'string', description: '파일명 필터 패턴' }, show_hidden: { type: 'boolean', description: '숨김 파일 표시', default: false }, sort_by: { type: 'string', description: '정렬 기준', enum: ['name', 'size', 'modified', 'type'], default: 'name' }, reverse: { type: 'boolean', description: '역순 정렬', default: false } }, required: ['path'] }
  • api/server.ts:329-330 (registration)
    Dispatch case in the tools/call handler that routes calls to the fast_list_directory tool to its implementation function.
    case 'fast_list_directory': result = await handleListDirectory(args);

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/efforthye/fast-filesystem-mcp'

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