puppeteer-mcp-claude 0.1.2 → 0.1.3

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 (3) hide show
  1. package/README.md +9 -3
  2. package/bin/cli.js +39 -23
  3. package/package.json +8 -2
package/README.md CHANGED
@@ -4,7 +4,13 @@ A Model Context Protocol (MCP) server that provides Claude Code with comprehensi
4
4
 
5
5
  ## 🚀 Quick Start
6
6
 
7
- **Want browser automation in Claude Desktop & Claude Code? Run this one command:**
7
+ **Want browser automation in Claude Code? Run this one command:**
8
+
9
+ ```bash
10
+ claude mcp add puppeteer-mcp-claude
11
+ ```
12
+
13
+ **Alternative - works for both Claude Desktop & Claude Code:**
8
14
 
9
15
  ```bash
10
16
  npx puppeteer-mcp-claude install
@@ -124,9 +130,9 @@ For development or contribution:
124
130
 
125
131
  ## Alternative Installation Methods
126
132
 
127
- ### Method 1: Using Claude Code MCP Command
133
+ ### Method 1: Using Claude Code MCP Command (Recommended)
128
134
 
129
- You can also configure this server using Claude Code's built-in MCP management:
135
+ Configure this server using Claude Code's built-in MCP management:
130
136
 
131
137
  ```bash
132
138
  claude mcp add puppeteer-mcp-claude
package/bin/cli.js CHANGED
@@ -138,14 +138,24 @@ class PuppeteerMCPInstaller {
138
138
  async installForConfig(config) {
139
139
  console.log(`📝 Configuring ${config.name}...`);
140
140
 
141
- // Ensure directory exists
141
+ // Use claude mcp add for Claude Code
142
+ if (config.type === 'code') {
143
+ console.log('🔧 Using claude mcp add command...');
144
+ execSync(`claude mcp add ${this.serverName} "npx puppeteer-mcp-claude serve"`, {
145
+ stdio: 'inherit',
146
+ cwd: this.packageDir
147
+ });
148
+ console.log(`✅ Successfully added via claude mcp add`);
149
+ return;
150
+ }
151
+
152
+ // Manual configuration for Claude Desktop
142
153
  const configDir = path.dirname(config.path);
143
154
  if (!existsSync(configDir)) {
144
155
  console.log(`📁 Creating directory: ${configDir}`);
145
156
  mkdirSync(configDir, { recursive: true });
146
157
  }
147
158
 
148
- // Read or create config
149
159
  let claudeConfig = {};
150
160
  let hasExistingConfig = false;
151
161
 
@@ -161,26 +171,23 @@ class PuppeteerMCPInstaller {
161
171
  }
162
172
  }
163
173
 
164
- // Initialize mcpServers if it doesn't exist
165
174
  if (!claudeConfig.mcpServers) {
166
175
  claudeConfig.mcpServers = {};
167
176
  }
168
177
 
169
- // Check if our server already exists
170
178
  if (claudeConfig.mcpServers[this.serverName]) {
171
179
  console.log(`⚠️ Puppeteer MCP already configured, updating...`);
172
180
  }
173
181
 
174
- // Add/update our MCP server configuration
175
182
  claudeConfig.mcpServers[this.serverName] = {
176
- command: 'npx',
177
- args: ['puppeteer-mcp-claude', 'serve'],
183
+ command: 'node',
184
+ args: [join(this.packageDir, 'dist', 'index.js')],
185
+ cwd: this.packageDir,
178
186
  env: {
179
187
  NODE_ENV: 'production'
180
188
  }
181
189
  };
182
190
 
183
- // Write the updated configuration
184
191
  writeFileSync(config.path, JSON.stringify(claudeConfig, null, 2));
185
192
 
186
193
  if (hasExistingConfig) {
@@ -189,7 +196,6 @@ class PuppeteerMCPInstaller {
189
196
  console.log(`✅ Configuration created: ${config.path}`);
190
197
  }
191
198
 
192
- // Verify the installation
193
199
  await this.verifyInstallationForConfig(config, claudeConfig);
194
200
  }
195
201
 
@@ -197,21 +203,31 @@ class PuppeteerMCPInstaller {
197
203
  console.log(`🔍 Verifying ${config.name} installation...`);
198
204
 
199
205
  try {
200
- if (!claudeConfig.mcpServers?.[this.serverName]) {
201
- throw new Error(`${this.serverName} not found in configuration`);
202
- }
203
-
204
- const serverConfig = claudeConfig.mcpServers[this.serverName];
205
-
206
- if (!serverConfig.command || !serverConfig.args) {
207
- throw new Error('Incomplete MCP server configuration');
208
- }
209
-
210
- // For npx commands, verify structure
211
- if (serverConfig.command === 'npx' && serverConfig.args[0] === 'puppeteer-mcp-claude') {
212
- console.log(`✅ ${config.name} configuration verified`);
206
+ // If claude mcp add was used, the configuration might not be in the expected format
207
+ // So we'll read the config file again to verify
208
+ if (existsSync(config.path)) {
209
+ const configContent = readFileSync(config.path, 'utf8');
210
+ const currentConfig = JSON.parse(configContent);
211
+
212
+ if (currentConfig.mcpServers?.[this.serverName]) {
213
+ const serverConfig = currentConfig.mcpServers[this.serverName];
214
+
215
+ if (!serverConfig.command || !serverConfig.args) {
216
+ throw new Error('Incomplete MCP server configuration');
217
+ }
218
+
219
+ // Verify either npx or node command structure
220
+ if ((serverConfig.command === 'npx' && serverConfig.args[0] === 'puppeteer-mcp-claude') ||
221
+ (serverConfig.command === 'node' && serverConfig.args[0].includes('dist/index.js'))) {
222
+ console.log(`✅ ${config.name} configuration verified`);
223
+ } else {
224
+ console.log(`✅ ${config.name} configuration verified (custom format)`);
225
+ }
226
+ } else {
227
+ throw new Error(`${this.serverName} not found in configuration`);
228
+ }
213
229
  } else {
214
- throw new Error('Invalid server configuration');
230
+ throw new Error('Configuration file not found');
215
231
  }
216
232
 
217
233
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puppeteer-mcp-claude",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "puppeteer-mcp-claude": "./bin/cli.js"
@@ -26,7 +26,13 @@
26
26
  "prepublishOnly": "npm run build",
27
27
  "prepack": "npm run build"
28
28
  },
29
- "keywords": ["mcp", "puppeteer", "claude", "browser-automation", "model-context-protocol"],
29
+ "keywords": [
30
+ "mcp",
31
+ "puppeteer",
32
+ "claude",
33
+ "browser-automation",
34
+ "model-context-protocol"
35
+ ],
30
36
  "author": "jaenster",
31
37
  "repository": {
32
38
  "type": "git",