web-agent-bridge 1.1.1 → 1.1.2
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.
- package/LICENSE +21 -21
- package/README.ar.md +446 -446
- package/README.md +844 -844
- package/bin/cli.js +80 -80
- package/bin/wab.js +80 -80
- package/docs/DEPLOY.md +118 -118
- package/docs/SPEC.md +1540 -1540
- package/examples/bidi-agent.js +119 -119
- package/examples/mcp-agent.js +94 -94
- package/examples/puppeteer-agent.js +108 -108
- package/examples/vision-agent.js +171 -171
- package/package.json +78 -78
- package/public/admin/dashboard.html +848 -848
- package/public/admin/login.html +84 -84
- package/public/cookies.html +208 -208
- package/public/css/styles.css +1235 -1235
- package/public/dashboard.html +704 -704
- package/public/docs.html +585 -585
- package/public/index.html +332 -332
- package/public/js/auth-nav.js +31 -31
- package/public/js/auth-redirect.js +12 -12
- package/public/js/cookie-consent.js +56 -56
- package/public/js/ws-client.js +74 -74
- package/public/login.html +83 -83
- package/public/privacy.html +295 -295
- package/public/register.html +103 -103
- package/public/terms.html +254 -254
- package/script/ai-agent-bridge.js +1513 -1513
- package/sdk/README.md +55 -55
- package/sdk/index.js +203 -203
- package/sdk/package.json +14 -14
- package/server/config/secrets.js +92 -92
- package/server/index.js +181 -181
- package/server/middleware/adminAuth.js +30 -30
- package/server/middleware/auth.js +41 -41
- package/server/middleware/rateLimits.js +24 -24
- package/server/migrations/001_add_analytics_indexes.sql +7 -7
- package/server/models/adapters/index.js +33 -33
- package/server/models/adapters/mysql.js +183 -183
- package/server/models/adapters/postgresql.js +172 -172
- package/server/models/adapters/sqlite.js +7 -7
- package/server/models/db.js +561 -561
- package/server/routes/admin.js +247 -247
- package/server/routes/api.js +138 -138
- package/server/routes/auth.js +51 -51
- package/server/routes/billing.js +45 -45
- package/server/routes/discovery.js +329 -329
- package/server/routes/license.js +240 -240
- package/server/routes/noscript.js +543 -543
- package/server/routes/wab-api.js +476 -476
- package/server/services/email.js +204 -204
- package/server/services/fairness.js +420 -420
- package/server/services/stripe.js +192 -192
- package/server/utils/cache.js +125 -125
- package/server/utils/migrate.js +81 -81
- package/server/utils/secureFields.js +50 -50
- package/server/ws.js +101 -101
- package/wab-mcp-adapter/README.md +136 -136
- package/wab-mcp-adapter/index.js +555 -555
- package/wab-mcp-adapter/package.json +17 -17
- package/public/css/premium.css +0 -317
- package/public/premium-dashboard.html +0 -2075
- package/public/premium.html +0 -791
- package/server/migrations/002_premium_features.sql +0 -418
- package/server/routes/premium.js +0 -724
- package/server/services/premium.js +0 -1680
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
# WAB-MCP Adapter
|
|
2
|
-
|
|
3
|
-
**MCP adapter for Web Agent Bridge** — exposes every capability of a WAB-enabled website as a set of [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) tools so that any MCP-compatible AI agent (Claude, GPT, Gemini, open-source LLMs, etc.) can discover, read, and interact with the site through a single, standardised interface.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
const { WABMCPAdapter } = require('wab-mcp-adapter');
|
|
9
|
-
|
|
10
|
-
const adapter = new WABMCPAdapter({
|
|
11
|
-
siteUrl: 'https://example.com',
|
|
12
|
-
transport: 'http', // 'http' | 'websocket' | 'direct'
|
|
13
|
-
apiKey: 'sk-optional', // optional API key
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// 1. Discover site capabilities
|
|
17
|
-
const doc = await adapter.discover();
|
|
18
|
-
|
|
19
|
-
// 2. Get MCP tool definitions for the AI agent
|
|
20
|
-
const tools = await adapter.getTools();
|
|
21
|
-
|
|
22
|
-
// 3. Execute a tool call
|
|
23
|
-
const result = await adapter.executeTool('wab_execute_action', {
|
|
24
|
-
name: 'signup',
|
|
25
|
-
params: { email: 'user@example.com' },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// 4. Clean up
|
|
29
|
-
adapter.close();
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## API Reference
|
|
33
|
-
|
|
34
|
-
### `new WABMCPAdapter(options)`
|
|
35
|
-
|
|
36
|
-
| Option | Type | Default | Description |
|
|
37
|
-
|---|---|---|---|
|
|
38
|
-
| `siteUrl` | `string` | — | Target WAB site URL (required for `http` transport) |
|
|
39
|
-
| `siteId` | `string` | `null` | WAB site identifier |
|
|
40
|
-
| `apiKey` | `string` | `null` | API key for authenticated requests |
|
|
41
|
-
| `transport` | `string` | `'http'` | Transport type: `http`, `websocket`, or `direct` |
|
|
42
|
-
| `registryUrl` | `string` | `https://webagentbridge.com` | WAB fairness registry URL |
|
|
43
|
-
| `page` | `object` | — | Puppeteer/Playwright page (required for `direct`) |
|
|
44
|
-
| `wsUrl` | `string` | auto | WebSocket URL (required for `websocket` if no `siteUrl`) |
|
|
45
|
-
| `timeout` | `number` | `15000` | Request timeout in milliseconds |
|
|
46
|
-
|
|
47
|
-
### Methods
|
|
48
|
-
|
|
49
|
-
| Method | Returns | Description |
|
|
50
|
-
|---|---|---|
|
|
51
|
-
| `discover(url?)` | `Promise<object>` | Fetch the WAB discovery document |
|
|
52
|
-
| `getTools()` | `Promise<object[]>` | Return MCP tool definitions (built-in + site-specific) |
|
|
53
|
-
| `executeTool(name, input)` | `Promise<object>` | Execute an MCP tool call |
|
|
54
|
-
| `close()` | `void` | Release transport resources |
|
|
55
|
-
|
|
56
|
-
## Built-in Tools
|
|
57
|
-
|
|
58
|
-
These tools are always available, regardless of which site actions are discovered:
|
|
59
|
-
|
|
60
|
-
| Tool | Description |
|
|
61
|
-
|---|---|
|
|
62
|
-
| `wab_discover` | Fetch the WAB discovery document from a site |
|
|
63
|
-
| `wab_get_actions` | List available actions, optionally filtered by category |
|
|
64
|
-
| `wab_execute_action` | Execute any WAB action by name and params |
|
|
65
|
-
| `wab_read_content` | Read page element text by CSS selector |
|
|
66
|
-
| `wab_get_page_info` | Return page metadata and bridge configuration |
|
|
67
|
-
| `wab_fairness_search` | Search the WAB registry with fairness-weighted results |
|
|
68
|
-
| `wab_authenticate` | Authenticate with the site using an API key |
|
|
69
|
-
|
|
70
|
-
Site-specific actions are exposed as additional tools named `wab_<action_name>` and are generated automatically from the discovery document.
|
|
71
|
-
|
|
72
|
-
## Transport Options
|
|
73
|
-
|
|
74
|
-
| Transport | When to use | Requirements |
|
|
75
|
-
|---|---|---|
|
|
76
|
-
| **http** | Server-to-server or CLI tools calling a WAB site over REST | `siteUrl` |
|
|
77
|
-
| **websocket** | Real-time bidirectional communication with low latency | `wsUrl` or `siteUrl` |
|
|
78
|
-
| **direct** | In-browser automation with Puppeteer/Playwright | `page` object |
|
|
79
|
-
|
|
80
|
-
## Fairness Protocol
|
|
81
|
-
|
|
82
|
-
The WAB discovery registry uses a **fairness-weighted ranking** algorithm that prevents large, high-traffic sites from monopolising search results. When you call `wab_fairness_search`, the registry applies:
|
|
83
|
-
|
|
84
|
-
- **Inverse-popularity weighting** — smaller sites receive a ranking boost.
|
|
85
|
-
- **Recency bonus** — newly registered or recently updated sites surface sooner.
|
|
86
|
-
- **Category balancing** — results are distributed across categories to avoid domination by a single vertical.
|
|
87
|
-
|
|
88
|
-
This ensures a level playing field so every WAB-enabled site has equitable visibility to AI agents.
|
|
89
|
-
|
|
90
|
-
## Integration with Claude / MCP
|
|
91
|
-
|
|
92
|
-
Pass the tools returned by `getTools()` as the `tools` parameter when calling the Anthropic Messages API and route any `tool_use` blocks back through `executeTool`:
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
const Anthropic = require('@anthropic-ai/sdk');
|
|
96
|
-
const { WABMCPAdapter } = require('wab-mcp-adapter');
|
|
97
|
-
|
|
98
|
-
const client = new Anthropic();
|
|
99
|
-
const adapter = new WABMCPAdapter({ siteUrl: 'https://shop.example.com' });
|
|
100
|
-
const tools = await adapter.getTools();
|
|
101
|
-
|
|
102
|
-
let messages = [{ role: 'user', content: 'Find the signup form and register me.' }];
|
|
103
|
-
|
|
104
|
-
while (true) {
|
|
105
|
-
const res = await client.messages.create({
|
|
106
|
-
model: 'claude-sonnet-4-20250514',
|
|
107
|
-
max_tokens: 1024,
|
|
108
|
-
tools,
|
|
109
|
-
messages,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
if (res.stop_reason === 'end_turn') break;
|
|
113
|
-
|
|
114
|
-
const toolBlocks = res.content.filter((b) => b.type === 'tool_use');
|
|
115
|
-
if (!toolBlocks.length) break;
|
|
116
|
-
|
|
117
|
-
messages.push({ role: 'assistant', content: res.content });
|
|
118
|
-
|
|
119
|
-
const toolResults = [];
|
|
120
|
-
for (const block of toolBlocks) {
|
|
121
|
-
const result = await adapter.executeTool(block.name, block.input);
|
|
122
|
-
toolResults.push({
|
|
123
|
-
type: 'tool_result',
|
|
124
|
-
tool_use_id: block.id,
|
|
125
|
-
content: JSON.stringify(result.content),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
messages.push({ role: 'user', content: toolResults });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
adapter.close();
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## License
|
|
135
|
-
|
|
136
|
-
MIT — see [LICENSE](../LICENSE).
|
|
1
|
+
# WAB-MCP Adapter
|
|
2
|
+
|
|
3
|
+
**MCP adapter for Web Agent Bridge** — exposes every capability of a WAB-enabled website as a set of [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) tools so that any MCP-compatible AI agent (Claude, GPT, Gemini, open-source LLMs, etc.) can discover, read, and interact with the site through a single, standardised interface.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
const { WABMCPAdapter } = require('wab-mcp-adapter');
|
|
9
|
+
|
|
10
|
+
const adapter = new WABMCPAdapter({
|
|
11
|
+
siteUrl: 'https://example.com',
|
|
12
|
+
transport: 'http', // 'http' | 'websocket' | 'direct'
|
|
13
|
+
apiKey: 'sk-optional', // optional API key
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// 1. Discover site capabilities
|
|
17
|
+
const doc = await adapter.discover();
|
|
18
|
+
|
|
19
|
+
// 2. Get MCP tool definitions for the AI agent
|
|
20
|
+
const tools = await adapter.getTools();
|
|
21
|
+
|
|
22
|
+
// 3. Execute a tool call
|
|
23
|
+
const result = await adapter.executeTool('wab_execute_action', {
|
|
24
|
+
name: 'signup',
|
|
25
|
+
params: { email: 'user@example.com' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 4. Clean up
|
|
29
|
+
adapter.close();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API Reference
|
|
33
|
+
|
|
34
|
+
### `new WABMCPAdapter(options)`
|
|
35
|
+
|
|
36
|
+
| Option | Type | Default | Description |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| `siteUrl` | `string` | — | Target WAB site URL (required for `http` transport) |
|
|
39
|
+
| `siteId` | `string` | `null` | WAB site identifier |
|
|
40
|
+
| `apiKey` | `string` | `null` | API key for authenticated requests |
|
|
41
|
+
| `transport` | `string` | `'http'` | Transport type: `http`, `websocket`, or `direct` |
|
|
42
|
+
| `registryUrl` | `string` | `https://webagentbridge.com` | WAB fairness registry URL |
|
|
43
|
+
| `page` | `object` | — | Puppeteer/Playwright page (required for `direct`) |
|
|
44
|
+
| `wsUrl` | `string` | auto | WebSocket URL (required for `websocket` if no `siteUrl`) |
|
|
45
|
+
| `timeout` | `number` | `15000` | Request timeout in milliseconds |
|
|
46
|
+
|
|
47
|
+
### Methods
|
|
48
|
+
|
|
49
|
+
| Method | Returns | Description |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `discover(url?)` | `Promise<object>` | Fetch the WAB discovery document |
|
|
52
|
+
| `getTools()` | `Promise<object[]>` | Return MCP tool definitions (built-in + site-specific) |
|
|
53
|
+
| `executeTool(name, input)` | `Promise<object>` | Execute an MCP tool call |
|
|
54
|
+
| `close()` | `void` | Release transport resources |
|
|
55
|
+
|
|
56
|
+
## Built-in Tools
|
|
57
|
+
|
|
58
|
+
These tools are always available, regardless of which site actions are discovered:
|
|
59
|
+
|
|
60
|
+
| Tool | Description |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `wab_discover` | Fetch the WAB discovery document from a site |
|
|
63
|
+
| `wab_get_actions` | List available actions, optionally filtered by category |
|
|
64
|
+
| `wab_execute_action` | Execute any WAB action by name and params |
|
|
65
|
+
| `wab_read_content` | Read page element text by CSS selector |
|
|
66
|
+
| `wab_get_page_info` | Return page metadata and bridge configuration |
|
|
67
|
+
| `wab_fairness_search` | Search the WAB registry with fairness-weighted results |
|
|
68
|
+
| `wab_authenticate` | Authenticate with the site using an API key |
|
|
69
|
+
|
|
70
|
+
Site-specific actions are exposed as additional tools named `wab_<action_name>` and are generated automatically from the discovery document.
|
|
71
|
+
|
|
72
|
+
## Transport Options
|
|
73
|
+
|
|
74
|
+
| Transport | When to use | Requirements |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| **http** | Server-to-server or CLI tools calling a WAB site over REST | `siteUrl` |
|
|
77
|
+
| **websocket** | Real-time bidirectional communication with low latency | `wsUrl` or `siteUrl` |
|
|
78
|
+
| **direct** | In-browser automation with Puppeteer/Playwright | `page` object |
|
|
79
|
+
|
|
80
|
+
## Fairness Protocol
|
|
81
|
+
|
|
82
|
+
The WAB discovery registry uses a **fairness-weighted ranking** algorithm that prevents large, high-traffic sites from monopolising search results. When you call `wab_fairness_search`, the registry applies:
|
|
83
|
+
|
|
84
|
+
- **Inverse-popularity weighting** — smaller sites receive a ranking boost.
|
|
85
|
+
- **Recency bonus** — newly registered or recently updated sites surface sooner.
|
|
86
|
+
- **Category balancing** — results are distributed across categories to avoid domination by a single vertical.
|
|
87
|
+
|
|
88
|
+
This ensures a level playing field so every WAB-enabled site has equitable visibility to AI agents.
|
|
89
|
+
|
|
90
|
+
## Integration with Claude / MCP
|
|
91
|
+
|
|
92
|
+
Pass the tools returned by `getTools()` as the `tools` parameter when calling the Anthropic Messages API and route any `tool_use` blocks back through `executeTool`:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
const Anthropic = require('@anthropic-ai/sdk');
|
|
96
|
+
const { WABMCPAdapter } = require('wab-mcp-adapter');
|
|
97
|
+
|
|
98
|
+
const client = new Anthropic();
|
|
99
|
+
const adapter = new WABMCPAdapter({ siteUrl: 'https://shop.example.com' });
|
|
100
|
+
const tools = await adapter.getTools();
|
|
101
|
+
|
|
102
|
+
let messages = [{ role: 'user', content: 'Find the signup form and register me.' }];
|
|
103
|
+
|
|
104
|
+
while (true) {
|
|
105
|
+
const res = await client.messages.create({
|
|
106
|
+
model: 'claude-sonnet-4-20250514',
|
|
107
|
+
max_tokens: 1024,
|
|
108
|
+
tools,
|
|
109
|
+
messages,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (res.stop_reason === 'end_turn') break;
|
|
113
|
+
|
|
114
|
+
const toolBlocks = res.content.filter((b) => b.type === 'tool_use');
|
|
115
|
+
if (!toolBlocks.length) break;
|
|
116
|
+
|
|
117
|
+
messages.push({ role: 'assistant', content: res.content });
|
|
118
|
+
|
|
119
|
+
const toolResults = [];
|
|
120
|
+
for (const block of toolBlocks) {
|
|
121
|
+
const result = await adapter.executeTool(block.name, block.input);
|
|
122
|
+
toolResults.push({
|
|
123
|
+
type: 'tool_result',
|
|
124
|
+
tool_use_id: block.id,
|
|
125
|
+
content: JSON.stringify(result.content),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
messages.push({ role: 'user', content: toolResults });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
adapter.close();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT — see [LICENSE](../LICENSE).
|