@n8n/mcp-browser 0.1.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE.md +88 -0
  2. package/README.md +175 -0
  3. package/dist/adapters/playwright.d.ts +72 -0
  4. package/dist/adapters/playwright.js +684 -0
  5. package/dist/adapters/playwright.js.map +1 -0
  6. package/dist/browser-discovery.d.ts +12 -0
  7. package/dist/browser-discovery.js +219 -0
  8. package/dist/browser-discovery.js.map +1 -0
  9. package/dist/build.tsbuildinfo +1 -0
  10. package/dist/cdp-relay-protocol.d.ts +81 -0
  11. package/dist/cdp-relay-protocol.js +5 -0
  12. package/dist/cdp-relay-protocol.js.map +1 -0
  13. package/dist/cdp-relay.d.ts +52 -0
  14. package/dist/cdp-relay.js +508 -0
  15. package/dist/cdp-relay.js.map +1 -0
  16. package/dist/connection.d.ts +15 -0
  17. package/dist/connection.js +137 -0
  18. package/dist/connection.js.map +1 -0
  19. package/dist/errors.d.ts +40 -0
  20. package/dist/errors.js +83 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.js +12 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/logger.d.ts +10 -0
  26. package/dist/logger.js +88 -0
  27. package/dist/logger.js.map +1 -0
  28. package/dist/server-config.d.ts +7 -0
  29. package/dist/server-config.js +45 -0
  30. package/dist/server-config.js.map +1 -0
  31. package/dist/server.d.ts +2 -0
  32. package/dist/server.js +93 -0
  33. package/dist/server.js.map +1 -0
  34. package/dist/tools/helpers.d.ts +15 -0
  35. package/dist/tools/helpers.js +77 -0
  36. package/dist/tools/helpers.js.map +1 -0
  37. package/dist/tools/index.d.ts +2 -0
  38. package/dist/tools/index.js +25 -0
  39. package/dist/tools/index.js.map +1 -0
  40. package/dist/tools/inspection.d.ts +3 -0
  41. package/dist/tools/inspection.js +205 -0
  42. package/dist/tools/inspection.js.map +1 -0
  43. package/dist/tools/interaction.d.ts +3 -0
  44. package/dist/tools/interaction.js +211 -0
  45. package/dist/tools/interaction.js.map +1 -0
  46. package/dist/tools/navigation.d.ts +3 -0
  47. package/dist/tools/navigation.js +75 -0
  48. package/dist/tools/navigation.js.map +1 -0
  49. package/dist/tools/response-envelope.d.ts +13 -0
  50. package/dist/tools/response-envelope.js +92 -0
  51. package/dist/tools/response-envelope.js.map +1 -0
  52. package/dist/tools/schemas.d.ts +236 -0
  53. package/dist/tools/schemas.js +46 -0
  54. package/dist/tools/schemas.js.map +1 -0
  55. package/dist/tools/session.d.ts +3 -0
  56. package/dist/tools/session.js +81 -0
  57. package/dist/tools/session.js.map +1 -0
  58. package/dist/tools/state.d.ts +3 -0
  59. package/dist/tools/state.js +108 -0
  60. package/dist/tools/state.js.map +1 -0
  61. package/dist/tools/tabs.d.ts +3 -0
  62. package/dist/tools/tabs.js +121 -0
  63. package/dist/tools/tabs.js.map +1 -0
  64. package/dist/tools/wait.d.ts +3 -0
  65. package/dist/tools/wait.js +39 -0
  66. package/dist/tools/wait.js.map +1 -0
  67. package/dist/types.d.ts +170 -0
  68. package/dist/types.js +15 -0
  69. package/dist/types.js.map +1 -0
  70. package/dist/utils.d.ts +8 -0
  71. package/dist/utils.js +54 -0
  72. package/dist/utils.js.map +1 -0
  73. package/package.json +48 -0
