Skip to content

Commit 518303d

Browse files
authored
Merge pull request #4 from benjaminr/chore/mcp-docs
docs: clarify MCP CLI source and fix Claude Code path resolution issues
2 parents 480a16b + 8f03010 commit 518303d

File tree

1 file changed

+85
-19
lines changed

1 file changed

+85
-19
lines changed

README.md

Lines changed: 85 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ cd chrome-devtools-mcp
4545
mcp install server.py -n "Chrome DevTools MCP" --with-editable .
4646
```
4747

48+
> **Note**: The `mcp` command is part of the [Python MCP SDK](https://github.com/modelcontextprotocol/python-sdk). Install it with `pip install mcp` if not already available.
49+
4850
**All Installation Options:**
4951

5052
```bash
@@ -82,37 +84,61 @@ git clone https://github.com/benjaminr/chrome-devtools-mcp.git
8284
cd chrome-devtools-mcp
8385
```
8486

85-
2. **Install dependencies**
87+
2. **Install dependencies with UV (creates venv)**
8688
```bash
87-
uv sync # or pip install -r requirements.txt
89+
uv sync # Creates .venv and installs dependencies
8890
```
8991

90-
3. **Add MCP server using Claude CLI**
92+
3. **Add MCP server using Claude CLI with absolute paths**
9193

92-
**Quick setup (recommended):**
94+
**IMPORTANT**: Claude Code needs absolute paths to both the Python interpreter and the server script to work correctly.
95+
96+
**Recommended setup using absolute paths:**
9397
```bash
94-
# Add the server with environment variable
95-
claude mcp add chrome-devtools python server.py -e CHROME_DEBUG_PORT=9222
98+
# Get the absolute paths
99+
SERVER_PATH="$(pwd)/server.py"
100+
PYTHON_PATH="$(pwd)/.venv/bin/python"
101+
102+
# Add the server with absolute paths
103+
claude mcp add chrome-devtools "$PYTHON_PATH" "$SERVER_PATH" -e CHROME_DEBUG_PORT=9222
104+
```
105+
106+
**Alternative: Using the system Python (if dependencies are installed globally):**
107+
```bash
108+
# Only if you've installed dependencies globally
109+
claude mcp add chrome-devtools python "$(pwd)/server.py" -e CHROME_DEBUG_PORT=9222
96110
```
97111

98112
**With custom scope:**
99113
```bash
100114
# Add to user scope (available across all projects)
101-
claude mcp add chrome-devtools python server.py -s user -e CHROME_DEBUG_PORT=9222
115+
claude mcp add chrome-devtools "$(pwd)/.venv/bin/python" "$(pwd)/server.py" -s user -e CHROME_DEBUG_PORT=9222
102116

103117
# Add to project scope (only for this project)
104-
claude mcp add chrome-devtools python server.py -s project -e CHROME_DEBUG_PORT=9222
118+
claude mcp add chrome-devtools "$(pwd)/.venv/bin/python" "$(pwd)/server.py" -s project -e CHROME_DEBUG_PORT=9222
105119
```
106120

107121
4. **Verify installation**
108122
```bash
109123
# List configured MCP servers
110124
claude mcp list
111125

112-
# Get details about the server
126+
# Get details about the server (check that paths are absolute)
113127
claude mcp get chrome-devtools
128+
129+
# The output should show absolute paths like:
130+
# Command: /Users/you/chrome-devtools-mcp/.venv/bin/python
131+
# Args: ["/Users/you/chrome-devtools-mcp/server.py"]
114132
```
115133

134+
**Common Path Issues and Solutions:**
135+
- **Problem**: "python: command not found" or "server.py not found"
136+
- **Solution**: Use absolute paths as shown above
137+
- **Problem**: "ModuleNotFoundError" when server starts
138+
- **Solution**: Use the venv Python interpreter that has dependencies installed
139+
- **Problem**: Server doesn't start or shows as disconnected
140+
- **Solution**: Test the command manually: `/path/to/.venv/bin/python /path/to/server.py`
141+
116142
### Option 4: Manual Claude Desktop Setup
117143

118144
1. **Clone this repository**
@@ -470,7 +496,7 @@ If the server appears in Claude but shows as "disabled", try these steps:
470496
4. **Restart Claude Desktop** completely (quit and reopen)
471497

472498
### Installation Issues
473-
- **MCP CLI not found**: Install MCP CLI with `pip install mcp` or `npm install -g @modelcontextprotocol/cli`
499+
- **MCP CLI not found**: Install MCP CLI from the [Python MCP SDK](https://github.com/modelcontextprotocol/python-sdk) with `pip install mcp`
474500
- **Server not appearing in Claude**:
475501
- For MCP CLI: Run `mcp list` to verify the server is installed
476502
- For manual setup: Check Claude Desktop configuration file path and JSON syntax
@@ -520,10 +546,32 @@ claude mcp list
520546
# Get details about a specific server
521547
claude mcp get chrome-devtools
522548

549+
# IMPORTANT: Verify paths are absolute, not relative
550+
# Good example output:
551+
# Command: /Users/you/chrome-devtools-mcp/.venv/bin/python
552+
# Args: ["/Users/you/chrome-devtools-mcp/server.py"]
553+
# Bad example output:
554+
# Command: python
555+
# Args: ["server.py"]
556+
557+
# Test the exact command Claude Code will use
558+
/path/to/.venv/bin/python /path/to/server.py
559+
523560
# Check if server is working
524561
claude mcp serve --help
525562
```
526563

