豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit ca6635d

Browse files
authored
refactor: optimize slim tool descriptions and params (#1028)
Minor changes to shorten descriptions and improve ease of use. Note that `--slim` mode is not released yet and this is an improvement for it.
1 parent a106170 commit ca6635d

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

docs/slim-tool-reference.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
22

3-
# Chrome DevTools MCP Slim Tool Reference (~368 cl100k_base tokens)
3+
# Chrome DevTools MCP Slim Tool Reference (~359 cl100k_base tokens)
44

55
- **[Navigation automation](#navigation-automation)** (1 tools)
66
- [`navigate`](#navigate)
@@ -12,29 +12,29 @@
1212

1313
### `navigate`
1414

15-
**Description:** Load URL in the browser
15+
**Description:** Loads a URL
1616

1717
**Parameters:**
1818

19-
- **url** (string) **(required)**: Page URL
19+
- **url** (string) **(required)**: URL to [`navigate`](#navigate) to
2020

2121
---
2222

2323
## Debugging
2424

2525
### `evaluate`
2626

27-
**Description:** [`Evaluate`](#evaluate) a JavaScript function on the last loaded page
27+
**Description:** Evaluates a JavaScript script
2828

2929
**Parameters:**
3030

31-
- **fn** (string) **(required)**: A JavaScript function to be executed on the active page
31+
- **script** (string) **(required)**: JS script to run on the page
3232

3333
---
3434

3535
### `screenshot`
3636

37-
**Description:** Take a [`screenshot`](#screenshot) of the active page.
37+
**Description:** Takes a [`screenshot`](#screenshot)
3838

3939
**Parameters:** None
4040

src/tools/slim/tools.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {defineTool} from '../ToolDefinition.js';
1212

1313
export const screenshot = defineTool({
1414
name: 'screenshot',
15-
description: `Take a screenshot of the active page.`,
15+
description: `Takes a screenshot`,
1616
annotations: {
1717
category: ToolCategory.DEBUGGING,
1818
// Not read-only due to filePath param.
@@ -32,13 +32,13 @@ export const screenshot = defineTool({
3232

3333
export const navigate = defineTool({
3434
name: 'navigate',
35-
description: `Load URL in the browser`,
35+
description: `Loads a URL`,
3636
annotations: {
3737
category: ToolCategory.NAVIGATION,
3838
readOnlyHint: false,
3939
},
4040
schema: {
41-
url: zod.string().describe('Page URL'),
41+
url: zod.string().describe('URL to navigate to'),
4242
},
4343
handler: async (request, response, context) => {
4444
const page = context.getSelectedPage();
@@ -68,29 +68,21 @@ export const navigate = defineTool({
6868

6969
export const evaluate = defineTool({
7070
name: 'evaluate',
71-
description: `Evaluate a JavaScript function on the last loaded page`,
71+
description: `Evaluates a JavaScript script`,
7272
annotations: {
7373
category: ToolCategory.DEBUGGING,
7474
readOnlyHint: false,
7575
},
7676
schema: {
77-
fn: zod
78-
.string()
79-
.describe(`A JavaScript function to be executed on the active page`),
77+
script: zod.string().describe(`JS script to run on the page`),
8078
},
8179
handler: async (request, response, context) => {
8280
const page = context.getSelectedPage();
83-
const fn = await page.evaluateHandle(`(${request.params.fn})`);
8481
try {
85-
const result = await page.evaluate(async fn => {
86-
// @ts-expect-error no types.
87-
return JSON.stringify(await fn());
88-
}, fn);
89-
response.appendResponseLine(result);
82+
const result = await page.evaluate(request.params.script);
83+
response.appendResponseLine(JSON.stringify(result));
9084
} catch (err) {
9185
response.appendResponseLine(String(err.message));
92-
} finally {
93-
void fn.dispose();
9486
}
9587
},
9688
});

tests/tools/slim/tools.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ describe('slim', () => {
1717
it('evaluates', async t => {
1818
await withMcpContext(async (response, context) => {
1919
await evaluate.handler(
20-
{params: {fn: String(() => 2 * 5)}},
20+
{
21+
params: {
22+
script: `2 * 5`,
23+
},
24+
},
2125
response,
2226
context,
2327
);
@@ -30,9 +34,7 @@ describe('slim', () => {
3034
await evaluate.handler(
3135
{
3236
params: {
33-
fn: String(() => {
34-
throw new Error('test error');
35-
}),
37+
script: `throw new Error('test error')`,
3638
},
3739
},
3840
response,

0 commit comments

Comments
 (0)