Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
- Match `@playwright/mcp` names, arguments and semantics wherever the operation is the same. `selenium_*` is only for
what Selenium alone can offer.
- The tool list is sent to the agent on every turn. Keep descriptions short; `test/unit/tools_test.js` enforces the
token budget and the exact tool set.
token budget and the exact tool set. The default list stays at 25 tools or fewer; opt-in groups (`--caps`,
`--allow-evaluate`) do not count toward that cap.
- Tools take refs, never selectors. Errors meant for the agent are `ToolError`s with a next step in the message
("Call browser_snapshot to get fresh refs").
- Actions return `actionResult(...)` so the agent gets a fresh snapshot without another call.
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ over.
| `browser_resize` | Resize the browser window. |
| `browser_tabs` | List, open, select or close tabs. |
| `browser_close` | Close the browser; the next call starts a new one. |
| `browser_install` | Have Selenium Manager install the browser and driver. |
| `browser_evaluate` | Run a JavaScript function on the page or a ref. Only with `--allow-evaluate`. |

Every action returns the page's URL, title and a fresh snapshot, so the agent rarely needs to ask for one.

### Optional tools

Each group is listed only when `--caps` names it, since every agent pays for every listed tool on every turn.
Each group is listed only when `--caps` names it, since every agent pays for every listed tool on every turn. The
default list stays at 25 tools or fewer; these groups and `browser_evaluate` are opt-in, so they do not count toward
that cap.

| Group | Tools |
| --------- | --------------------------------------------------------------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function createServer(config, deps = {}) {
session.reset()
return errorResult(
`Could not start ${config.browser}: ${firstLine(e.message)} ` +
'Run browser_install to let Selenium Manager fetch a matching browser and driver.',
`Check that ${config.browser} is installed where the browser runs.`,
)
}
log_.warning(`${name} failed: ${e.stack || e}`)
Expand Down
22 changes: 1 addition & 21 deletions lib/tools/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

'use strict'

const { ELEMENT, REF, ToolError, describePage, elementFor, onElement, textResult } = require('./common')
const { ELEMENT, REF, describePage, elementFor, onElement, textResult } = require('./common')

const tools = [
{
Expand Down Expand Up @@ -60,26 +60,6 @@ const tools = [
}
},
},
{
name: 'browser_install',
description: 'Install the configured browser and its driver, if missing',
inputSchema: { type: 'object', properties: {} },
async run(ctx) {
if (ctx.config.grid) throw new ToolError('The browser runs on the Grid; there is nothing to install locally.')
const { binaryPaths } = require('selenium-webdriver/common/seleniumManager')
let paths
try {
paths = binaryPaths(['--browser', ctx.config.browser, '--language-binding', 'javascript', '--output', 'json'])
} catch (e) {
throw new ToolError(`Selenium Manager could not set up ${ctx.config.browser}: ${e.message}`)
}
return textResult(
[`${ctx.config.browser} is ready.`, `- Browser: ${paths.browserPath}`, `- Driver: ${paths.driverPath}`].join(
'\n',
),
)
},
},
]

module.exports = { tools }
2 changes: 1 addition & 1 deletion test/e2e/tools_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('selenium-mcp tools', function () {

it('lists the tools without starting a browser', async function () {
const { tools } = await mcp.client.listTools()
assert.strictEqual(tools.length, 20)
assert.strictEqual(tools.length, 19)
assert.strictEqual(mcp.session.isOpen, false)
})

Expand Down
6 changes: 4 additions & 2 deletions test/unit/tools_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ const DEFAULT_TOOLS = [
'browser_handle_dialog',
'browser_tabs',
'browser_close',
'browser_install',
'browser_drag',
'browser_file_upload',
'browser_resize',
'browser_network_requests',
]

/** The plan's v1 gate: the default tool list stays at 25 or fewer. */
/**
* The v1 gate: the default tool list stays at 25 or fewer. Groups enabled with
* --caps and --allow-evaluate are opt-in, so they do not count against it.
*/
const MAX_DEFAULT_TOOLS = 25

/** Agents pay for the tool list on every turn; the plan caps it. */
Expand Down
Loading