Skip to main content
Glama

take_screenshot

Capture screenshots on macOS with control over area, format, cursor visibility, window shadow, and timestamp. Specify save path and type: fullscreen, window, or selection.

Instructions

Take a screenshot using macOS screencapture

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath where to save the screenshot
typeYesType of screenshot to take
formatNoImage format
hideCursorNoWhether to hide the cursor
shadowNoWhether to include the window shadow (only for window type)
timestampNoTimestamp to add to filename

Implementation Reference

  • Main handler function that validates params, builds the screencapture command, and executes it. Imports ScreenshotParams, NotificationError, execAsync, and escapeString. Throws specific error types on failure.
    export async function takeScreenshot(params: ScreenshotParams): Promise<void> {
      try {
        validateScreenshotParams(params);
        const command = buildScreenshotCommand(params);
        await execAsync(command);
      } catch (error) {
        if (error instanceof NotificationError) {
          throw error;
        }
    
        const err = error as Error;
        if (err.message.includes('execution error')) {
          throw new NotificationError(
            NotificationErrorType.COMMAND_FAILED,
            'Failed to capture screenshot'
          );
        } else if (err.message.includes('permission')) {
          throw new NotificationError(
            NotificationErrorType.PERMISSION_DENIED,
            'Permission denied when trying to capture screenshot'
          );
        } else {
          throw new NotificationError(
            NotificationErrorType.UNKNOWN,
            `Unexpected error: ${err.message}`
          );
        }
  • TypeScript interface defining ScreenshotParams: path (required), type (fullscreen|window|selection, required), format (png|jpg|pdf|tiff), hideCursor, shadow, timestamp.
    export interface ScreenshotParams {
      /** Path where to save the screenshot */
      path: string;
      /** Type of screenshot to take */
      type: 'fullscreen' | 'window' | 'selection';
      /** Image format (png, jpg, pdf, tiff) */
      format?: 'png' | 'jpg' | 'pdf' | 'tiff';
      /** Whether to hide the cursor */
      hideCursor?: boolean;
      /** Whether to include the window shadow (only for window type) */
      shadow?: boolean;
      /** Timestamp to add to filename (defaults to current time) */
      timestamp?: boolean;
    }
  • src/index.ts:144-178 (registration)
    Tool registration in ListToolsRequestSchema handler: name 'take_screenshot', description, and inputSchema with path, type, format, hideCursor, shadow, timestamp fields.
    name: 'take_screenshot',
    description: 'Take a screenshot using macOS screencapture',
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path where to save the screenshot',
        },
        type: {
          type: 'string',
          enum: ['fullscreen', 'window', 'selection'],
          description: 'Type of screenshot to take',
        },
        format: {
          type: 'string',
          enum: ['png', 'jpg', 'pdf', 'tiff'],
          description: 'Image format',
        },
        hideCursor: {
          type: 'boolean',
          description: 'Whether to hide the cursor',
        },
        shadow: {
          type: 'boolean',
          description: 'Whether to include the window shadow (only for window type)',
        },
        timestamp: {
          type: 'boolean',
          description: 'Timestamp to add to filename',
        }
      },
      required: ['path', 'type'],
      additionalProperties: false,
    },
  • Case handler in CallToolRequestSchema switch statement: extracts params from request, constructs ScreenshotParams, calls takeScreenshot() from screenshot.ts, returns success message.
    case 'take_screenshot': {
      const { path, type, format, hideCursor, shadow, timestamp } = request.params.arguments as Record<string, unknown>;
      
      const params: ScreenshotParams = {
        path: path as string,
        type: type as 'fullscreen' | 'window' | 'selection',
        format: format as 'png' | 'jpg' | 'pdf' | 'tiff' | undefined,
        hideCursor: typeof hideCursor === 'boolean' ? hideCursor : undefined,
        shadow: typeof shadow === 'boolean' ? shadow : undefined,
        timestamp: typeof timestamp === 'boolean' ? timestamp : undefined
      };
    
      await takeScreenshot(params);
      return {
        content: [
          {
            type: 'text',
            text: 'Screenshot saved successfully',
          },
        ],
      };
    }
  • Helper function buildScreenshotCommand that builds the macOS screencapture CLI command with flags for type (-w, -s), format (-t), hide cursor (-C), shadow (-o), and optional timestamp in filename.
    function buildScreenshotCommand(params: ScreenshotParams): string {
      let command = 'screencapture';
      
      // Screenshot type
      switch (params.type) {
        case 'window':
          command += ' -w'; // Capture window
          break;
        case 'selection':
          command += ' -s'; // Interactive selection
          break;
        // fullscreen is default, no flag needed
      }
      
      // Optional flags
      if (params.format) {
        command += ` -t ${params.format}`;
      }
      
      if (params.hideCursor) {
        command += ' -C'; // Hide cursor
      }
      
      if (params.type === 'window' && params.shadow === false) {
        command += ' -o'; // No window shadow
      }
      
      // Add timestamp to filename if requested
      let path = params.path;
      if (params.timestamp) {
        const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
        const ext = params.format || 'png';
        path = path.replace(new RegExp(`\\.${ext}$`), `-${timestamp}.${ext}`);
      }
      
      command += ` "${escapeString(path)}"`;
      
      return command;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description bears full burden. Mentions 'macOS screencapture' to hint at system call, but fails to state that it saves to file, requires display permissions, or that it blocks execution. No behavioral traits disclosed beyond basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence, no extra words, efficient. However, lacks structure (e.g., bullet points) that could improve readability for such a multi-param tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, description is too sparse. Does not explain return value (saved file path?), does not mention side effects (file write), and omits important nuances like when to use different screenshot types.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. Description adds no extra meaning beyond what schema already provides for parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb (take) and resource (screenshot) with specific underlying tool (macOS screencapture). Distinguishes from sibling tools which are all unrelated. Could mention the types of screenshots (fullscreen, window, selection) but schema covers that.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives. No explicit context for when to capture full screen vs window vs selection, or when to use timestamp feature.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/turlockmike/apple-notifier-mcp'

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