Skip to main content
Glama

screenshot

Capture a screenshot of the iOS Simulator screen and save it to a file. Choose image format, display, and mask options for non-rectangular screens.

Instructions

Takes a screenshot of the iOS Simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
udidNoUdid of target, can also be set with the IDB_UDID env var
output_pathYesFile path where the screenshot will be saved. If relative, it uses the directory specified by the `IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR` env var, or `~/Downloads` if not set.
typeNoImage format (png, tiff, bmp, gif, or jpeg). Default is png.
displayNoDisplay to capture (internal or external). Default depends on device type.
maskNoFor non-rectangular displays, handle the mask by policy (ignored, alpha, or black)

Implementation Reference

  • src/index.ts:846-932 (registration)
    Registration of the 'screenshot' tool via server.tool() with name 'screenshot' and description 'Takes a screenshot of the iOS Simulator'
    if (!isToolFiltered("screenshot")) {
      server.tool(
        "screenshot",
        "Takes a screenshot of the iOS Simulator",
        {
          udid: z
            .string()
            .regex(UDID_REGEX)
            .optional()
            .describe("Udid of target, can also be set with the IDB_UDID env var"),
          output_path: z
            .string()
            .max(1024)
            .describe(
              "File path where the screenshot will be saved. If relative, it uses the directory specified by the `IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR` env var, or `~/Downloads` if not set."
            ),
          type: z
            .enum(["png", "tiff", "bmp", "gif", "jpeg"])
            .optional()
            .describe(
              "Image format (png, tiff, bmp, gif, or jpeg). Default is png."
            ),
          display: z
            .enum(["internal", "external"])
            .optional()
            .describe(
              "Display to capture (internal or external). Default depends on device type."
            ),
          mask: z
            .enum(["ignored", "alpha", "black"])
            .optional()
            .describe(
              "For non-rectangular displays, handle the mask by policy (ignored, alpha, or black)"
            ),
        },
        { title: "Take Screenshot", readOnlyHint: false, openWorldHint: true },
        async ({ udid, output_path, type, display, mask }) => {
          try {
            const actualUdid = await getBootedDeviceId(udid);
            const absolutePath = ensureAbsolutePath(output_path);
    
            // command is weird, it responds with stderr on success and stdout is blank
            const { stderr: stdout } = await run("xcrun", [
              "simctl",
              "io",
              actualUdid,
              "screenshot",
              ...(type ? [`--type=${type}`] : []),
              ...(display ? [`--display=${display}`] : []),
              ...(mask ? [`--mask=${mask}`] : []),
              // When passing user-provided values to a command, it's crucial to use `--`
              // to separate the command's options from positional arguments.
              // This prevents the shell from misinterpreting the arguments as options.
              "--",
              absolutePath,
            ]);
    
            // throw if we don't get the expected success message
            if (stdout && !stdout.includes("Wrote screenshot to")) {
              throw new Error(stdout);
            }
    
            return {
              isError: false,
              content: [
                {
                  type: "text",
                  text: stdout,
                },
              ],
            };
          } catch (error) {
            return {
              isError: true,
              content: [
                {
                  type: "text",
                  text: errorWithTroubleshooting(
                    `Error taking screenshot: ${toError(error).message}`
                  ),
                },
              ],
            };
          }
        }
      );
    }
  • Zod schema defining input parameters for the screenshot tool: udid, output_path (required), type, display, mask
    {
      udid: z
        .string()
        .regex(UDID_REGEX)
        .optional()
        .describe("Udid of target, can also be set with the IDB_UDID env var"),
      output_path: z
        .string()
        .max(1024)
        .describe(
          "File path where the screenshot will be saved. If relative, it uses the directory specified by the `IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR` env var, or `~/Downloads` if not set."
        ),
      type: z
        .enum(["png", "tiff", "bmp", "gif", "jpeg"])
        .optional()
        .describe(
          "Image format (png, tiff, bmp, gif, or jpeg). Default is png."
        ),
      display: z
        .enum(["internal", "external"])
        .optional()
        .describe(
          "Display to capture (internal or external). Default depends on device type."
        ),
      mask: z
        .enum(["ignored", "alpha", "black"])
        .optional()
        .describe(
          "For non-rectangular displays, handle the mask by policy (ignored, alpha, or black)"
        ),
    },
  • Handler function for the screenshot tool. Executes 'xcrun simctl io <udid> screenshot' with optional type/display/mask flags, saves to output path, and returns the result text.
      async ({ udid, output_path, type, display, mask }) => {
        try {
          const actualUdid = await getBootedDeviceId(udid);
          const absolutePath = ensureAbsolutePath(output_path);
    
          // command is weird, it responds with stderr on success and stdout is blank
          const { stderr: stdout } = await run("xcrun", [
            "simctl",
            "io",
            actualUdid,
            "screenshot",
            ...(type ? [`--type=${type}`] : []),
            ...(display ? [`--display=${display}`] : []),
            ...(mask ? [`--mask=${mask}`] : []),
            // When passing user-provided values to a command, it's crucial to use `--`
            // to separate the command's options from positional arguments.
            // This prevents the shell from misinterpreting the arguments as options.
            "--",
            absolutePath,
          ]);
    
          // throw if we don't get the expected success message
          if (stdout && !stdout.includes("Wrote screenshot to")) {
            throw new Error(stdout);
          }
    
          return {
            isError: false,
            content: [
              {
                type: "text",
                text: stdout,
              },
            ],
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: errorWithTroubleshooting(
                  `Error taking screenshot: ${toError(error).message}`
                ),
              },
            ],
          };
        }
      }
    );
  • Helper function that resolves relative file paths to absolute paths using IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR or ~/Downloads as the base directory. Used by the screenshot handler to determine the output path.
    function ensureAbsolutePath(filePath: string): string {
      if (path.isAbsolute(filePath)) {
        return filePath;
      }
    
      // Handle ~/something paths in the provided filePath
      if (filePath.startsWith("~/")) {
        return path.join(os.homedir(), filePath.slice(2));
      }
    
      // Determine the default directory from env var or fallback to ~/Downloads
      let defaultDir = path.join(os.homedir(), "Downloads");
      const customDefaultDir = process.env.IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR;
    
      if (customDefaultDir) {
        // also expand tilde for the custom directory path
        if (customDefaultDir.startsWith("~/")) {
          defaultDir = path.join(os.homedir(), customDefaultDir.slice(2));
        } else {
          defaultDir = customDefaultDir;
        }
      }
    
      // Join the relative filePath with the resolved default directory
      return path.join(defaultDir, filePath);
    }
Behavior2/5

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

The description only states the action without disclosing behavioral traits. The annotation 'readOnlyHint': false contradicts the typical read-only nature of screenshots, suggesting possible side effects not mentioned in the description.

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?

The description is a single, front-loaded sentence that is concise and to the point. It wastes no words but could be slightly more structured for clarity.

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

Completeness3/5

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

While parameters are well-documented, the description lacks information about the tool's return value or side effects. For a tool with no output schema, the description should clarify what happens after execution (e.g., file saved, success message).

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?

All parameters are well-described in the input schema, achieving 100% coverage. The description adds no additional semantic value beyond what the schema provides, so a baseline score of 3 is appropriate.

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?

The description clearly states the action (takes a screenshot) and the target (iOS Simulator). However, it does not differentiate from the sibling tool 'record_video', which captures video instead of still images.

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 is provided on when to use this tool versus alternatives like 'record_video' or other UI capture tools. The description lacks any contextual hints about appropriate use cases or prerequisites.

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/joshuayoes/ios-simulator-mcp'

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