NPM Package Deployment
NPM Package Deployment
Section titled “NPM Package Deployment”Complete guide for deploying Puppeteer MCP as an npm package.
Package Overview
Section titled “Package Overview”- Name:
puppeteer-mcp
- Current Version: 1.1.0
- License: MIT
- Registry: npmjs.com/package/puppeteer-mcp
Installation Methods
Section titled “Installation Methods”Global Installation
Section titled “Global Installation”Best for system-wide CLI access:
# Install globallynpm install -g puppeteer-mcp
# Verify installationpuppeteer-mcp --version
# Run the serverpuppeteer-mcp
Local Project Installation
Section titled “Local Project Installation”Best for project-specific usage:
# Add to projectnpm install puppeteer-mcp
# Add to package.json scripts{ "scripts": { "mcp": "puppeteer-mcp", "mcp:dev": "puppeteer-mcp --dev" }}
# Run via npmnpm run mcp
Using NPX
Section titled “Using NPX”Best for one-time usage or testing:
# Run latest versionnpx puppeteer-mcp
# Run specific versionnpx puppeteer-mcp@1.1.2
# Run with argumentsnpx puppeteer-mcp --port 3001
Package Contents
Section titled “Package Contents”What’s Included
Section titled “What’s Included”puppeteer-mcp/├── dist/ # Compiled JavaScript│ ├── index.js # Main entry point│ ├── cli.js # CLI entry point│ └── **/*.js # All modules├── package.json # Package manifest├── README.md # Package documentation├── LICENSE # MIT license└── CHANGELOG.md # Version history
Binary Entry Points
Section titled “Binary Entry Points”{ "bin": { "puppeteer-mcp": "./dist/cli.js" }}
Publishing Process
Section titled “Publishing Process”1. Pre-Publish Checklist
Section titled “1. Pre-Publish Checklist”# Run all checksnpm run prepublish-check
# Individual checksnpm run typecheck # TypeScript compilationnpm run lint # ESLint checksnpm test # All tests passnpm audit # Security audit
2. Version Management
Section titled “2. Version Management”# Patch release (1.0.0 → 1.0.1)npm version patch -m "fix: %s"
# Minor release (1.0.0 → 1.1.0)npm version minor -m "feat: %s"
# Major release (1.0.0 → 2.0.0)npm version major -m "breaking: %s"
# Pre-releasenpm version prerelease --preid=beta# Results in: 1.0.1-beta.0
3. Build Package
Section titled “3. Build Package”# Clean build directorynpm run clean
# Build TypeScriptnpm run build
# Verify build outputls -la dist/
4. Test Package Locally
Section titled “4. Test Package Locally”# Create package archivenpm pack
# Test in another directorycd /tmpnpm install /path/to/puppeteer-mcp-1.0.0.tgznpx puppeteer-mcp --version
5. Publish to NPM
Section titled “5. Publish to NPM”# Dry run firstnpm publish --dry-run
# Publish to registrynpm publish
# Publish with tagnpm publish --tag betanpm publish --tag next
Configuration
Section titled “Configuration”Package.json Configuration
Section titled “Package.json Configuration”{ "name": "puppeteer-mcp", "version": "1.1.0", "description": "AI-enabled browser automation platform", "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { "puppeteer-mcp": "./dist/cli.js" }, "files": ["dist/**/*", "README.md", "LICENSE", "CHANGELOG.md"], "scripts": { "prepublishOnly": "npm run clean && npm run build && npm test" }, "engines": { "node": ">=20.0.0" }, "keywords": ["puppeteer", "mcp", "browser-automation", "ai", "typescript"], "repository": { "type": "git", "url": "https://github.com/williamzujkowski/puppeteer-mcp.git" }}
NPM Configuration
Section titled “NPM Configuration”# Set registry (if using private)npm config set registry https://registry.npmjs.org/
# Set auth tokennpm config set //registry.npmjs.org/:_authToken YOUR_TOKEN
# Set scope (if scoped package)npm config set @yourscope:registry https://registry.npmjs.org/
Usage Examples
Section titled “Usage Examples”CLI Usage
Section titled “CLI Usage”# Basic usagepuppeteer-mcp
# With custom portpuppeteer-mcp --port 3001
# With config filepuppeteer-mcp --config ./config.json
# Development modepuppeteer-mcp --dev
# Helppuppeteer-mcp --help
Programmatic Usage
Section titled “Programmatic Usage”// CommonJSconst { PuppeteerMCP } = require('puppeteer-mcp');
// ES Modulesimport { PuppeteerMCP } from 'puppeteer-mcp';
// Create instanceconst mcp = new PuppeteerMCP({ auth: { token: 'your-token', }, server: { port: 3000, },});
// Start serverawait mcp.start();
// Stop serverawait mcp.stop();
Integration Examples
Section titled “Integration Examples”// Express middlewareconst express = require('express');const { middleware } = require('puppeteer-mcp');
const app = express();app.use( '/browser', middleware({ auth: { token: process.env.AUTH_TOKEN }, }),);
Troubleshooting
Section titled “Troubleshooting”Installation Issues
Section titled “Installation Issues”Permission Denied
Section titled “Permission Denied”# Error: EACCES: permission deniednpm ERR! code EACCES
# Solution 1: Fix npm permissionsmkdir ~/.npm-globalnpm config set prefix '~/.npm-global'echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
# Solution 2: Use npx insteadnpx puppeteer-mcp
Puppeteer Download Failed
Section titled “Puppeteer Download Failed”# Error: Failed to download Chromium
# Solution 1: Skip downloadexport PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=trueexport PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
# Solution 2: Use proxyexport HTTPS_PROXY=http://proxy.company.com:8080
Platform-Specific Issues
Section titled “Platform-Specific Issues”# Linux: Missing dependenciessudo apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0
# macOS: Code signingxattr -d com.apple.quarantine /path/to/chrome
# Windows: Path issuesset PATH=%PATH%;C:\path\to\chrome
Runtime Issues
Section titled “Runtime Issues”Port Already in Use
Section titled “Port Already in Use”# Find processlsof -i :3000 # macOS/Linuxnetstat -ano | findstr :3000 # Windows
# Use different portPORT=3001 puppeteer-mcp
Memory Issues
Section titled “Memory Issues”# Increase Node.js memorynode --max-old-space-size=4096 $(which puppeteer-mcp)
# Limit browser sessionsMAX_SESSIONS=5 puppeteer-mcp
Maintenance
Section titled “Maintenance”Version Updates
Section titled “Version Updates”# Check for updatesnpm outdated -g puppeteer-mcp
# Update to latestnpm update -g puppeteer-mcp
# Update to specific versionnpm install -g puppeteer-mcp@1.1.2
Security Audits
Section titled “Security Audits”# Run security auditnpm audit
# Fix vulnerabilitiesnpm audit fix
# Force fixes (careful!)npm audit fix --force
Deprecation Notices
Section titled “Deprecation Notices”# Deprecate old versionnpm deprecate puppeteer-mcp@1.1.2 "Please upgrade to 1.0.0"
# Check deprecationnpm view puppeteer-mcp deprecated
Best Practices
Section titled “Best Practices”1. Semantic Versioning
Section titled “1. Semantic Versioning”- Use SemVer strictly
- Document breaking changes
- Maintain compatibility
2. Documentation
Section titled “2. Documentation”- Keep README updated
- Include migration guides
- Provide examples
3. Testing
Section titled “3. Testing”- Test before publishing
- Include integration tests
- Verify on multiple platforms
4. Security
Section titled “4. Security”- Regular security audits
- Quick patch releases
- Responsible disclosure
5. Community
Section titled “5. Community”- Respond to issues
- Accept contributions
- Maintain changelog
Distribution Channels
Section titled “Distribution Channels”NPM Registry
Section titled “NPM Registry”- Primary distribution
- Version management
- Download statistics
GitHub Releases
Section titled “GitHub Releases”- Source code archives
- Release notes
- Binary attachments
Docker Hub
Section titled “Docker Hub”- Container images
- Multi-arch support
- Version tags
CDN Distribution
Section titled “CDN Distribution”- For browser usage
- Minified versions
- Integrity hashes
Metrics & Analytics
Section titled “Metrics & Analytics”NPM Statistics
Section titled “NPM Statistics”# View download statsnpm view puppeteer-mcp
# Detailed stats at:# https://www.npmjs.com/package/puppeteer-mcp
Usage Tracking
Section titled “Usage Tracking”- Download counts
- Version adoption
- Platform distribution
- Dependency usage
Future Considerations
Section titled “Future Considerations”Planned Features
Section titled “Planned Features”- TypeScript declarations
- ESM support
- Smaller bundle size
- Plugin system
Breaking Changes
Section titled “Breaking Changes”- API redesign
- Dependency updates
- Node.js requirements
- Configuration format