A WebSocket-based browser REPL tool that provides programmatic access to browser sessions via CLI and MCP server.
- WebSocket server for browser REPL connections
- CLI tool for interactive JavaScript execution
- MCP server integration for seamless automation
- Playwright testing support
- Modular architecture for reusability
npm install
npm start
# or
browser-repl-server
The server will output connection codes for both browser and CLI.
Paste the provided JavaScript code into your browser's developer console.
Use the provided CLI command:
browser-repl --session YOUR_SESSION_ID --host localhost --port 8080
Add to your Claude MCP configuration:
{
"mcpServers": {
"browser-repl": {
"command": "node",
"args": ["src/mcp/mcp-server.js"],
"env": {
"REPL_HOST": "localhost",
"REPL_PORT": "8080",
"REPL_SESSION": "YOUR_SESSION_ID"
}
}
}
}
src/core/websocket.js
- Core WebSocket server implementationsrc/core/client.js
- WebSocket client for CLI connectionssrc/server/index.js
- Standalone WebSocket serversrc/cli/index.js
- Interactive CLI clientsrc/mcp/server.js
- MCP server wrappersrc/mcp/mcp-server.js
- MCP protocol implementation
npm test
import { WebSocketREPLServer } from './src/core/websocket.js';
const server = new WebSocketREPLServer({
port: 8080,
host: '0.0.0.0'
});
server.start();
import { WebSocketREPLClient } from './src/core/client.js';
const client = new WebSocketREPLClient({
host: 'localhost',
port: 8080,
sessionId: 'your-session-id'
});
await client.connect();
client.execute('document.title');
import { MCPBrowserREPLServer } from './src/mcp/server.js';
const mcpServer = new MCPBrowserREPLServer({
host: 'localhost',
port: 8080,
sessionId: 'your-session-id'
});
await mcpServer.initialize();
const result = await mcpServer.executeJavaScript('1 + 1');
MIT