Skip to content

Commit 273d778

Browse files
feat: refactor context system and integrate all tools
- Replace context.ts with playwright-mcp version while preserving session manager - Add config.ts and browserContextFactory.ts for session integration - Convert assert.ts to new tool format - Add all tools to auto.ts (25 tools total): console, dialogs, files, keyboard, network, tabs, testing, wait, common - Maintain backward compatibility with existing auto-browse-ts functionality - Remove old browser_* tool files and replace with new modular tool structure - Move session-manager.ts to src/ root for better organization
1 parent ff62593 commit 273d778

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2709
-1379
lines changed

config.d.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type * as playwright from 'playwright';
18+
19+
export type ToolCapability = 'core' | 'tabs' | 'pdf' | 'history' | 'wait' | 'files' | 'install' | 'testing';
20+
21+
export type Config = {
22+
/**
23+
* The browser to use.
24+
*/
25+
browser?: {
26+
/**
27+
* Use browser agent (experimental).
28+
*/
29+
browserAgent?: string;
30+
31+
/**
32+
* The type of browser to use.
33+
*/
34+
browserName?: 'chromium' | 'firefox' | 'webkit';
35+
36+
/**
37+
* Keep the browser profile in memory, do not save it to disk.
38+
*/
39+
isolated?: boolean;
40+
41+
/**
42+
* Path to a user data directory for browser profile persistence.
43+
* Temporary directory is created by default.
44+
*/
45+
userDataDir?: string;
46+
47+
/**
48+
* Launch options passed to
49+
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
50+
*
51+
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
52+
*/
53+
launchOptions?: playwright.LaunchOptions;
54+
55+
/**
56+
* Context options for the browser context.
57+
*
58+
* This is useful for settings options like `viewport`.
59+
*/
60+
contextOptions?: playwright.BrowserContextOptions;
61+
62+
/**
63+
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
64+
*/
65+
cdpEndpoint?: string;
66+
67+
/**
68+
* Remote endpoint to connect to an existing Playwright server.
69+
*/
70+
remoteEndpoint?: string;
71+
},
72+
73+
server?: {
74+
/**
75+
* The port to listen on for SSE or MCP transport.
76+
*/
77+
port?: number;
78+
79+
/**
80+
* The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
81+
*/
82+
host?: string;
83+
},
84+
85+
/**
86+
* List of enabled tool capabilities. Possible values:
87+
* - 'core': Core browser automation features.
88+
* - 'tabs': Tab management features.
89+
* - 'pdf': PDF generation and manipulation.
90+
* - 'history': Browser history access.
91+
* - 'wait': Wait and timing utilities.
92+
* - 'files': File upload/download support.
93+
* - 'install': Browser installation utilities.
94+
*/
95+
capabilities?: ToolCapability[];
96+
97+
/**
98+
* Run server that uses screenshots (Aria snapshots are used by default).
99+
*/
100+
vision?: boolean;
101+
102+
/**
103+
* Whether to save the Playwright trace of the session into the output directory.
104+
*/
105+
saveTrace?: boolean;
106+
107+
/**
108+
* The directory to save output files.
109+
*/
110+
outputDir?: string;
111+
112+
network?: {
113+
/**
114+
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
115+
*/
116+
allowedOrigins?: string[];
117+
118+
/**
119+
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
120+
*/
121+
blockedOrigins?: string[];
122+
};
123+
124+
/**
125+
* 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.
126+
*/
127+
imageResponses?: 'allow' | 'omit' | 'auto';
128+
};

0 commit comments

Comments
 (0)