Skip to main content
Glama

video_record

Record screen video on mobile devices for testing. Use start action to begin and stop action to end and retrieve the file.

Instructions

Enregistre une vidéo de l'écran du device. Utilise action='start' pour commencer et action='stop' pour arrêter et récupérer le fichier.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes'start' pour commencer l'enregistrement, 'stop' pour arrêter

Implementation Reference

  • Main handler for video_record tool. Registers the MCP tool with 'start'/'stop' actions, manages recording state, dispatches to iOS (simctl) or Android (adb) recording helpers.
    export function registerVideoRecord(server: McpServer): void {
      server.tool(
        "video_record",
        "Enregistre une vidéo de l'écran du device. Utilise action='start' pour commencer et action='stop' pour arrêter et récupérer le fichier.",
        {
          action: z.enum(["start", "stop"]).describe("'start' pour commencer l'enregistrement, 'stop' pour arrêter"),
        },
        async ({ action }) => {
          const result = await resolveDevice();
          if ("error" in result) return { content: [{ type: "text", text: result.error }], isError: true };
          const dev = result.device;
    
          // Recover from stale state if process died
          recoverStaleState();
    
          try {
            if (action === "start") {
              if (isRecording) {
                return { content: [{ type: "text", text: `Enregistrement déjà en cours (${isRecording}). Arrête-le d'abord avec action='stop'.` }], isError: true };
              }
    
              if (dev.platform === "ios") {
                iosRecordPid = await iosStartVideoRecord(dev.id, "/tmp/phantom-ios-record.mp4");
                isRecording = "ios";
              } else {
                await androidStartScreenRecord();
                isRecording = "android";
              }
    
              return { content: [{ type: "text", text: `Enregistrement vidéo démarré sur ${dev.name}. Utilise video_record(action='stop') pour arrêter.` }] };
            }
    
            // Stop
            if (!isRecording) {
              return { content: [{ type: "text", text: "Aucun enregistrement en cours. Lance d'abord video_record(action='start')." }], isError: true };
            }
    
            let filePath: string;
    
            if (isRecording === "ios") {
              if (iosRecordPid) {
                try { process.kill(iosRecordPid, "SIGINT"); } catch (err) {
                  console.error(`[phantom] Failed to stop iOS recording (PID ${iosRecordPid}): ${err instanceof Error ? err.message : err}`);
                }
                iosRecordPid = null;
              }
              await new Promise((r) => setTimeout(r, 1500));
              filePath = "/tmp/phantom-ios-record.mp4";
            } else {
              filePath = await androidStopScreenRecord();
            }
    
            isRecording = null;
    
            return {
              content: [{ type: "text", text: `Vidéo enregistrée : ${filePath}\nTu peux la lire avec : open "${filePath}"` }],
            };
          } catch (err) {
            isRecording = null;
            const msg = err instanceof Error ? err.message : String(err);
            return { content: [{ type: "text", text: `Erreur video_record: ${msg}` }], isError: true };
          }
        }
      );
    }
  • Zod schema for video_record: 'action' enum of 'start' or 'stop'.
    {
      action: z.enum(["start", "stop"]).describe("'start' pour commencer l'enregistrement, 'stop' pour arrêter"),
    },
  • src/index.ts:60-60 (registration)
    Registration call in the main server setup, which registers the video_record tool on the MCP server.
    registerVideoRecord(server);
  • iOS helper: starts video recording via xcrun simctl io recordVideo, returns PID for later termination.
    export async function iosStartVideoRecord(deviceUdid: string, outputPath: string): Promise<number | null> {
      validateUdid(deviceUdid);
      if (!outputPath.startsWith("/tmp/phantom-")) throw new Error("outputPath doit commencer par /tmp/phantom-");
      const proc = spawn("xcrun", ["simctl", "io", deviceUdid, "recordVideo", outputPath], {
        detached: true,
        stdio: "ignore",
      });
      proc.unref();
      console.error(`[phantom] iOS video recording started (PID: ${proc.pid})`);
      return proc.pid ?? null;
    }
  • Android helpers: starts screenrecord via adb shell screenrecord (detached), stops by killing PID/pulling file to /tmp.
    export async function androidStartScreenRecord(outputPath: string = "/sdcard/phantom-record.mp4"): Promise<void> {
      if (!outputPath.startsWith("/sdcard/phantom-")) throw new Error("outputPath doit commencer par /sdcard/phantom-");
      const path = await findAdb();
      const proc = spawn(path, buildArgs(["shell", "screenrecord", outputPath]), {
        detached: true,
        stdio: "ignore",
      });
      proc.unref();
      // Store PID for later kill
      screenRecordPid = proc.pid ?? null;
      console.error(`[phantom] Screen recording started on Android (PID: ${screenRecordPid})`);
    }
    
    let screenRecordPid: number | null = null;
    
    export async function androidStopScreenRecord(): Promise<string> {
      // Kill the screenrecord process
      if (screenRecordPid) {
        try { process.kill(screenRecordPid); } catch (err) {
          console.error(`[phantom] Failed to kill screenrecord (PID ${screenRecordPid}): ${err instanceof Error ? err.message : err}`);
        }
        screenRecordPid = null;
      } else {
        await adb(["shell", "pkill", "-f", "screenrecord"]).catch(() => {});
      }
      await new Promise((r) => setTimeout(r, 1000));
    
      // Pull the file to local disk
      const localPath = "/tmp/phantom-android-record.mp4";
      const adbPath = await findAdb();
      await execFileAsync(adbPath, buildArgs(["pull", "/sdcard/phantom-record.mp4", localPath]));
      await adb(["shell", "rm", "/sdcard/phantom-record.mp4"]).catch(() => {});
    
      return localPath;
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses the start/stop workflow and that stop retrieves a file. However, it does not mention potential side effects (e.g., performance impact, permission requirements) or behavior if actions are misused.

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

Conciseness5/5

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

The description is two sentences, both front-loaded and concise. The first sentence states the purpose, the second explains usage—no extraneous words.

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

Completeness4/5

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

For a simple tool with one parameter and no output schema, the description is fairly complete: it explains the workflow and the two actions. It could mention what file is returned or any limitations, but overall it is adequate.

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?

The input schema already has a description for the action parameter, and the description merely restates that information. With 100% schema coverage, the description adds no new semantic meaning beyond what the schema provides.

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

Purpose5/5

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

The description clearly states it records a video of the device screen, which is a specific verb and resource. This distinguishes it from sibling tools like screenshot or visual_diff, which capture images rather than videos.

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

Usage Guidelines4/5

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

The description explains the two-step process (start and stop) for using the tool, providing clear instructions. However, it does not mention when to use this tool versus alternatives like screenshot, nor does it specify any prerequisites or exclusions.

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/nthImpulse/phantom-mcp'

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