From f4df37ca7139457835238379876fd2e389fa284c Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Sat, 29 Nov 2025 00:38:42 +0100 Subject: [PATCH] chore: generate config section from config.d.ts (#1224) --- README.md | 19 ++++++++++++++++++- update-readme.js | 28 +++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d38ac52..f50f20e 100644 --- a/README.md +++ b/README.md @@ -451,6 +451,8 @@ npx @playwright/mcp@latest --config path/to/config.json
Configuration file schema + + ```typescript { /** @@ -576,6 +578,18 @@ npx @playwright/mcp@latest --config path/to/config.json */ outputDir?: string; + network?: { + /** + * List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked. + */ + allowedOrigins?: string[]; + + /** + * List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked. + */ + blockedOrigins?: string[]; + }; + /** * Specify the attribute to use for test ids, defaults to "data-testid". */ @@ -597,8 +611,11 @@ npx @playwright/mcp@latest --config path/to/config.json * 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'; -}; +} ``` + + +
### Standalone MCP server diff --git a/update-readme.js b/update-readme.js index 4354e5c..37d5f6b 100644 --- a/update-readme.js +++ b/update-readme.js @@ -135,12 +135,38 @@ async function updateOptions(content) { ]); } +/** + * @param {string} content + * @returns {Promise} + */ +async function updateConfig(content) { + console.log('Updating config schema from config.d.ts...'); + const configPath = path.join(__dirname, 'config.d.ts'); + const configContent = await fs.promises.readFile(configPath, 'utf-8'); + + // Extract the Config type definition + const configTypeMatch = configContent.match(/export type Config = (\{[\s\S]*?\n\});/); + if (!configTypeMatch) + throw new Error('Config type not found in config.d.ts'); + + const configType = configTypeMatch[1]; // Use capture group to get just the object definition + + const startMarker = ``; + const endMarker = ``; + return updateSection(content, startMarker, endMarker, [ + '```typescript', + configType, + '```', + ]); +} + async function updateReadme() { const readmePath = path.join(__dirname, 'README.md'); const readmeContent = await fs.promises.readFile(readmePath, 'utf-8'); const withTools = await updateTools(readmeContent); const withOptions = await updateOptions(withTools); - await fs.promises.writeFile(readmePath, withOptions, 'utf-8'); + const withConfig = await updateConfig(withOptions); + await fs.promises.writeFile(readmePath, withConfig, 'utf-8'); console.log('README updated successfully'); }