564+
**Step 3.5: Fix Path Issues (Claude Code specific)**
565+
```bash
566+
# If paths are relative, remove and re-add with absolute paths
567+
claude mcp remove chrome-devtools
568+
569+
# Re-add with absolute paths
570+
SERVER_PATH="$(pwd)/server.py"
571+
PYTHON_PATH="$(pwd)/.venv/bin/python"
572+
claude mcp add chrome-devtools "$PYTHON_PATH" "$SERVER_PATH" -e CHROME_DEBUG_PORT=9222
573+
```
574+
527575
**Step 4: Reinstall if Needed**
528576

529577
**For MCP CLI:**
@@ -554,6 +602,9 @@ claude mcp add chrome-devtools python server.py -s user -e CHROME_DEBUG_PORT=922
554602
| "Import error" | Check `pip install mcp websockets aiohttp` |
555603
| "Permission denied" | Use absolute paths in config |
556604
| "Server disabled" | Check Claude Desktop logs, restart Claude |
605+
| "python: command not found" (Claude Code) | Use absolute path to venv Python: `/path/to/.venv/bin/python` |
606+
| "server.py: No such file" (Claude Code) | Use absolute path to server: `/path/to/server.py` |
607+
| "ModuleNotFoundError" (Claude Code) | Use venv Python that has dependencies installed |
557608

558609
### Manual Configuration Fallback
559610

@@ -575,22 +626,37 @@ If MCP CLI isn't working, add this to Claude Desktop config manually:
575626
```
576627

577628
**For Claude Code:**
578-
If the `claude mcp add` command isn't working, you can use the JSON format:
629+
If the `claude mcp add` command isn't working, you can use the JSON format with absolute paths:
579630

580631
```bash
581-
# Add server using JSON configuration
582-
claude mcp add-json chrome-devtools '{
583-
"command": "python3",
584-
"args": ["'$(pwd)'/server.py"],
585-
"env": {
586-
"CHROME_DEBUG_PORT": "9222"
632+
# Get absolute paths first
633+
SERVER_PATH="$(pwd)/server.py"
634+
PYTHON_PATH="$(pwd)/.venv/bin/python"
635+
636+
# Add server using JSON configuration with absolute paths
637+
claude mcp add-json chrome-devtools "{
638+
\"command\": \"$PYTHON_PATH\",
639+
\"args\": [\"$SERVER_PATH\"],
640+
\"env\": {
641+
\"CHROME_DEBUG_PORT\": \"9222\"
587642
}
588-
}'
643+
}"
589644

590-
# Or import from Claude Desktop if you have it configured there
645+
# Or if you have it working in Claude Desktop, import from there
591646
claude mcp add-from-claude-desktop
592647
```
593648

649+
**Example of correct Claude Code configuration (with absolute paths):**
650+
```json
651+
{
652+
"command": "/Users/you/chrome-devtools-mcp/.venv/bin/python",
653+
"args": ["/Users/you/chrome-devtools-mcp/server.py"],
654+
"env": {
655+
"CHROME_DEBUG_PORT": "9222"
656+
}
657+
}
658+
```
659+
594660
### Connection Issues
595661
- **Chrome won't start**: The MCP server will start Chrome automatically when you use `start_chrome()`
596662
- **Can't connect**: Try `get_connection_status()` to check the connection

0 commit comments

Comments
 (0)