vite-plugin-aipanel 1.2.8 → 1.2.10

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 (58) hide show
  1. package/es/core/chrome-project.d.ts +15 -0
  2. package/es/core/chrome-project.mjs +13 -0
  3. package/es/core/mcp-chrome.d.ts +12 -8
  4. package/es/core/mcp-chrome.mjs +52 -10
  5. package/es/core/mcp-proxy.d.ts +21 -1
  6. package/es/core/mcp-proxy.mjs +83 -12
  7. package/es/core/mcp-tools.d.ts +51 -3
  8. package/es/core/mcp-tools.mjs +109 -659
  9. package/es/core/official-meta.d.ts +9 -0
  10. package/es/core/official-meta.mjs +62 -0
  11. package/es/core/official-tools.d.ts +7 -0
  12. package/es/core/official-tools.mjs +54 -0
  13. package/es/core/proxy-server.mjs +16 -13
  14. package/es/core/service.mjs +4 -5
  15. package/es/endpoints/context.mjs +2 -2
  16. package/es/endpoints/host-events.mjs +1 -2
  17. package/es/endpoints/index.d.ts +2 -2
  18. package/es/endpoints/index.mjs +2 -2
  19. package/es/endpoints/mcp.d.ts +2 -2
  20. package/es/endpoints/mcp.mjs +116 -87
  21. package/es/endpoints/sse.mjs +3 -3
  22. package/es/endpoints/vue-devtools.d.ts +5 -2
  23. package/es/endpoints/vue-devtools.mjs +3 -4
  24. package/es/index.mjs +29 -6
  25. package/lib/client.js +2380 -2369
  26. package/lib/core/chrome-project.cjs +36 -0
  27. package/lib/core/chrome-project.d.ts +15 -0
  28. package/lib/core/mcp-chrome.cjs +64 -10
  29. package/lib/core/mcp-chrome.d.ts +12 -8
  30. package/lib/core/mcp-proxy.cjs +87 -13
  31. package/lib/core/mcp-proxy.d.ts +21 -1
  32. package/lib/core/mcp-tools.cjs +124 -660
  33. package/lib/core/mcp-tools.d.ts +51 -3
  34. package/lib/core/official-meta.cjs +85 -0
  35. package/lib/core/official-meta.d.ts +9 -0
  36. package/lib/core/official-tools.cjs +70 -0
  37. package/lib/core/official-tools.d.ts +7 -0
  38. package/lib/core/proxy-server.cjs +16 -13
  39. package/lib/core/service.cjs +4 -5
  40. package/lib/endpoints/context.cjs +1 -1
  41. package/lib/endpoints/host-events.cjs +0 -1
  42. package/lib/endpoints/index.cjs +2 -2
  43. package/lib/endpoints/index.d.ts +2 -2
  44. package/lib/endpoints/mcp.cjs +114 -85
  45. package/lib/endpoints/mcp.d.ts +2 -2
  46. package/lib/endpoints/sse.cjs +2 -2
  47. package/lib/endpoints/vue-devtools.cjs +4 -5
  48. package/lib/endpoints/vue-devtools.d.ts +5 -2
  49. package/lib/index.cjs +29 -7
  50. package/package.json +10 -7
  51. package/es/utils/format-bridge.d.ts +0 -9
  52. package/es/utils/format-bridge.mjs +0 -80
  53. package/es/utils/system.d.ts +0 -3
  54. package/es/utils/system.mjs +0 -76
  55. package/lib/utils/format-bridge.cjs +0 -102
  56. package/lib/utils/format-bridge.d.ts +0 -9
  57. package/lib/utils/system.cjs +0 -110
  58. package/lib/utils/system.d.ts +0 -3
@@ -1,671 +1,121 @@
1
+ import { OFFICIAL_TOOL_META } from "./official-meta.mjs";
2
+ const MCP_PREFIX = "chrome-devtools_";
3
+ function displayToolName(short) {
4
+ return MCP_PREFIX + short;
5
+ }
6
+ const OFFICIAL_GLOBAL_POLICY = [
7
+ "evaluate_script",
8
+ "list_console_messages",
9
+ "list_pages",
10
+ "new_page"
11
+ ];
12
+ const OFFICIAL_NO_PAGE_TOOLS = /* @__PURE__ */ new Set(["list_pages", "new_page"]);
1
13
  const PAGE_ID_PROP = {
2
- pageId: { type: "number", description: "\u76EE\u6807\u9875\u9762 ID" }
14
+ pageId: {
15
+ type: "number",
16
+ description: "The ID of a page within the operation scope (project pages or chromeMcp.project.allowOrigins pages) to operate on"
17
+ }
3
18
  };
