chrome-mcp
Version:
Model Context Protocol (MCP) server for controlling Google Chrome browser on macOS. Enables AI assistants like Claude to automate Chrome via DevTools Protocol.
227 lines (166 loc) β’ 6.06 kB
Markdown
# Getting Started with Chrome MCP Server
Congratulations! Your Chrome MCP server has been successfully created. π
## What You Got
This project is a fully functional **Model Context Protocol (MCP) server** that allows Claude Desktop to control your Google Chrome browser on macOS.
### Project Structure
```
chrome-mcp/
βββ src/
β βββ index.ts # Main MCP server implementation
β βββ chrome-controller.ts # Chrome automation controller
βββ build/ # Compiled JavaScript output
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ README.md # Full documentation
βββ CLAUDE_DESKTOP_SETUP.md # Step-by-step setup guide
βββ .gitignore # Git ignore rules
```
## Quick Start (3 Steps)
### Step 1: Verify Build (Already Done!)
The project has been built successfully. If you need to rebuild:
```bash
cd /Users/Apple/Documents/GitHub/chrome-mcp
pnpm run build
```
### Step 2: Configure Claude Desktop
Edit your Claude Desktop config:
```bash
open ~/Library/Application\ Support/Claude/claude_desktop_config.json
```
Add this configuration:
```json
{
"mcpServers": {
"chrome": {
"command": "node",
"args": ["/Users/Apple/Documents/GitHub/chrome-mcp/build/index.js"]
}
}
}
```
### Step 3: Enable Chrome Developer Mode
Open Chrome and enable: **View** β **Developer** β **Allow JavaScript from Apple Events**
Then restart Claude Desktop!
## What Can Claude Do Now?
Once connected, Claude can:
β
**Navigate the web**
- "Open google.com in Chrome"
- "Go to github.com"
β
**Interact with pages**
- "Click the search button"
- "Type 'hello world' in the search box"
- "Execute JavaScript to change the page background"
β
**Inspect pages**
- "What's the title of this page?"
- "Get all the visible text from this webpage"
- "Take a screenshot"
β
**Manage tabs**
- "Open a new tab"
- "List all my open Chrome tabs"
- "Close the current tab"
β
**Navigate history**
- "Go back"
- "Go forward"
- "Reload the page"
## Available Tools (15 Total)
| Tool | Purpose |
|------|---------|
| `chrome_navigate` | Go to a URL |
| `chrome_get_current_url` | Get current page URL |
| `chrome_get_title` | Get page title |
| `chrome_get_content` | Get HTML content |
| `chrome_get_visible_text` | Get visible text |
| `chrome_execute_script` | Run JavaScript |
| `chrome_click` | Click an element |
| `chrome_type` | Type into an input |
| `chrome_screenshot` | Take screenshot |
| `chrome_open_new_tab` | Open new tab |
| `chrome_close_tab` | Close tab |
| `chrome_list_tabs` | List all tabs |
| `chrome_reload` | Reload page |
| `chrome_go_back` | Navigate back |
| `chrome_go_forward` | Navigate forward |
## Technical Details
### Technologies Used
- **TypeScript** - Type-safe JavaScript
- **@modelcontextprotocol/sdk** - MCP protocol implementation
- **chrome-launcher** - Launch and manage Chrome
- **chrome-remote-interface** - Chrome DevTools Protocol client
- **Node.js 18+** - Runtime environment
### How It Works
1. **MCP Server** (`src/index.ts`) runs as a stdio server
2. **Claude Desktop** communicates with it via MCP protocol
3. **ChromeController** (`src/chrome-controller.ts`) uses:
- Chrome DevTools Protocol (CDP) for browser automation
- AppleScript for Mac-specific features (tab management)
### Architecture
```
βββββββββββββββββββ
β Claude Desktop β
ββββββββββ¬βββββββββ
β MCP Protocol (stdio)
β
ββββββββββΌβββββββββ
β MCP Server β (Your server)
β src/index.ts β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββββββ
β Chrome Controller β
β src/chrome- β
β controller.ts β
ββββββββββ¬βββββββββββββ
β
ββββββ΄βββββ¬βββββββββββββ
β β β
βββββΌβββ ββββΌβββββββ ββββΌββββββ
β CDP β βAppleScr.β βChrome β
ββββββββ βββββββββββ ββββββββββ
```
## Development Commands
```bash
# Install dependencies
pnpm install
# Build the project
pnpm run build
# Watch mode (auto-rebuild on changes)
pnpm run watch
# Start the server standalone
pnpm start
```
## Next Steps
1. β
**Project created and built**
2. π **Read CLAUDE_DESKTOP_SETUP.md** for detailed setup
3. π§ **Configure Claude Desktop** with the MCP server
4. π **Start using Chrome automation** with Claude!
## Documentation
- **README.md** - Full project documentation
- **CLAUDE_DESKTOP_SETUP.md** - Detailed setup instructions
- **This file** - Quick start guide
## Need Help?
### Common Issues
**Issue**: Chrome won't connect
**Solution**: Enable "Allow JavaScript from Apple Events" in Chrome
**Issue**: Permission denied
**Solution**: Grant accessibility permissions to your terminal
**Issue**: MCP server not showing in Claude
**Solution**: Check the path in `claude_desktop_config.json` is absolute
### Check Logs
```bash
# Claude Desktop logs
tail -f ~/Library/Logs/Claude/mcp*.log
# Check if Chrome remote debugging is active
lsof -i :9222
```
## Security Note
β οΈ This server has full control over your Chrome browser. Only use it with trusted AI assistants like Claude Desktop. Be careful when executing JavaScript or interacting with sensitive pages.
## Contributing
Feel free to extend this project:
- Add more Chrome DevTools Protocol features
- Implement additional automation capabilities
- Improve error handling
- Add tests
## License
MIT - Feel free to use and modify!
---
**Ready to go?** Read `CLAUDE_DESKTOP_SETUP.md` for the full setup process! π