Skip to main content
Glama

list_directories

Retrieve all configured screenshot directories from the MCP Windows Screenshots server, enabling easy access and sharing of screenshots without navigating complex file paths.

Instructions

List all configured screenshot directories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler for the 'list_directories' tool. It fetches default and custom screenshot directories, checks if they exist, and returns a JSON-formatted list with additional metadata.
    case 'list_directories': { const defaultDirs = getScreenshotDirectories(); const customDirs = getCustomDirectories(); const dirInfo = await Promise.all( [...defaultDirs, ...customDirs].map(async (dir) => { try { await stat(dir); return { path: dir, exists: true }; } catch { return { path: dir, exists: false }; } }) ); return { content: [ { type: 'text', text: JSON.stringify({ default_directories: dirInfo.filter((_, i) => i < defaultDirs.length), custom_directories: dirInfo.filter((_, i) => i >= defaultDirs.length), environment_variable: 'MCP_SCREENSHOT_DIRS', current_value: process.env.MCP_SCREENSHOT_DIRS || '(not set)', windows_username: process.env.WINDOWS_USERNAME || '(not set)', usage: 'Set MCP_SCREENSHOT_DIRS=/path/to/dir or use semicolon for multiple: /path/1;/path/2', }, null, 2), }, ], }; }
  • src/index.ts:220-226 (registration)
    Registration of the 'list_directories' tool in the tools array, including name, description, and empty input schema (no parameters required).
    name: 'list_directories', description: 'List all configured screenshot directories', inputSchema: { type: 'object', properties: {}, }, },
  • Input schema for the 'list_directories' tool, which expects no parameters.
    inputSchema: { type: 'object', properties: {}, },
  • Key helper function that generates the list of default screenshot directories, adapting to WSL, Windows, or Linux environments and querying the Windows registry for the screenshots folder.
    const getScreenshotDirectories = (): string[] => { const username = os.userInfo().username; const windowsUsername = process.env.WINDOWS_USERNAME || username; const env = detectEnvironment(); // Try to get the actual Screenshots folder from registry first const registryPath = getWindowsScreenshotPath(); const directories: string[] = []; if (registryPath) { directories.push(registryPath); } // Add default paths based on environment if (env.type === 'wsl') { // WSL paths directories.push( `/mnt/c/Users/${windowsUsername}/Pictures/Screenshots`, `/mnt/c/Users/${windowsUsername}/Pictures`, `/mnt/c/Users/${windowsUsername}/OneDrive/Pictures/Screenshots`, `/mnt/c/Users/${windowsUsername}/OneDrive/Pictures 2/Screenshots 1`, `/mnt/c/Users/${windowsUsername}/Documents/Screenshots`, `/mnt/c/Users/${windowsUsername}/Desktop`, `/mnt/c/Users/${windowsUsername}/AppData/Local/Temp`, `/mnt/c/Windows/Temp` ); } else if (env.type === 'windows') { // Native Windows paths directories.push( `C:\\Users\\${windowsUsername}\\Pictures\\Screenshots`, `C:\\Users\\${windowsUsername}\\Pictures`, `C:\\Users\\${windowsUsername}\\OneDrive\\Pictures\\Screenshots`, `C:\\Users\\${windowsUsername}\\OneDrive\\Pictures 2\\Screenshots 1`, `C:\\Users\\${windowsUsername}\\Documents\\Screenshots`, `C:\\Users\\${windowsUsername}\\Desktop`, `C:\\Users\\${windowsUsername}\\AppData\\Local\\Temp`, `C:\\Windows\\Temp` ); } // Remove duplicates return [...new Set(directories)]; };
  • Helper function to parse custom screenshot directories from the MCP_SCREENSHOT_DIRS environment variable, supporting semicolon-separated lists.
    const getCustomDirectories = (): string[] => { // Check for multiple directories first (semicolon-separated) const customDirs = process.env.MCP_SCREENSHOT_DIRS; if (!customDirs) return []; // If it contains semicolons, split by semicolon if (customDirs.includes(';')) { return customDirs.split(';').filter(dir => dir.trim()); } // Otherwise, treat as a single directory return [customDirs.trim()]; };
Install Server

Other Tools

Related 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/rubinsh/mcp-windows-screenshots'

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