chrometools-mcp 2.3.2 → 2.4.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.4.0] - 2025-12-29
6
+
7
+ ### Added
8
+ - **Tool Filtering by Groups** - New `ENABLED_TOOLS` environment variable for selective group enabling
9
+ - Configure via `env.ENABLED_TOOLS` in MCP client config (comma-separated list of group names)
10
+ - Available groups: `core`, `interaction`, `inspection`, `debug`, `advanced`, `recorder`, `figma`
11
+ - Group structure optimized:
12
+ - `debug` - NEW group for debugging tools (console logs, network monitoring)
13
+ - `advanced` - Combined with AI tools (now includes smartFindElement, analyzePage, etc.)
14
+ - If not set, all tools are enabled (default behavior)
15
+ - If set, only tools from specified groups are available to AI
16
+ - Primary benefit: **Token optimization** - all 43 tools consume ~28k tokens (~14% of context). Enable only needed groups to reduce token usage and costs
17
+ - Additional use cases: security/compliance restrictions, workflow simplification, improved AI focus
18
+ - Examples:
19
+ - Basic automation: `ENABLED_TOOLS=core,interaction,inspection`
20
+ - Advanced with AI: `ENABLED_TOOLS=core,interaction,advanced`
21
+ - With debugging: `ENABLED_TOOLS=core,interaction,inspection,debug`
22
+ - Figma validation: `ENABLED_TOOLS=core,figma`
23
+ - Location:
24
+ - `server/tool-groups.js` - group definitions (7 groups, 43 tools total)
25
+ - `index.js:36` - import groups module
26
+ - `index.js:77-92` - parsing and filtering logic
27
+ - `index.js:195-203` - apply filter to ListTools handler
28
+ - Documentation: README.md section "Tool Filtering with ENABLED_TOOLS"
29
+
5
30
  ## [2.3.2] - 2025-12-25
6
31
 
7
32
  ### Changed
package/README.md CHANGED
@@ -965,6 +965,106 @@ If you don't need to see the browser window, you can use xvfb (virtual X server)
965
965
 
966
966
  This runs Chrome in GUI mode but on a virtual display (window is not visible).
967
967
 