package/LICENSE.md ADDED
@@ -0,0 +1,88 @@
1
+ # License
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - Content of branches other than the main branch (i.e. "master") are not licensed.
6
+ - Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under
7
+ the Sustainable Use License.
8
+ To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a
9
+ valid n8n Enterprise License specifically allowing you access to such source code files and as defined
10
+ in "LICENSE_EE.md".
11
+ - All third party components incorporated into the n8n Software are licensed under the original license
12
+ provided by the owner of the applicable component.
13
+ - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
14
+ License" as defined below.
15
+
16
+ ## Sustainable Use License
17
+
18
+ Version 1.0
19
+
20
+ ### Acceptance
21
+
22
+ By using the software, you agree to all of the terms and conditions below.
23
+
24
+ ### Copyright License
25
+
26
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
27
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
28
+ to the limitations below.
29
+
30
+ ### Limitations
31
+
32
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
33
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
34
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
35
+ the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
36
+
37
+ ### Patents
38
+
39
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
40
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
41
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
42
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
43
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
44
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
45
+ license ends immediately for work on behalf of your company.
46
+
47
+ ### Notices
48
+
49
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
50
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
51
+ stating that you have modified the software.
52
+
53
+ ### No Other Rights
54
+
55
+ These terms do not imply any licenses other than those expressly granted in these terms.
56
+
57
+ ### Termination
58
+
59
+ If you use the software in violation of these terms, such use is not licensed, and your license will
60
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
61
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
62
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
63
+ terms will cause your license to terminate automatically and permanently.
64
+
65
+ ### No Liability
66
+
67
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
68
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
69
+ any kind of legal claim.
70
+
71
+ ### Definitions
72
+
73
+ The “licensor” is the entity offering these terms.
74
+
75
+ The “software” is the software the licensor makes available under these terms, including any portion of it.
76
+
77
+ “You” refers to the individual or entity agreeing to these terms.
78
+
79
+ “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
80
+ all organizations that have control over, are under the control of, or are under common control with that
81
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
82
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
83
+
84
+ “Your license” is the license granted to you for the software under these terms.
85
+
86
+ “Use” means anything you do with the software requiring your license.
87
+
88
+ “Trademark” means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @n8n/mcp-browser
2
+
3
+ MCP server that gives AI agents full control over Chrome. Connects to the
4
+ user's real installed browser via the **n8n AI Browser Bridge** extension, using
5
+ their actual profile, cookies, and sessions. Action tools return an
6
+ accessibility snapshot with every response for single-roundtrip interaction.
7
+
8
+ See [spec/browser-mcp.md](spec/browser-mcp.md) for the full feature spec and
9
+ [spec/technical-spec.md](spec/technical-spec.md) for the technical design.
10
+
11
+ ## Usage
12
+
13
+ ### Library mode
14
+
15
+ ```typescript
16
+ import { createBrowserTools } from '@n8n/mcp-browser';
17
+
18
+ const { tools, connection } = createBrowserTools({
19
+ defaultBrowser: 'chrome',
20
+ headless: false,
21
+ viewport: { width: 1280, height: 720 },
22
+ });
23
+
24
+ // Register tools on any MCP server
25
+ for (const tool of tools) {
26
+ server.tool(tool.name, tool.description, tool.inputSchema, tool.execute);
27
+ }
28
+
29
+ // Cleanup on shutdown
30
+ process.on('SIGTERM', () => connection.shutdown());
31
+ ```
32
+
33
+ ### Standalone mode
34
+
35
+ ```bash
36
+ # HTTP transport (default)
37
+ npx @n8n/mcp-browser --browser chrome --transport http --port 3100
38
+
39
+ # stdio transport
40
+ npx @n8n/mcp-browser --browser chrome --transport stdio
41
+ ```
42
+
43
+ ### CLI flags
44
+
45
+ | Flag | Alias | Env var | Default | Description |
46
+ |------|-------|---------|---------|-------------|
47
+ | `--browser` | `-b` | `N8N_MCP_BROWSER_DEFAULT_BROWSER` | `chrome` | Default browser |
48
+ | `--headless` | | `N8N_MCP_BROWSER_HEADLESS` | `false` | Headless mode |
49
+ | `--viewport` | | `N8N_MCP_BROWSER_VIEWPORT` | `1280x720` | Viewport (WxH) |
50
+ | `--transport` | `-t` | `N8N_MCP_BROWSER_TRANSPORT` | `http` | `http` or `stdio` |
51
+ | `--port` | `-p` | `N8N_MCP_BROWSER_PORT` | `3100` | HTTP port |
52
+
53
+ CLI flags take precedence over environment variables.
54
+
55
+ ## Prerequisites
56
+
57
+ 1. **Chrome** (or Brave/Edge) installed
58
+ 2. **n8n AI Browser Bridge** extension loaded in Chrome:
59
+ - Open `chrome://extensions`
60
+ - Enable Developer mode
61
+ - Click "Load unpacked" and select the `mcp-browser-extension` directory
62
+
63
+ ## Testing with AI clients
64
+
65
+ Start the server:
66
+
67
+ ```bash
68
+ npx @n8n/mcp-browser --transport http --port 3100
69
+ ```
70
+
71
+ Or from the monorepo:
72
+
73
+ ```bash
74
+ npx tsx packages/@n8n/mcp-browser/src/server.ts --transport http --port 3100
75
+ ```
76
+
77
+ Then point your client at `http://localhost:3100/mcp`:
78
+
79
+ <details>
80
+ <summary>Claude Desktop</summary>
81
+
82
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`
83
+ (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "n8n-browser": {
89
+ "url": "http://localhost:3100/mcp"
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ </details>
96
+
97
+ <details>
98
+ <summary>Claude Code</summary>
99
+
100
+ Add to `.mcp.json` in your project root (per-project) or
101
+ `~/.claude/mcp.json` (global):
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "n8n-browser": {
107
+ "url": "http://localhost:3100/mcp"
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ Or add interactively with `/mcp add`.
114
+
115
+ </details>
116
+
117
+ <details>
118
+ <summary>Cursor</summary>
119
+
120
+ Add to `.cursor/mcp.json` in your project root:
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "n8n-browser": {
126
+ "url": "http://localhost:3100/mcp"
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ </details>
133
+
134
+ <details>
135
+ <summary>Windsurf</summary>
136
+
137
+ Add to `~/.codeium/windsurf/mcp_config.json`:
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "n8n-browser": {
143
+ "url": "http://localhost:3100/mcp"
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ </details>
150
+
151
+ <details>
152
+ <summary>VS Code (GitHub Copilot)</summary>
153
+
154
+ Add to `.vscode/mcp.json` in your project root. Note: VS Code uses `"servers"`
155
+ instead of `"mcpServers"`.
156
+
157
+ ```json
158
+ {
159
+ "servers": {
160
+ "n8n-browser": {
161
+ "url": "http://localhost:3100/mcp"
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ </details>
168
+
169
+ ## Development
170
+
171
+ ```bash
172
+ pnpm dev # start standalone MCP server with hot reload
173
+ pnpm build # build for production
174
+ pnpm test # run tests
175
+ ```
@@ -0,0 +1,72 @@
1
+ import type { ClickOptions, ConnectConfig, ConsoleEntry, Cookie, ElementTarget, ModalState, NavigateResult, NetworkEntry, PageInfo, ResolvedConfig, ScreenshotOptions, ScrollOptions, SnapshotResult, TypeOptions, WaitOptions } from '../types';
2
+ export declare class PlaywrightAdapter {
3
+ readonly name = "playwright";
4
+ private resolvedConfig;
5
+ private browser?;
6
+ private context?;
7
+ private pageStates;
8
+ private relay?;
9
+ private pendingActivation?;
10
+ constructor(config: ResolvedConfig);
11
+ launch(config: ConnectConfig): Promise<void>;
12
+ close(): Promise<void>;
13
+ newPage(url?: string): Promise<PageInfo>;
14
+ closePage(pageId: string): Promise<void>;
15
+ focusPage(pageId: string): Promise<void>;
16
+ listPages(): Promise<PageInfo[]>;
17
+ listTabs(): Promise<PageInfo[]>;
18
+ listTabSessionIds(): string[];
19
+ listTabIds(): Promise<string[]>;
20
+ navigate(pageId: string, url: string, waitUntil?: 'load' | 'domcontentloaded' | 'networkidle'): Promise<NavigateResult>;
21
+ back(pageId: string): Promise<NavigateResult>;
22
+ forward(pageId: string): Promise<NavigateResult>;
23
+ reload(pageId: string, waitUntil?: 'load' | 'domcontentloaded' | 'networkidle'): Promise<NavigateResult>;
24
+ click(pageId: string, target: ElementTarget, options?: ClickOptions): Promise<void>;
25
+ type(pageId: string, target: ElementTarget, text: string, options?: TypeOptions): Promise<void>;
26
+ select(pageId: string, target: ElementTarget, values: string[]): Promise<string[]>;
27
+ hover(pageId: string, target: ElementTarget): Promise<void>;
28
+ press(pageId: string, keys: string): Promise<void>;
29
+ drag(pageId: string, from: ElementTarget, to: ElementTarget): Promise<void>;
30
+ scroll(pageId: string, target?: ElementTarget, options?: ScrollOptions): Promise<void>;
31
+ upload(pageId: string, target: ElementTarget | undefined, files: string[]): Promise<void>;
32
+ dialog(pageId: string, action: 'accept' | 'dismiss', text?: string): Promise<string>;
33
+ screenshot(pageId: string, target?: ElementTarget, options?: ScreenshotOptions): Promise<string>;
34
+ snapshot(pageId: string, target?: ElementTarget): Promise<SnapshotResult>;
35
+ getText(pageId: string, target?: ElementTarget): Promise<string>;
36
+ evaluate(pageId: string, script: string): Promise<unknown>;
37
+ getConsole(pageId: string, level?: string, clear?: boolean): Promise<ConsoleEntry[]>;
38
+ getConsoleSummary(pageId: string): {
39
+ errors: number;
40
+ warnings: number;
41
+ };
42
+ pdf(pageId: string, options?: {
43
+ format?: string;
44
+ landscape?: boolean;
45
+ }): Promise<{
46
+ data: string;
47
+ pages: number;
48
+ }>;
49
+ getNetwork(pageId: string, filter?: string, clear?: boolean): Promise<NetworkEntry[]>;
50
+ wait(pageId: string, options: WaitOptions): Promise<number>;
51
+ getCookies(pageId: string, url?: string): Promise<Cookie[]>;
52
+ setCookies(pageId: string, cookies: Cookie[]): Promise<void>;
53
+ clearCookies(pageId: string): Promise<void>;
54
+ getStorage(pageId: string, kind: 'local' | 'session'): Promise<Record<string, string>>;
55
+ setStorage(pageId: string, kind: 'local' | 'session', data: Record<string, string>): Promise<void>;
56
+ clearStorage(pageId: string, kind: 'local' | 'session'): Promise<void>;
57
+ waitForCompletion<T>(pageId: string, action: () => Promise<T>): Promise<T>;
58
+ getModalStates(pageId: string): ModalState[];
59
+ getContent(pageId: string, selector?: string): Promise<{
60
+ html: string;
61
+ url: string;
62
+ }>;
63
+ resolveRef(pageId: string, ref: string): Promise<unknown>;
64
+ private requireContext;
65
+ private requirePage;
66
+ private ensurePage;
67
+ private findPageState;
68
+ private trackPage;
69
+ getPageUrl(pageId: string): string | undefined;
70
+ private resolveLocator;
71
+ private globToRegex;
72
+ }