4
- function withPageId(properties, required = []) {
19
+ function withPageIdSchema(schema) {
5
20
  return {
6
- properties: { ...PAGE_ID_PROP, ...properties },
7
- required: ["pageId", ...required]
21
+ type: "object",
22
+ properties: { ...PAGE_ID_PROP, ...schema.properties },
23
+ required: ["pageId", ...schema.required ?? []]
8
24
  };
9
25
  }
26
+ const PROJECT_DESCRIPTION_NOTES = {
27
+ list_pages: "Lists pages within the operation scope (project pages + chromeMcp.project.allowOrigins).",
28
+ new_page: "Only URLs within the operation scope (project or allowOrigins) can be opened. Opening a project page is de-duplicated (returns the already-open page); allowOrigins pages are opened without a count limit.",
29
+ navigate_page: "Navigation target (type=url) must stay within the operation scope (project or allowOrigins)."
30
+ };
10
31
  const CUSTOM_TOOLS = [
11
- // ===== 页面管理 =====
12
- {
13
- name: "chrome-devtools_list_pages",
14
- description: "\u83B7\u53D6\u5F53\u524D\u9879\u76EE\u6240\u6709\u6253\u5F00\u7684\u9875\u9762\u5217\u8868\uFF0C\u542B active\uFF08\u7528\u6237\u6B63\u5728\u6D4F\u89C8\uFF09\u548C selected\uFF08Chrome DevTools \u5F53\u524D\u64CD\u4F5C\u76EE\u6807\uFF09\u6807\u8BB0",
15
- inputSchema: {
16
- type: "object",
17
- properties: {}
18
- }
19
- },
20
- {
21
- name: "chrome-devtools_current_page",
22
- description: "\u83B7\u53D6\u7528\u6237\u5F53\u524D\u6B63\u5728\u6D4F\u89C8\u5668\u6D4F\u89C8\u7684\u9875\u9762\u4E0A\u4E0B\u6587\u4FE1\u606F\uFF0C\u5305\u542B\u9875\u9762 URL\u3001\u6807\u9898\u3001\u9875\u9762 ID",
23
- inputSchema: {
24
- type: "object",
25
- properties: {}
26
- }
27
- },
28
- {
29
- name: "chrome-devtools_new_page",
30
- description: "\u6253\u5F00\u4E00\u4E2A\u65B0\u6807\u7B7E\u9875\u5E76\u52A0\u8F7D URL\uFF08\u4EC5\u5141\u8BB8\u6253\u5F00\u5F53\u524D\u9879\u76EE\u7684\u9875\u9762\uFF09\u3002\u82E5\u5F53\u524D\u9879\u76EE\u5DF2\u6709\u6253\u5F00\u7684\u9875\u9762\uFF0C\u5219\u4E0D\u4F1A\u91CD\u590D\u6253\u5F00\uFF0C\u800C\u662F\u8FD4\u56DE\u5DF2\u6709\u9875\u9762\u4FE1\u606F",
31
- inputSchema: {
32
- type: "object",
33
- properties: {
34
- url: {
35
- type: "string",
36
- description: "\u8981\u6253\u5F00\u7684\u9875\u9762 URL\uFF08\u5FC5\u987B\u662F\u5F53\u524D\u9879\u76EE\u7684\u9875\u9762\uFF09"
37
- },
38
- timeout: {
39
- type: "integer",
40
- description: "\u6700\u5927\u7B49\u5F85\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4F7F\u7528\u9ED8\u8BA4\u8D85\u65F6"
41
- }
42
- },
43
- required: ["url"]
44
- }
45
- },
46
- // ===== 截图与快照 =====
47
- {
48
- name: "chrome-devtools_take_snapshot",
49
- description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u53EF\u8BBF\u95EE\u6027\u6811\u5FEB\u7167\uFF0C\u8FD4\u56DE\u5143\u7D20 uid\u3001\u89D2\u8272\u3001\u6587\u672C\u7B49",
50
- inputSchema: {
51
- type: "object",
52
- ...withPageId({
53
- verbose: { type: "boolean", description: "\u662F\u5426\u83B7\u53D6\u5B8C\u6574 a11y \u6811\u4FE1\u606F\uFF0C\u9ED8\u8BA4 false" },
54
- filePath: { type: "string", description: "\u4FDD\u5B58\u5FEB\u7167\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u7701\u7565\u5219\u5185\u8054\u8FD4\u56DE" }
55
- })
56
- }
57
- },
58
- {
59
- name: "chrome-devtools_take_screenshot",
60
- description: "\u622A\u53D6\u6307\u5B9A\u9875\u9762\u6216\u5143\u7D20\u5C4F\u5E55\u622A\u56FE\uFF0C\u8FD4\u56DE base64 \u6216\u4FDD\u5B58\u5230\u6587\u4EF6",
61
- inputSchema: {
62
- type: "object",
63
- ...withPageId({
64
- format: {
65
- type: "string",
66
- enum: ["png", "jpeg", "webp"],
67
- description: "\u56FE\u7247\u683C\u5F0F\uFF0C\u9ED8\u8BA4 png"
68
- },
69
- quality: {
70
- type: "number",
71
- minimum: 0,
72
- maximum: 100,
73
- description: "JPEG/WebP \u538B\u7F29\u8D28\u91CF 0-100"
74
- },
75
- uid: {
76
- type: "string",
77
- description: "\u5143\u7D20 uid\uFF08\u4ECE chrome-devtools_take_snapshot \u83B7\u53D6\uFF09\uFF0C\u7701\u7565\u622A\u53D6\u6574\u9875"
78
- },
79
- fullPage: { type: "boolean", description: "\u662F\u5426\u622A\u53D6\u5B8C\u6574\u9875\u9762\uFF08\u4E0E uid \u4E92\u65A5\uFF09" },
80
- filePath: { type: "string", description: "\u4FDD\u5B58\u622A\u56FE\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u7701\u7565\u8FD4\u56DE base64" }
81
- })
82
- }
83
- },
84
- // ===== 交互操作 =====
85
- {
86
- name: "chrome-devtools_click",
87
- description: "\u70B9\u51FB\u9875\u9762\u5143\u7D20",
88
- inputSchema: {
89
- type: "object",
90
- ...withPageId(
91
- {
92
- uid: { type: "string", description: "\u5143\u7D20 uid\uFF08\u4ECE chrome-devtools_take_snapshot \u83B7\u53D6\uFF09" },
93
- dblClick: { type: "boolean", description: "\u662F\u5426\u53CC\u51FB\uFF0C\u9ED8\u8BA4 false" },
94
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
95
- },
96
- ["uid"]
97
- )
98
- }
99
- },
100
- {
101
- name: "chrome-devtools_hover",
102
- description: "\u9F20\u6807\u60AC\u505C\u5728\u9875\u9762\u5143\u7D20\u4E0A",
103
- inputSchema: {
104
- type: "object",
105
- ...withPageId(
106
- {
107
- uid: { type: "string", description: "\u5143\u7D20 uid" },
108
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
109
- },
110
- ["uid"]
111
- )
112
- }
113
- },
114
- {
115
- name: "chrome-devtools_drag",
116
- description: "\u62D6\u62FD\u9875\u9762\u5143\u7D20\u5230\u53E6\u4E00\u4E2A\u5143\u7D20\u4E0A",
117
- inputSchema: {
118
- type: "object",
119
- ...withPageId(
120
- {
121
- from_uid: { type: "string", description: "\u88AB\u62D6\u62FD\u5143\u7D20\u7684 uid" },
122
- to_uid: { type: "string", description: "\u76EE\u6807\u653E\u7F6E\u5143\u7D20\u7684 uid" },
123
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
124
- },
125
- ["from_uid", "to_uid"]
126
- )
127
- }
128
- },
129
- {
130
- name: "chrome-devtools_type_text",
131
- description: "\u5728\u5DF2\u805A\u7126\u7684\u8F93\u5165\u6846\u4E2D\u4F7F\u7528\u952E\u76D8\u8F93\u5165\u6587\u672C",
132
- inputSchema: {
133
- type: "object",
134
- ...withPageId(
135
- {
136
- text: { type: "string", description: "\u8981\u8F93\u5165\u7684\u6587\u672C" },
137
- submitKey: {
138
- type: "string",
139
- description: '\u8F93\u5165\u540E\u6309\u4E0B\u7684\u6309\u952E\uFF0C\u5982 "Enter"\u3001"Tab"\u3001"Escape"'
140
- }
141
- },
142
- ["text"]
143
- )
144
- }
145
- },
146
- {
147
- name: "chrome-devtools_press_key",
148
- description: "\u6309\u4E0B\u952E\u76D8\u6309\u952E\u6216\u7EC4\u5408\u952E\uFF08\u5FEB\u6377\u952E\u3001\u5BFC\u822A\u952E\u7B49\uFF09",
149
- inputSchema: {
150
- type: "object",
151
- ...withPageId(
152
- {
153
- key: {
154
- type: "string",
155
- description: '\u6309\u952E\u6216\u7EC4\u5408\u952E\uFF0C\u5982 "Enter"\u3001"Control+A"\u3002\u4FEE\u9970\u952E: Control, Shift, Alt, Meta'
156
- },
157
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
158
- },
159
- ["key"]
160
- )
161
- }
162
- },
163
- {
164
- name: "chrome-devtools_fill",
165
- description: "\u586B\u5199\u8F93\u5165\u6846\u503C\u6216\u9009\u62E9 select \u9009\u9879\uFF0C\u89E6\u53D1 input/change \u4E8B\u4EF6",
166
- inputSchema: {
167
- type: "object",
168
- ...withPageId(
169
- {
170
- uid: { type: "string", description: "\u8F93\u5165\u6846/select \u5143\u7D20 uid" },
171
- value: {
172
- type: "string",
173
- description: '\u8981\u586B\u5165\u7684\u503C\u3002checkbox/toggle \u7528 "true"/"false"\uFF0Cradio \u7528 "true"'
174
- },
175
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
176
- },
177
- ["uid", "value"]
178
- )
179
- }
180
- },
181
- {
182
- name: "chrome-devtools_fill_form",
183
- description: "\u6279\u91CF\u586B\u5199\u8868\u5355\u5B57\u6BB5\uFF0C\u6BD4\u591A\u6B21\u8C03\u7528 fill/click \u66F4\u5FEB\u66F4\u53EF\u9760",
184
- inputSchema: {
185
- type: "object",
186
- ...withPageId(
187
- {
188
- elements: {
189
- type: "array",
190
- items: {
191
- type: "object",
192
- properties: { uid: { type: "string" }, value: { type: "string" } }
193
- },
194
- description: "\u8868\u5355\u5143\u7D20\u6570\u7EC4 [{ uid, value }]"
195
- },
196
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
197
- },
198
- ["elements"]
199
- )
200
- }
201
- },
202
- // ===== 页面导航 =====
203
- {
204
- name: "chrome-devtools_navigate_page",
205
- description: "\u5BFC\u822A\u9875\u9762\uFF08url/reload/back/forward\uFF09",
206
- inputSchema: {
207
- type: "object",
208
- ...withPageId(
209
- {
210
- type: {
211
- type: "string",
212
- enum: ["url", "back", "forward", "reload"],
213
- description: "\u5BFC\u822A\u7C7B\u578B"
214
- },
215
- url: { type: "string", description: "\u76EE\u6807 URL\uFF08type=url \u65F6\u5FC5\u586B\uFF09" },
216
- ignoreCache: { type: "boolean", description: "reload \u65F6\u662F\u5426\u5FFD\u7565\u7F13\u5B58" },
217
- handleBeforeUnload: {
218
- type: "string",
219
- enum: ["accept", "dismiss"],
220
- description: "beforeunload \u5BF9\u8BDD\u6846\u5904\u7406\u65B9\u5F0F"
221
- },
222
- initScript: {
223
- type: "string",
224
- description: "\u4E0B\u4E00\u6B21\u5BFC\u822A\u65F6\uFF0C\u5728\u6BCF\u4E2A\u65B0 document \u52A0\u8F7D\u524D\u6267\u884C\u7684 JS \u811A\u672C"
225
- },
226
- timeout: { type: "integer", description: "\u6700\u5927\u7B49\u5F85\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4F7F\u7528\u9ED8\u8BA4\u8D85\u65F6" }
227
- },
228
- ["type"]
229
- )
230
- }
231
- },
232
- {
233
- name: "chrome-devtools_resize_page",
234
- description: "\u8C03\u6574\u9875\u9762\u89C6\u53E3\u5927\u5C0F",
235
- inputSchema: {
236
- type: "object",
237
- ...withPageId(
238
- {
239
- width: { type: "number", description: "\u89C6\u53E3\u5BBD\u5EA6" },
240
- height: { type: "number", description: "\u89C6\u53E3\u9AD8\u5EA6" }
241
- },
242
- ["width", "height"]
243
- )
244
- }
245
- },
246
- {
247
- name: "chrome-devtools_emulate",
248
- description: "\u6A21\u62DF\u8BBE\u5907\u7279\u6027\uFF08\u7F51\u7EDC\u8282\u6D41\u3001CPU \u964D\u901F\u3001\u5730\u7406\u4F4D\u7F6E\u3001UA\u3001\u989C\u8272\u65B9\u6848\u3001\u89C6\u53E3\u7B49\uFF09",
249
- inputSchema: {
250
- type: "object",
251
- ...withPageId({
252
- networkConditions: {
253
- type: "string",
254
- enum: ["Offline", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G"],
255
- description: "\u7F51\u7EDC\u8282\u6D41\u6A21\u5F0F"
256
- },
257
- cpuThrottlingRate: {
258
- type: "number",
259
- minimum: 1,
260
- maximum: 20,
261
- description: "CPU \u964D\u901F\u500D\u6570\uFF0C1 \u4E0D\u964D\u901F"
262
- },
263
- geolocation: { type: "string", description: "\u5730\u7406\u4F4D\u7F6E\uFF0C\u683C\u5F0F `<\u7EAC\u5EA6>,<\u7ECF\u5EA6>`" },
264
- userAgent: { type: "string", description: "UA \u5B57\u7B26\u4E32\uFF0C\u7A7A\u5B57\u7B26\u4E32\u6E05\u9664" },
265
- colorScheme: {
266
- type: "string",
267
- enum: ["dark", "light", "auto"],
268
- description: '\u989C\u8272\u65B9\u6848\uFF0C"auto" \u6062\u590D\u9ED8\u8BA4'
269
- },
270
- viewport: {
271
- type: "string",
272
- description: "\u89C6\u53E3\u6A21\u62DF\uFF0C\u683C\u5F0F `<\u5BBD>x<\u9AD8>x<\u7F29\u653E\u6BD4>[,mobile][,touch][,landscape]`"
273
- },
274
- extraHttpHeaders: {
275
- type: "string",
276
- description: `\u989D\u5916 HTTP \u8BF7\u6C42\u5934 JSON\uFF0C\u5982 '{"X-Custom":"value"}'`
277
- }
278
- })
279
- }
280
- },
281
- // ===== JS 执行 =====
282
- {
283
- name: "chrome-devtools_evaluate_script",
284
- description: "\u5728\u6307\u5B9A\u9875\u9762\u6267\u884C JavaScript \u51FD\u6570\u5E76\u8FD4\u56DE\u7ED3\u679C\uFF08\u8FD4\u56DE\u503C\u9700\u53EF JSON \u5E8F\u5217\u5316\uFF09",
285
- inputSchema: {
286
- type: "object",
287
- ...withPageId(
288
- {
289
- function: {
290
- type: "string",
291
- description: "JS \u51FD\u6570\u58F0\u660E\u3002\u65E0\u53C2\u6570: `() => document.title`\uFF0C\u6709\u53C2\u6570: `(el) => el.innerText`"
292
- },
293
- args: {
294
- type: "array",
295
- items: { type: "string" },
296
- description: "\u4F20\u7ED9\u51FD\u6570\u7684\u53C2\u6570\u5217\u8868\uFF08\u5143\u7D20 uid\uFF09"
297
- },
298
- filePath: { type: "string", description: "\u4FDD\u5B58\u8F93\u51FA\u5230\u6587\u4EF6\uFF0C\u7701\u7565\u5219\u5185\u8054\u8FD4\u56DE" },
299
- dialogAction: {
300
- type: "string",
301
- description: '\u5BF9\u8BDD\u6846\u5904\u7406: "accept"\u3001"dismiss" \u6216 prompt \u6587\u672C'
302
- }
303
- },
304
- ["function"]
305
- )
306
- }
307
- },
308
- // ===== 网络监控 =====
309
- {
310
- name: "chrome-devtools_list_network_requests",
311
- description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u7F51\u7EDC\u8BF7\u6C42\u5217\u8868\uFF08\u652F\u6301\u5206\u9875\u548C\u8FC7\u6EE4\uFF09",
312
- inputSchema: {
313
- type: "object",
314
- ...withPageId({
315
- pageSize: { type: "integer", description: "\u6BCF\u9875\u6700\u5927\u8BF7\u6C42\u6570" },
316
- pageIdx: { type: "integer", minimum: 0, description: "\u9875\u7801\uFF08\u4ECE 0 \u5F00\u59CB\uFF09" },
317
- resourceTypes: {
318
- type: "array",
319
- items: {
320
- type: "string",
321
- enum: [
322
- "document",
323
- "stylesheet",
324
- "image",
325
- "media",
326
- "font",
327
- "script",
328
- "xhr",
329
- "fetch",
330
- "websocket",
331
- "manifest",
332
- "other"
333
- ]
334
- },
335
- description: "\u6309\u8D44\u6E90\u7C7B\u578B\u8FC7\u6EE4"
336
- },
337
- includePreservedRequests: {
338
- type: "boolean",
339
- description: "\u662F\u5426\u8FD4\u56DE\u6700\u8FD1 3 \u6B21\u5BFC\u822A\u7684\u4FDD\u7559\u8BF7\u6C42"
340
- }
341
- })
342
- }
343
- },
344
- {
345
- name: "chrome-devtools_get_network_request",
346
- description: "\u83B7\u53D6\u7F51\u7EDC\u8BF7\u6C42\u7684\u8BE6\u7EC6\u4FE1\u606F\uFF0C\u53EF\u4FDD\u5B58\u8BF7\u6C42/\u54CD\u5E94\u4F53\u5230\u6587\u4EF6",
347
- inputSchema: {
348
- type: "object",
349
- ...withPageId({
350
- reqid: {
351
- type: "number",
352
- description: "\u8BF7\u6C42 ID\uFF08\u4ECE chrome-devtools_list_network_requests \u83B7\u53D6\uFF09\uFF0C\u7701\u7565\u8FD4\u56DE\u5F53\u524D\u9009\u4E2D\u8BF7\u6C42"
353
- },
354
- requestFilePath: {
355
- type: "string",
356
- description: "\u4FDD\u5B58\u8BF7\u6C42\u4F53\u5230 .network-request \u6587\u4EF6\u7684\u8DEF\u5F84"
357
- },
358
- responseFilePath: {
359
- type: "string",
360
- description: "\u4FDD\u5B58\u54CD\u5E94\u4F53\u5230 .network-response \u6587\u4EF6\u7684\u8DEF\u5F84"
361
- }
362
- })
363
- }
364
- },
365
- // ===== 控制台 =====
366
- {
367
- name: "chrome-devtools_list_console_messages",
368
- description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u63A7\u5236\u53F0\u6D88\u606F\uFF08\u652F\u6301\u5206\u9875\u548C\u8FC7\u6EE4\uFF09",
369
- inputSchema: {
370
- type: "object",
371
- ...withPageId({
372
- pageSize: { type: "integer", description: "\u6BCF\u9875\u6700\u5927\u6D88\u606F\u6570" },
373
- pageIdx: { type: "integer", minimum: 0, description: "\u9875\u7801\uFF08\u4ECE 0 \u5F00\u59CB\uFF09" },
374
- types: {
375
- type: "array",
376
- items: {
377
- type: "string",
378
- enum: ["log", "debug", "info", "error", "warn", "trace", "verbose", "issue"]
379
- },
380
- description: "\u6309\u6D88\u606F\u7C7B\u578B\u8FC7\u6EE4"
381
- },
382
- includePreservedMessages: {
383
- type: "boolean",
384
- description: "\u662F\u5426\u8FD4\u56DE\u6700\u8FD1 3 \u6B21\u5BFC\u822A\u7684\u4FDD\u7559\u6D88\u606F"
385
- },
386
- serviceWorkerId: { type: "string", description: "\u6309 service worker ID \u8FC7\u6EE4" }
387
- })
388
- }
389
- },
390
- {
391
- name: "chrome-devtools_get_console_message",
392
- description: "\u83B7\u53D6\u67D0\u6761\u63A7\u5236\u53F0\u6D88\u606F\u7684\u8BE6\u7EC6\u4FE1\u606F",
393
- inputSchema: {
394
- type: "object",
395
- ...withPageId(
396
- {
397
- msgid: {
398
- type: "number",
399
- description: "\u6D88\u606F ID\uFF08\u4ECE chrome-devtools_list_console_messages \u83B7\u53D6\uFF09"
400
- }
401
- },
402
- ["msgid"]
403
- )
404
- }
405
- },
406
- // ===== 其他 =====
407
- {
408
- name: "chrome-devtools_wait_for",
409
- description: "\u7B49\u5F85\u6307\u5B9A\u9875\u9762\u51FA\u73B0\u6307\u5B9A\u6587\u672C\uFF08\u4EFB\u4E00\u5339\u914D\u5373\u8FD4\u56DE\uFF09",
410
- inputSchema: {
411
- type: "object",
412
- ...withPageId(
413
- {
414
- text: {
415
- type: "array",
416
- items: { type: "string" },
417
- minItems: 1,
418
- description: "\u7B49\u5F85\u51FA\u73B0\u7684\u6587\u672C\u5217\u8868"
419
- },
420
- timeout: { type: "integer", description: "\u6700\u5927\u7B49\u5F85\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4F7F\u7528\u9ED8\u8BA4\u8D85\u65F6" }
421
- },
422
- ["text"]
423
- )
424
- }
425
- },
426
- {
427
- name: "chrome-devtools_handle_dialog",
428
- description: "\u5904\u7406 JavaScript \u5BF9\u8BDD\u6846\uFF08alert/confirm/prompt\uFF09",
429
- inputSchema: {
430
- type: "object",
431
- ...withPageId(
432
- {
433
- action: { type: "string", enum: ["accept", "dismiss"], description: "\u63A5\u53D7\u6216\u5173\u95ED\u5BF9\u8BDD\u6846" },
434
- promptText: { type: "string", description: "prompt \u5BF9\u8BDD\u6846\u7684\u8F93\u5165\u6587\u672C" }
435
- },
436
- ["action"]
437
- )
438
- }
439
- },
440
- {
441
- name: "chrome-devtools_upload_file",
442
- description: "\u4E0A\u4F20\u6587\u4EF6\u5230\u6587\u4EF6\u8F93\u5165\u6846",
443
- inputSchema: {
444
- type: "object",
445
- ...withPageId(
446
- {
447
- uid: { type: "string", description: "\u6587\u4EF6\u8F93\u5165\u6846\u5143\u7D20 uid" },
448
- filePath: { type: "string", description: "\u672C\u5730\u6587\u4EF6\u8DEF\u5F84" },
449
- includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
450
- },
451
- ["uid", "filePath"]
452
- )
453
- }
454
- },
455
- // ===== 性能分析 =====
456
- {
457
- name: "chrome-devtools_performance_start_trace",
458
- description: "\u5728\u6307\u5B9A\u9875\u9762\u5F00\u59CB\u8BB0\u5F55\u6027\u80FD trace\uFF08\u7528\u4E8E\u53D1\u73B0 Core Web Vitals \u6027\u80FD\u95EE\u9898\uFF09",
459
- inputSchema: {
460
- type: "object",
461
- ...withPageId({
462
- reload: { type: "boolean", description: "\u5F00\u59CB\u540E\u662F\u5426\u81EA\u52A8\u5237\u65B0\u9875\u9762\uFF0C\u9ED8\u8BA4 true" },
463
- autoStop: { type: "boolean", description: "\u662F\u5426\u81EA\u52A8\u505C\u6B62\u5F55\u5236\uFF0C\u9ED8\u8BA4 true" },
464
- filePath: { type: "string", description: "\u4FDD\u5B58\u539F\u59CB trace \u6570\u636E\u7684\u8DEF\u5F84\uFF0C\u5982 trace.json.gz" }
465
- })
466
- }
467
- },
468
- {
469
- name: "chrome-devtools_performance_stop_trace",
470
- description: "\u505C\u6B62\u6027\u80FD trace \u8BB0\u5F55\u5E76\u8FD4\u56DE\u7ED3\u679C",
471
- inputSchema: {
472
- type: "object",
473
- ...withPageId({
474
- filePath: { type: "string", description: "\u4FDD\u5B58\u539F\u59CB trace \u6570\u636E\u7684\u8DEF\u5F84\uFF0C\u5982 trace.json.gz" }
475
- })
476
- }
477
- },
478
32
  {
479
- name: "chrome-devtools_performance_analyze_insight",
480
- description: "\u83B7\u53D6\u7279\u5B9A\u6027\u80FD\u6307\u6807\u7684\u8BE6\u7EC6\u5206\u6790",
481
- inputSchema: {
482
- type: "object",
483
- ...withPageId(
484
- {
485
- insightSetId: { type: "string", description: "\u6307\u6807\u96C6 ID\uFF08\u4ECE trace \u7ED3\u679C\u83B7\u53D6\uFF09" },
486
- insightName: {
487
- type: "string",
488
- description: '\u6307\u6807\u540D\u79F0\uFF0C\u5982 "DocumentLatency"\u3001"LCPBreakdown"'
489
- }
490
- },
491
- ["insightSetId", "insightName"]
492
- )
493
- }
494
- },
495
- {
496
- name: "chrome-devtools_lighthouse_audit",
497
- description: "\u5BF9\u6307\u5B9A\u9875\u9762\u8FD0\u884C Lighthouse \u5BA1\u8BA1\uFF08\u53EF\u8BBF\u95EE\u6027/SEO/\u6700\u4F73\u5B9E\u8DF5\uFF0C\u4E0D\u542B\u6027\u80FD\uFF09",
498
- inputSchema: {
499
- type: "object",
500
- ...withPageId({
501
- mode: {
502
- type: "string",
503
- enum: ["navigation", "snapshot"],
504
- description: "navigation \u5237\u65B0\u5BA1\u8BA1\uFF0Csnapshot \u5206\u6790\u5F53\u524D\u72B6\u6001"
505
- },
506
- device: {
507
- type: "string",
508
- enum: ["desktop", "mobile"],
509
- description: "\u6A21\u62DF\u8BBE\u5907\u7C7B\u578B\uFF0C\u9ED8\u8BA4 desktop"
510
- },
511
- outputDirPath: { type: "string", description: "\u62A5\u544A\u8F93\u51FA\u76EE\u5F55\uFF0C\u7701\u7565\u4F7F\u7528\u4E34\u65F6\u6587\u4EF6" }
512
- })
513
- }
514
- },
515
- {
516
- name: "chrome-devtools_take_heapsnapshot",
517
- description: "\u6355\u83B7\u6307\u5B9A\u9875\u9762\u5806\u5185\u5B58\u5FEB\u7167\uFF0C\u7528\u4E8E\u5206\u6790 JS \u5BF9\u8C61\u5185\u5B58\u5206\u5E03\u548C\u8C03\u8BD5\u5185\u5B58\u6CC4\u6F0F",
518
- inputSchema: {
519
- type: "object",
520
- ...withPageId(
521
- {
522
- filePath: { type: "string", description: "\u4FDD\u5B58 .heapsnapshot \u6587\u4EF6\u7684\u8DEF\u5F84" }
523
- },
524
- ["filePath"]
525
- )
526
- }
527
- },
528
- // ===== Vue DevTools =====
529
- {
530
- name: "vue-devtools_get_apps",
531
- description: `\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u6240\u6709 Vue \u5E94\u7528\u5B9E\u4F8B\u5217\u8868\u3002
532
-
533
- **\u4F55\u65F6\u4F7F\u7528**\uFF1A
534
- - \u6392\u67E5\u5FAE\u524D\u7AEF/\u591A\u5B9E\u4F8B\u573A\u666F\u4E0B\u64CD\u4F5C\u7684\u662F\u54EA\u4E2A\u5E94\u7528
535
- - \u5207\u6362\u6D3B\u8DC3\u5E94\u7528\u524D\u67E5\u770B\u6709\u54EA\u4E9B\u53EF\u7528`,
536
- inputSchema: {
537
- type: "object",
538
- ...withPageId({})
539
- }
540
- },
541
- {
542
- name: "vue-devtools_set_active_app",
543
- description: `\u5207\u6362\u6307\u5B9A\u9875\u9762\u7684\u6D3B\u8DC3 Vue \u5E94\u7528\u5B9E\u4F8B\u3002\u540E\u7EED\u6240\u6709 vue-devtools_* \u5DE5\u5177\u90FD\u64CD\u4F5C\u8FD9\u4E2A\u5E94\u7528\u3002`,
544
- inputSchema: {
545
- type: "object",
546
- ...withPageId(
547
- {
548
- appId: { type: "string", description: "\u5E94\u7528 ID\uFF08\u4ECE vue-devtools_get_apps \u83B7\u53D6\uFF09" }
549
- },
550
- ["appId"]
551
- )
552
- }
553
- },
554
- {
555
- name: "vue-devtools_get_component_tree",
556
- description: `\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u5F53\u524D\u6D3B\u8DC3 Vue \u5E94\u7528\u7684\u7EC4\u4EF6\u6811\u3002
557
-
558
- **\u4F55\u65F6\u4F7F\u7528**\uFF1A
559
- - \u4E86\u89E3\u9875\u9762\u7EC4\u4EF6\u5C42\u7EA7\u7ED3\u6784
560
- - \u627E\u5230\u76EE\u6807\u7EC4\u4EF6\u7684 nodeId\uFF08\u540E\u7EED\u67E5\u72B6\u6001\u7528\uFF09
561
- - \u6392\u67E5\u7EC4\u4EF6\u672A\u6E32\u67D3\u95EE\u9898
562
- - \u53EA\u5173\u5FC3\u67D0\u7C7B\u7EC4\u4EF6\u65F6\u7528 filter \u7F29\u5C0F\u8303\u56F4
563
-
564
- **\u8FD4\u56DE**\uFF1A\u7EC4\u4EF6\u6811 [{ id, name, children, file, ... }]`,
565
- inputSchema: {
566
- type: "object",
567
- ...withPageId({
568
- filter: { type: "string", description: "\u6309\u7EC4\u4EF6\u540D\u8FC7\u6EE4\uFF08\u5927\u5C0F\u5199\u4E0D\u654F\u611F\u7684\u5B50\u4E32\u5339\u914D\uFF09\uFF0C\u53EF\u9009" }
569
- })
570
- }
571
- },
572
- {
573
- name: "vue-devtools_get_component_state",
574
- description: `\u83B7\u53D6\u6307\u5B9A\u7EC4\u4EF6\u7684\u5B8C\u6574\u8FD0\u884C\u65F6\u72B6\u6001\u3002
575
-
576
- **\u4F55\u65F6\u4F7F\u7528**\uFF1A
577
- - \u6392\u67E5 props \u4F20\u503C\u662F\u5426\u6B63\u786E
578
- - \u67E5\u770B ref/reactive \u54CD\u5E94\u5F0F\u6570\u636E\u7684\u5F53\u524D\u503C
579
- - \u68C0\u67E5 computed \u8BA1\u7B97\u7ED3\u679C
580
- - \u67E5\u770B attrs / events / inject / provide / template refs`,
581
- inputSchema: {
582
- type: "object",
583
- ...withPageId(
584
- {
585
- nodeId: {
586
- type: "string",
587
- description: "\u7EC4\u4EF6\u8282\u70B9 ID\uFF08\u4ECE vue-devtools_get_component_tree \u83B7\u53D6\uFF09"
588
- }
589
- },
590
- ["nodeId"]
591
- )
592
- }
593
- },
594
- {
595
- name: "vue-devtools_get_component_render_code",
596
- description: `\u83B7\u53D6\u7EC4\u4EF6\u7684\u6E32\u67D3\u51FD\u6570\u6E90\u7801\u3002`,
597
- inputSchema: {
598
- type: "object",
599
- ...withPageId({ nodeId: { type: "string", description: "\u7EC4\u4EF6\u8282\u70B9 ID" } }, ["nodeId"])
600
- }
601
- },
602
- {
603
- name: "vue-devtools_get_current_route",
604
- description: `\u83B7\u53D6 Vue Router \u7684\u5F53\u524D\u8DEF\u7531\u4FE1\u606F\u3002
605
-
606
- **\u4F55\u65F6\u4F7F\u7528**\uFF1A
607
- - \u6392\u67E5\u8DEF\u7531\u8DF3\u8F6C\u95EE\u9898
608
- - \u67E5\u770B\u5F53\u524D\u8DEF\u7531 path/params/query/hash
609
- - \u786E\u8BA4\u8DEF\u7531\u5B88\u536B\u548C matched \u8BB0\u5F55`,
610
- inputSchema: {
611
- type: "object",
612
- ...withPageId({})
613
- }
614
- },
615
- {
616
- name: "vue-devtools_get_routes",
617
- description: `\u83B7\u53D6 Vue Router \u7684\u5B8C\u6574\u8DEF\u7531\u8868\u3002
618
-
619
- **\u4F55\u65F6\u4F7F\u7528**\uFF1A
620
- - \u67E5\u770B\u6240\u6709\u5DF2\u6CE8\u518C\u8DEF\u7531
621
- - \u786E\u8BA4\u8DEF\u7531\u914D\u7F6E\u662F\u5426\u6B63\u786E
622
- - \u67E5\u770B\u8DEF\u7531\u5D4C\u5957\u5173\u7CFB`,
623
- inputSchema: {
624
- type: "object",
625
- ...withPageId({})
33
+ name: displayToolName("current_page"),
34
+ description: "Get the page the user is currently browsing (URL, title, and page ID). Resolves the project page with injected context; for allowOrigins pages use list_pages and pass its pageId to page tools instead.",
35
+ inputSchema: { type: "object", properties: {} }
36
+ }
37
+ ];
38
+ const UNSAFE_CATEGORIES = /* @__PURE__ */ new Set(["EXTENSIONS", "PWA", "THIRD_PARTY", "WEBMCP"]);
39
+ function metaByName(short) {
40
+ return OFFICIAL_TOOL_META.find((m) => m.name === short);
41
+ }
42
+ function isOfficialExtraTool(short) {
43
+ const m = metaByName(short);
44
+ return !!m && m.conditions.length > 0 && !UNSAFE_CATEGORIES.has(m.category);
45
+ }
46
+ function camelToKebab(name) {
47
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
48
+ }
49
+ function extraToolFlag(short) {
50
+ const m = metaByName(short);
51
+ if (!m) return void 0;
52
+ const cond = m.conditions.find((c) => c.startsWith("experimental"));
53
+ return cond ? `--${camelToKebab(cond)}` : void 0;
54
+ }
55
+ function officialExtraCandidates() {
56
+ return OFFICIAL_TOOL_META.filter(
57
+ (m) => m.conditions.length > 0 && !UNSAFE_CATEGORIES.has(m.category)
58
+ ).map((m) => m.name);
59
+ }
60
+ function officialDefaultShorts() {
61
+ const pages = OFFICIAL_TOOL_META.filter(
62
+ (m) => m.pageScoped && m.conditions.length === 0 && !UNSAFE_CATEGORIES.has(m.category)
63
+ ).map((m) => m.name).sort();
64
+ return [...pages, ...OFFICIAL_GLOBAL_POLICY];
65
+ }
66
+ let extraAllowed = /* @__PURE__ */ new Set();
67
+ let deniedShorts = /* @__PURE__ */ new Set();
68
+ function configureToolScope(extra = [], deny = [], warn = (msg) => console.warn(msg)) {
69
+ const allowedExtra = /* @__PURE__ */ new Set();
70
+ for (const short of extra) {
71
+ if (isOfficialExtraTool(short)) {
72
+ allowedExtra.add(short);
73
+ } else {
74
+ warn(`chromeMcp.project.tools.extra \u5DF2\u5FFD\u7565\u975E\u4E8C\u7EA7\u76EE\u5F55\u5DE5\u5177: ${short}`);
626
75
  }
627
- },
628
- // ===== Vite 进程日志 =====
629
- {
630
- name: "logs-devtools_vite_logs",
631
- description: `\u83B7\u53D6 Vite \u5F00\u53D1\u670D\u52A1\u5668\u7684\u8FD0\u884C\u65E5\u5FD7\u3002
632
-
633
- **\u4F55\u65F6\u4F7F\u7528\u6B64\u5DE5\u5177**\uFF1A
634
- - \u7528\u6237\u62A5\u544A"\u9875\u9762\u6CA1\u66F4\u65B0"\u3001"\u70ED\u66F4\u65B0\u4E0D\u5DE5\u4F5C"\u3001"HMR \u5931\u6548"\u65F6
635
- - \u6784\u5EFA\u62A5\u9519\u6216\u7F16\u8BD1\u5931\u8D25\uFF0C\u9700\u8981\u67E5\u770B\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F
636
- - \u9875\u9762\u767D\u5C4F\u3001\u6837\u5F0F\u4E22\u5931\u3001\u6A21\u5757\u52A0\u8F7D\u5931\u8D25\u7B49\u5F00\u53D1\u95EE\u9898
637
- - \u7528\u6237\u63D0\u5230"\u5F00\u53D1\u670D\u52A1\u5668\u6709\u95EE\u9898"\u3001"vite \u62A5\u9519"
638
- - \u9700\u8981\u786E\u8BA4\u6700\u8FD1\u7684\u6587\u4EF6\u53D8\u66F4\u662F\u5426\u88AB Vite \u6B63\u786E\u5904\u7406
639
-
640
- **\u65E5\u5FD7\u5185\u5BB9**\uFF1A
641
- - Vite HMR \u70ED\u66F4\u65B0\u65E5\u5FD7\uFF08\u54EA\u4E9B\u6587\u4EF6\u88AB\u66F4\u65B0\u3001\u66F4\u65B0\u72B6\u6001\uFF09
642
- - \u6784\u5EFA\u7F16\u8BD1\u65E5\u5FD7\uFF08\u9519\u8BEF\u3001\u8B66\u544A\u3001\u6210\u529F\u4FE1\u606F\uFF09
643
- - OpenCode Web \u8FDB\u7A0B\u8F93\u51FA
644
- - \u63D2\u4EF6\u8FD0\u884C\u65E5\u5FD7
645
-
646
- \u65E5\u5FD7\u4FDD\u5B58\u5728\u5185\u5B58\u7F13\u51B2\u533A\uFF08\u6700\u8FD1 500 \u6761\uFF09\u3002`,
647
- inputSchema: {
648
- type: "object",
649
- properties: {
650
- level: {
651
- type: "string",
652
- description: "\u65E5\u5FD7\u7EA7\u522B\u8FC7\u6EE4\uFF1Aerror(\u9519\u8BEF)\u3001warn(\u8B66\u544A)\u3001info(\u4FE1\u606F)\u3001debug(\u8C03\u8BD5)\u3001log(\u666E\u901A)\u3002\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694\uFF0C\u5982 'error,warn'"
653
- },
654
- limit: {
655
- type: "integer",
656
- minimum: 1,
657
- maximum: 200,
658
- default: 50,
659
- description: "\u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 50\uFF0C\u6700\u5927 200"
660
- },
661
- source: {
662
- type: "string",
663
- description: "\u6765\u6E90\u8FC7\u6EE4\uFF1Aconsole(\u63A7\u5236\u53F0)\u3001provider-stdout(\u670D\u52A1\u8F93\u51FA)\u3001provider-stderr(\u670D\u52A1\u9519\u8BEF)"
664
- }
665
- }
76
+ }
77
+ const known = /* @__PURE__ */ new Set([
78
+ ...officialDefaultShorts(),
79
+ ...officialExtraCandidates(),
80
+ "current_page"
81
+ ]);
82
+ const denied = /* @__PURE__ */ new Set();
83
+ for (const short of deny) {
84
+ if (known.has(short)) {
85
+ denied.add(short);
86
+ } else {
87
+ warn(`chromeMcp.project.tools.deny \u5DF2\u5FFD\u7565\u672A\u77E5\u5DE5\u5177\u540D: ${short}`);
666
88
  }
667
89
  }
668
- ];
90
+ extraAllowed = allowedExtra;
91
+ deniedShorts = denied;
92
+ }
93
+ function currentOfficialShorts() {
94
+ const base = officialDefaultShorts().filter((s) => !deniedShorts.has(s));
95
+ const extra = [...extraAllowed].filter((s) => !officialDefaultShorts().includes(s));
96
+ return [...base, ...extra];
97
+ }
98
+ function isAllowedToolName(name) {
99
+ if (name === displayToolName("current_page")) return true;
100
+ const short = name.startsWith(MCP_PREFIX) ? name.slice(MCP_PREFIX.length) : name;
101
+ if (deniedShorts.has(short)) return false;
102
+ if (officialDefaultShorts().includes(short)) return true;
103
+ return extraAllowed.has(short);
104
+ }
669
105
  export {
670
- CUSTOM_TOOLS
106
+ CUSTOM_TOOLS,
107
+ MCP_PREFIX,
108
+ OFFICIAL_GLOBAL_POLICY,
109
+ OFFICIAL_NO_PAGE_TOOLS,
110
+ PAGE_ID_PROP,
111
+ PROJECT_DESCRIPTION_NOTES,
112
+ configureToolScope,
113
+ currentOfficialShorts,
114
+ displayToolName,
115
+ extraToolFlag,
116
+ isAllowedToolName,
117
+ isOfficialExtraTool,
118
+ officialDefaultShorts,
119
+ officialExtraCandidates,
120
+ withPageIdSchema
671
121
  };