968
+ ### Tool Filtering with ENABLED_TOOLS
969
+
970
+ By default, all tools are enabled. You can selectively enable only specific tool groups using the `ENABLED_TOOLS` environment variable.
971
+
972
+ **Why filter tools?**
973
+
974
+ Each tool definition is sent to the AI in every request, consuming context tokens. All 43 tools consume ~28k tokens (~14% of context window). By enabling only the groups you need, you can significantly reduce token usage:
975
+
976
+ - **Save tokens:** Fewer tools = less context consumed per request
977
+ - **Reduce costs:** Lower token usage means lower API costs
978
+ - **Improve focus:** AI sees only relevant tools for your workflow
979
+ - **Security/compliance:** Restrict available capabilities when needed
980
+
981
+ **Available Tool Groups:**
982
+
983
+ | Group | Description | Tools (count) |
984
+ |-------|-------------|---------------|
985
+ | `core` | Basic tools | `ping`, `openBrowser` (2) |
986
+ | `interaction` | User interaction | `click`, `type`, `scrollTo`, `waitForElement`, `hover` (5) |
987
+ | `inspection` | Page inspection | `getElement`, `getComputedCss`, `getBoxModel`, `screenshot`, `saveScreenshot` (5) |
988
+ | `debug` | Debugging & network | `getConsoleLogs`, `listNetworkRequests`, `getNetworkRequest`, `filterNetworkRequests` (4) |
989
+ | `advanced` | Advanced automation & AI | `executeScript`, `setStyles`, `setViewport`, `getViewport`, `navigateTo`, `smartFindElement`, `analyzePage`, `getAllInteractiveElements`, `findElementsByText` (9) |
990
+ | `recorder` | Scenario recording | `enableRecorder`, `executeScenario`, `listScenarios`, `searchScenarios`, `getScenarioInfo`, `deleteScenario`, `exportScenarioAsCode`, `appendScenarioToFile`, `generatePageObject` (9) |
991
+ | `figma` | Figma integration | `getFigmaFrame`, `compareFigmaToElement`, `getFigmaSpecs`, `parseFigmaUrl`, `listFigmaPages`, `searchFigmaFrames`, `getFigmaComponents`, `getFigmaStyles`, `getFigmaColorPalette` (9) |
992
+
993
+ **Total:** 43 tools across 7 groups
994
+
995
+ **Configuration:**
996
+
997
+ **Claude Desktop** (`~/.claude/mcp_config.json`):
998
+
999
+ ```json
1000
+ {
1001
+ "mcpServers": {
1002
+ "chrometools": {
1003
+ "command": "npx",
1004
+ "args": ["-y", "chrometools-mcp"],
1005
+ "env": {
1006
+ "ENABLED_TOOLS": "core,interaction,inspection"
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ ```
1012
+
1013
+ **Claude Code** (`~/.claude.json`):
1014
+
1015
+ ```json
1016
+ {
1017
+ "mcpServers": {
1018
+ "chrometools": {
1019
+ "type": "stdio",
1020
+ "command": "npx",
1021
+ "args": ["-y", "chrometools-mcp"],
1022
+ "env": {
1023
+ "ENABLED_TOOLS": "core,interaction,advanced"
1024
+ }
1025
+ }
1026
+ }
1027
+ }
1028
+ ```
1029
+
1030
+ **Format:**
1031
+ - Comma-separated list of group names (e.g., `"core,interaction,advanced"`)
1032
+ - Spaces are automatically trimmed
1033
+ - If not set or empty, all tools are enabled (default behavior)
1034
+
1035
+ **Example configurations:**
1036
+
1037
+ **Basic automation only:**
1038
+ ```json
1039
+ "ENABLED_TOOLS": "core,interaction,inspection"
1040
+ ```
1041
+
1042
+ **Advanced automation with AI:**
1043
+ ```json
1044
+ "ENABLED_TOOLS": "core,interaction,advanced"
1045
+ ```
1046
+
1047
+ **With debugging tools:**
1048
+ ```json
1049
+ "ENABLED_TOOLS": "core,interaction,inspection,debug"
1050
+ ```
1051
+
1052
+ **Figma design validation:**
1053
+ ```json
1054
+ "ENABLED_TOOLS": "core,figma"
1055
+ ```
1056
+
1057
+ **Full automation with recording:**
1058
+ ```json
1059
+ "ENABLED_TOOLS": "core,interaction,inspection,debug,advanced,recorder"
1060
+ ```
1061
+
1062
+ **All tools (default):**
1063
+ ```json
1064
+ "env": {}
1065
+ ```
1066
+ or omit the `env` field entirely.
1067
+
968
1068
  ### Figma API Token Setup
969
1069
 
970
1070
  To use Figma tools, you need to configure your Figma Personal Access Token.
package/index.js CHANGED
@@ -33,6 +33,7 @@ import {filterCssStyles} from './utils/css-utils.js';
33
33
  // Import tool schemas and definitions
34
34
  import * as schemas from './server/tool-schemas.js';
35
35
  import {toolDefinitions} from './server/tool-definitions.js';
36
+ import {getToolsFromGroups, getAllGroupNames} from './server/tool-groups.js';
36
37
 
37
38
  // Import element actions helper
38
39
  import {executeElementAction} from './utils/element-actions.js';
@@ -73,6 +74,16 @@ const debugLog = DEBUG_MODE ? console.error : () => {};
73
74
  // Figma token from environment variable (can be set in MCP config)
74
75
  const FIGMA_TOKEN = process.env.FIGMA_TOKEN || null;
75
76
 
77
+ // Tool filtering - read ENABLED_TOOLS environment variable
78
+ // If set, only enable specified tool groups (comma-separated list)
79
+ // If not set, enable all tools (default behavior)
80
+ const ENABLED_TOOLS = process.env.ENABLED_TOOLS;
81
+ let enabledToolsSet = null;
82
+
83
+ if (ENABLED_TOOLS) {
84
+ const groupNames = ENABLED_TOOLS.split(',').map(g => g.trim()).filter(g => g.length > 0);
85
+ enabledToolsSet = getToolsFromGroups(groupNames);
86
+ }
76
87
  // Get current directory for loading utils
