Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mcp): say when device names need a permission, refuse GIF flags on an MP4

EtienneLescot454c9c8c417b
diff --git a/electron/cli/args.test.ts b/electron/cli/args.test.ts
index 3e694349b..d657f7a98 100644
--- a/electron/cli/args.test.ts
+++ b/electron/cli/args.test.ts
@@ -172,6 +172,10 @@ describe("parseCliArgs", () => {
expect(parse(["export", "a.openscreen", "--format", "gif", "--fps", "30"])).toMatchObject({
kind: "error",
});
+ expect(parse(["export", "a.openscreen", "-o", "a.mp4", "--no-gif-loop"])).toMatchObject({
+ kind: "error",
+ message: "--no-gif-loop is only supported for GIF exports",
+ });
});
it("parses --auto-zoom", () => {
diff --git a/electron/cli/args.ts b/electron/cli/args.ts
index aaf8d38ef..9b621b660 100644
--- a/electron/cli/args.ts
+++ b/electron/cli/args.ts
@@ -334,6 +334,13 @@ function parseExport(args: string[], cwd: string): CliCommand {
if (request.format === "gif" && args.includes("--fps")) {
throw new Error("--fps is only supported for MP4 exports (use --gif-fps)");
}
+ // And the GIF options, on an MP4 they would not change.
+ const gifFlag = ["--gif-fps", "--gif-size", "--gif-loop", "--no-gif-loop"].find((flag) =>
+ args.includes(flag),
+ );
+ if (request.format === "mp4" && gifFlag) {
+ throw new Error(`${gifFlag} is only supported for GIF exports`);
+ }
return request;
}
diff --git a/electron/mcp/media-tools.test.ts b/electron/mcp/media-tools.test.ts
index 8c418aeda..d1851efb1 100644
--- a/electron/mcp/media-tools.test.ts
+++ b/electron/mcp/media-tools.test.ts
@@ -327,7 +327,11 @@ describe("recording", () => {
},
};
const listed = JSON.parse(textOf(await call("listSources")));
- expect(listed).toMatchObject({ microphones: ["USB Mic"], cameras: ["Logitech BRIO"] });
+ expect(listed).toMatchObject({
+ microphones: ["USB Mic"],
+ cameras: ["Logitech BRIO"],
+ cameraLabelsUnavailable: false,
+ });
});
it("says where the take is when it cannot become a project", async () => {
diff --git a/electron/mcp/media-tools.ts b/electron/mcp/media-tools.ts
index 1feb7a82a..0d4bcc8a9 100644
--- a/electron/mcp/media-tools.ts
+++ b/electron/mcp/media-tools.ts
@@ -541,7 +541,7 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
server.registerTool(
"listSources",
{
- description: `List the displays and windows OpenScreen can record, the microphones and the cameras. Pass startRecording a display's index or part of a window's title, and part of a microphone's or a camera's name. ${HIDDEN_WINDOWS_NOTE}`,
+ description: `List the displays and windows OpenScreen can record, the microphones and the cameras. Pass startRecording a display's index or part of a window's title, and part of a microphone's or a camera's name. microphoneLabelsUnavailable or cameraLabelsUnavailable true means their names need a permission the user has not granted, so the list is empty: ask the user to allow it. ${HIDDEN_WINDOWS_NOTE}`,
inputSchema: z.object({}),
annotations: READ_ONLY,
},
@@ -557,6 +557,9 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
windows: windows.map((window) => window.name),
microphones: microphones.map((mic) => mic.label),
cameras: cameras.map((camera) => camera.label),
+ // An empty list is not "none" when the names need a permission: say which.
+ microphoneLabelsUnavailable: result.sources.microphoneLabelsUnavailable,
+ cameraLabelsUnavailable: result.sources.cameraLabelsUnavailable,
}),
);
},