API Reference
API Reference
Section titled “API Reference”Complete API reference documentation for Puppeteer MCP’s multi-protocol interfaces.
Available APIs
Section titled “Available APIs”RESTful HTTP API for browser automation:
- Session management endpoints
- Browser action endpoints
- Authentication methods
- Response formats
- Error codes
High-performance gRPC service:
- Protocol buffer definitions
- Service methods
- Streaming capabilities
- Client examples
- Performance considerations
Real-time WebSocket interface:
- Connection management
- Message protocols
- Event subscriptions
- Bidirectional communication
- Connection lifecycle
Model Context Protocol tools for AI assistants:
- Available tools listing
- Parameter specifications
- Response formats
- Integration patterns
- Claude Desktop usage
Comprehensive Puppeteer action reference:
- Navigation methods
- Interaction methods
- Content methods
- Wait strategies
- Advanced options
Quick Links
Section titled “Quick Links”By Protocol
Section titled “By Protocol”- HTTP/REST: Standard web API - REST API
- gRPC: High-performance RPC - gRPC API
- WebSocket: Real-time events - WebSocket API
- MCP: AI integration - MCP Tools
By Function
Section titled “By Function”- Session Management: Create, list, and close browser sessions
- Page Navigation: Navigate, reload, and manage history
- Element Interaction: Click, type, select, and fill forms
- Content Extraction: Screenshot, PDF, and JavaScript evaluation
- Synchronization: Wait for elements and navigation
API Comparison
Section titled “API Comparison”Feature | REST | WebSocket | gRPC | MCP |
---|---|---|---|---|
Request/Response | ✅ | ✅ | ✅ | ✅ |
Streaming | ❌ | ✅ | ✅ | ❌ |
Binary Data | ✅ | ✅ | ✅ | ✅ |
Easy Integration | ✅ | ✅ | ⚠️ | ✅ |
Performance | Good | Good | Best | Good |
AI Assistant Support | ❌ | ❌ | ❌ | ✅ |
Authentication
Section titled “Authentication”All APIs use the same authentication token:
# REST APIAuthorization: Bearer YOUR_TOKEN
# WebSocket{ "type": "auth", "token": "YOUR_TOKEN" }
# gRPC (metadata)authorization: Bearer YOUR_TOKEN
# MCP (environment)PUPPETEER_MCP_AUTH_TOKEN=YOUR_TOKEN
Common Patterns
Section titled “Common Patterns”Session Lifecycle
Section titled “Session Lifecycle”// 1. Create sessionconst session = await createSession({ baseUrl: 'https://example.com' });
// 2. Perform actionsawait navigate(session.id, { url: '/page' });await click(session.id, { selector: '#button' });
// 3. Get resultsconst content = await getContent(session.id);
// 4. Clean upawait closeSession(session.id);
Error Handling
Section titled “Error Handling”try { const result = await browserAction(sessionId, params);} catch (error) { if (error.code === 'SESSION_NOT_FOUND') { // Handle missing session } else if (error.code === 'TIMEOUT') { // Handle timeout }}
Response Formats
Section titled “Response Formats”Success Response
Section titled “Success Response”{ "success": true, "data": { // Response data }, "metadata": { "timestamp": "2025-01-05T10:00:00Z", "duration": 123 }}
Error Response
Section titled “Error Response”{ "success": false, "error": { "code": "ERROR_CODE", "message": "Human-readable error message", "details": { // Additional error context } }}
Rate Limits
Section titled “Rate Limits”Default limits per authentication token:
API | Limit | Window |
---|---|---|
REST | 100 requests | 15 minutes |
WebSocket | 1000 messages | 15 minutes |
gRPC | 1000 calls | 15 minutes |
MCP | No limit | - |
Quick Start Examples
Section titled “Quick Start Examples”REST API
Section titled “REST API”curl -X POST http://localhost:8443/api/sessions \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"baseUrl": "https://example.com"}'
WebSocket
Section titled “WebSocket”const ws = new WebSocket('ws://localhost:8443');ws.send(JSON.stringify({ type: 'auth', token: 'YOUR_TOKEN' }));
const client = new BrowserAutomation('localhost:50051', credentials);const session = await client.createSession({ baseUrl: 'https://example.com' });
Claude: "Navigate to example.com and take a screenshot"
API Selection Guide
Section titled “API Selection Guide”Choose the right API for your use case:
- REST API: Best for simple integrations, one-off requests
- WebSocket: Best for real-time updates, event streaming
- gRPC: Best for high-performance, microservices
- MCP: Best for AI assistants, natural language control