mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-26 08:32:26 +08:00
chore: remove image reply special case in cursor (#680)
This commit is contained in:
parent
e9f6433241
commit
95454735bf
10
README.md
10
README.md
@ -205,9 +205,7 @@ Playwright MCP server supports following arguments. They can be provided in the
|
|||||||
--isolated keep the browser profile in memory, do not save
|
--isolated keep the browser profile in memory, do not save
|
||||||
it to disk.
|
it to disk.
|
||||||
--image-responses <mode> whether to send image responses to the client.
|
--image-responses <mode> whether to send image responses to the client.
|
||||||
Can be "allow", "omit", or "auto". Defaults to
|
Can be "allow" or "omit", Defaults to "allow".
|
||||||
"auto", which sends images if the client can
|
|
||||||
display them.
|
|
||||||
--no-sandbox disable the sandbox for all process types that
|
--no-sandbox disable the sandbox for all process types that
|
||||||
are normally sandboxed.
|
are normally sandboxed.
|
||||||
--output-dir <path> path to the directory for output files.
|
--output-dir <path> path to the directory for output files.
|
||||||
@ -346,10 +344,10 @@ npx @playwright/mcp@latest --config path/to/config.json
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to send image responses to the client. Can be "allow", "omit", or "auto".
|
* Whether to send image responses to the client. Can be "allow" or "omit".
|
||||||
* Defaults to "auto", images are omitted for Cursor clients and sent for all other clients.
|
* Defaults to "allow".
|
||||||
*/
|
*/
|
||||||
imageResponses?: 'allow' | 'omit' | 'auto';
|
imageResponses?: 'allow' | 'omit';
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
2
config.d.ts
vendored
2
config.d.ts
vendored
@ -110,5 +110,5 @@ export type Config = {
|
|||||||
/**
|
/**
|
||||||
* Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
|
* Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
|
||||||
*/
|
*/
|
||||||
imageResponses?: 'allow' | 'omit' | 'auto';
|
imageResponses?: 'allow' | 'omit';
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ export type CLIOptions = {
|
|||||||
host?: string;
|
host?: string;
|
||||||
ignoreHttpsErrors?: boolean;
|
ignoreHttpsErrors?: boolean;
|
||||||
isolated?: boolean;
|
isolated?: boolean;
|
||||||
imageResponses?: 'allow' | 'omit' | 'auto';
|
imageResponses?: 'allow' | 'omit';
|
||||||
sandbox: boolean;
|
sandbox: boolean;
|
||||||
outputDir?: string;
|
outputDir?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
|
@ -52,11 +52,9 @@ export class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clientSupportsImages(): boolean {
|
clientSupportsImages(): boolean {
|
||||||
if (this.config.imageResponses === 'allow')
|
|
||||||
return true;
|
|
||||||
if (this.config.imageResponses === 'omit')
|
if (this.config.imageResponses === 'omit')
|
||||||
return false;
|
return false;
|
||||||
return !this.clientVersion?.name.includes('cursor');
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalStates(): ModalState[] {
|
modalStates(): ModalState[] {
|
||||||
|
@ -39,7 +39,7 @@ program
|
|||||||
.option('--host <host>', 'host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.')
|
.option('--host <host>', 'host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.')
|
||||||
.option('--ignore-https-errors', 'ignore https errors')
|
.option('--ignore-https-errors', 'ignore https errors')
|
||||||
.option('--isolated', 'keep the browser profile in memory, do not save it to disk.')
|
.option('--isolated', 'keep the browser profile in memory, do not save it to disk.')
|
||||||
.option('--image-responses <mode>', 'whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.')
|
.option('--image-responses <mode>', 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".')
|
||||||
.option('--no-sandbox', 'disable the sandbox for all process types that are normally sandboxed.')
|
.option('--no-sandbox', 'disable the sandbox for all process types that are normally sandboxed.')
|
||||||
.option('--output-dir <path>', 'path to the directory for output files.')
|
.option('--output-dir <path>', 'path to the directory for output files.')
|
||||||
.option('--port <port>', 'port to listen on for SSE transport.')
|
.option('--port <port>', 'port to listen on for SSE transport.')
|
||||||
|
@ -201,32 +201,3 @@ test('browser_take_screenshot (imageResponses=omit)', async ({ startClient, serv
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('browser_take_screenshot (cursor)', async ({ startClient, server }, testInfo) => {
|
|
||||||
const outputDir = testInfo.outputPath('output');
|
|
||||||
|
|
||||||
const { client } = await startClient({
|
|
||||||
clientName: 'cursor:vscode',
|
|
||||||
config: { outputDir },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await client.callTool({
|
|
||||||
name: 'browser_navigate',
|
|
||||||
arguments: { url: server.HELLO_WORLD },
|
|
||||||
})).toContainTextContent(`Navigate to http://localhost`);
|
|
||||||
|
|
||||||
await client.callTool({
|
|
||||||
name: 'browser_take_screenshot',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await client.callTool({
|
|
||||||
name: 'browser_take_screenshot',
|
|
||||||
})).toEqual({
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
text: expect.stringContaining(`Screenshot viewport and save it as`),
|
|
||||||
type: 'text',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user