Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

take_screenshot

Capture and save screen images on Windows systems. Specify file path and format (PNG or JPG) for automated screenshot management.

Instructions

截取屏幕截图

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo保存路径(可选,默认桌面)
formatNo图片格式(可选,默认 png)

Implementation Reference

  • The handler function that executes the screenshot capture using PowerShell script on Windows, saving to desktop or specified path with optional format.
    async takeScreenshot(savePath, format = 'png') { try { // 生成文件名 const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const fileName = `screenshot-${timestamp}.${format}`; const defaultPath = path.join(process.env.USERPROFILE, 'Desktop', fileName); const finalPath = savePath || defaultPath; // 使用 PowerShell 截图 const script = ` Add-Type -AssemblyName System.Windows.Forms,System.Drawing $bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds $bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height $graphics = [System.Drawing.Graphics]::FromImage($bitmap) $graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size) $bitmap.Save("${finalPath}", [System.Drawing.Imaging.ImageFormat]::${format === 'jpg' ? 'Jpeg' : 'Png'}) $bitmap.Dispose() $graphics.Dispose() `; await execAsync(`powershell -Command "${script.replace(/"/g, '\\"')}"`, { shell: 'powershell.exe' }); // 验证文件是否创建 await fs.access(finalPath); return { success: true, path: finalPath, format, message: '截图已保存' }; } catch (error) { return { success: false, error: error.message }; } }
  • The tool definition including name, description, and input schema for validation.
    { name: 'take_screenshot', description: '截取屏幕截图', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '保存路径(可选,默认桌面)' }, format: { type: 'string', enum: ['png', 'jpg'], description: '图片格式(可选,默认 png)' }, }, }, },
  • The executeTool method registers and dispatches 'take_screenshot' to its handler.
    async executeTool(name, args) { switch (name) { case 'take_screenshot': return await this.takeScreenshot(args.path, args.format); case 'take_screenshot_region': return await this.takeScreenshotRegion(args.x, args.y, args.width, args.height, args.path); default: throw new Error(`未知工具: ${name}`); } }
  • Checks if 'take_screenshot' is a handled tool.
    canHandle(toolName) { const tools = ['take_screenshot', 'take_screenshot_region']; return tools.includes(toolName); }

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/eva-wanxin-git/windows-automation-mcp'

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