77
88
  const __filename = fileURLToPath(import.meta.url);
78
89
  const __dirname = dirname(__filename);
@@ -164,7 +175,7 @@ try {
164
175
  const server = new Server(
165
176
  {
166
177
  name: "chrometools-mcp",
167
- version: "2.1.0",
178
+ version: "2.4.0",
168
179
  },
169
180
  {
170
181
  capabilities: {
@@ -175,8 +186,13 @@ const server = new Server(
175
186
 
176
187
  // List available tools
177
188
  server.setRequestHandler(ListToolsRequestSchema, async () => {
189
+ // Filter tools based on ENABLED_TOOLS environment variable
190
+ const tools = enabledToolsSet
191
+ ? toolDefinitions.filter(tool => enabledToolsSet.has(tool.name))
192
+ : toolDefinitions;
193
+
178
194
  return {
179
- tools: toolDefinitions,
195
+ tools,
180
196
  };
181
197
  });
182
198
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrometools-mcp",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "MCP (Model Context Protocol) server for Chrome automation using Puppeteer. Persistent browser sessions, visual testing, Figma comparison, and design validation. Works seamlessly in WSL, Linux, and macOS.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,82 @@
1
+ /**
2
+ * server/tool-groups.js
3
+ *
4
+ * Tool group definitions for filtering
5
+ */
6
+
7
+ export const toolGroups = {
8
+ core: ['ping', 'openBrowser'],
9
+
10
+ interaction: ['click', 'type', 'scrollTo', 'waitForElement', 'hover'],
11
+
12
+ inspection: ['getElement', 'getComputedCss', 'getBoxModel', 'screenshot', 'saveScreenshot'],
13
+
14
+ debug: [
15
+ 'getConsoleLogs',
16
+ 'listNetworkRequests',
17
+ 'getNetworkRequest',
18
+ 'filterNetworkRequests'
19
+ ],
20
+
21
+ advanced: [
22
+ 'executeScript',
23
+ 'setStyles',
24
+ 'setViewport',
25
+ 'getViewport',
26
+ 'navigateTo',
27
+ 'smartFindElement',
28
+ 'analyzePage',
29
+ 'getAllInteractiveElements',
30
+ 'findElementsByText'
31
+ ],
32
+
33
+ recorder: [
34
+ 'enableRecorder',
35
+ 'executeScenario',
36
+ 'listScenarios',
37
+ 'searchScenarios',
38
+ 'getScenarioInfo',
39
+ 'deleteScenario',
40
+ 'exportScenarioAsCode',
41
+ 'appendScenarioToFile',
42
+ 'generatePageObject'
43
+ ],
44
+
45
+ figma: [
46
+ 'getFigmaFrame',
47
+ 'compareFigmaToElement',
48
+ 'getFigmaSpecs',
49
+ 'parseFigmaUrl',
50
+ 'listFigmaPages',
51
+ 'searchFigmaFrames',
52
+ 'getFigmaComponents',
53
+ 'getFigmaStyles',
54
+ 'getFigmaColorPalette'
55
+ ]
56
+ };
57
+
58
+ /**
59
+ * Get all tool names from specified groups
60
+ * @param {string[]} groupNames - Array of group names (e.g., ['core', 'interaction'])
61
+ * @returns {Set<string>} - Set of tool names
62
+ */
63
+ export function getToolsFromGroups(groupNames) {
64
+ const tools = new Set();
65
+
66
+ for (const groupName of groupNames) {
67
+ const group = toolGroups[groupName];
68
+ if (group) {
69
+ group.forEach(tool => tools.add(tool));
70
+ }
71
+ }
72
+
73
+ return tools;
74
+ }
75
+
76
+ /**
77
+ * Get all available group names
78
+ * @returns {string[]} - Array of group names
79
+ */
80
+ export function getAllGroupNames() {
81
+ return Object.keys(toolGroups);
82
+ }