expo-devtools-mcp
by fysnerd
README.md
# expo-devtools-mcp
A Model Context Protocol (MCP) server for debugging Expo/React Native apps with Claude Code (or any MCP-compatible AI assistant).
**Control your React Native app directly from your AI assistant** - take screenshots, read logs, navigate, and more.

## Features
| Command | Description |
|---------|-------------|
| `take_screenshot` | Capture the current screen |
| `get_logs` | Get console logs from the app |
| `navigate` | Navigate to any Expo Router route |
| `scroll` | Scroll up/down/left/right |
| `tap` | Tap on registered elements |
| `fill` | Fill text inputs |
| `take_snapshot` | Get accessibility tree with element UIDs |
| `get_state` | Read Zustand store state |
| `connection_status` | Check if app is connected |
## Quick Start
### 1. Install the MCP server
```bash
npm install -g expo-devtools-mcp
```
Or add to your Claude Code MCP config (`~/.claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"expo-devtools": {
"command": "npx",
"args": ["expo-devtools-mcp"],
"env": {
"EXPO_DEVTOOLS_PORT": "19876"
}
}
}
}
```
### 2. Install the client in your Expo app
```bash
cd your-expo-app
npx expo install expo-devtools-client expo-file-system react-native-view-shot
```
### 3. Wrap your app with DevToolsProvider
```tsx
// app/_layout.tsx
import { DevToolsProvider } from 'expo-devtools-client';
export default function RootLayout() {
return (
<DevToolsProvider>
<Stack />
</DevToolsProvider>
);
}
```
### 4. Start your app and connect
```bash
# Terminal 1: Start Expo
npx expo start
# Terminal 2: Start Claude Code
claude
```
The app will automatically connect to the MCP server. You'll see in Metro logs:
```
[DevTools] Connected to MCP server!
```
## Configuration
### Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `EXPO_DEVTOOLS_PORT` | `19876` | WebSocket server port |
| `EXPO_DEVTOOLS_HOST` | Auto-detected | Your computer's IP address |
### Client Options
```tsx
<DevToolsProvider
enabled={__DEV__} // Only enable in dev mode (default: true)
port={19876} // WebSocket port (default: 19876)
host="192.168.1.100" // Override auto-detected IP
autoConnect={true} // Auto-connect on mount (default: true)
reconnectInterval={3000} // Reconnection delay in ms (default: 3000)
>
{children}
</DevToolsProvider>
```
## Usage Examples
### Take a screenshot
```
Claude: take a screenshot of the app
→ [Shows current screen]
```
### Navigate to a screen
```
Claude: navigate to the settings screen
→ Navigated to: /settings
```
### Debug with logs
```
Claude: show me the recent console logs
→ [LOG] User logged in
→ [ERROR] API call failed: 401
```
### Check app state
```
Claude: what's in the auth store?
→ { user: { id: 1, email: "..." }, isAuthenticated: true }
```
## Advanced: Register Interactive Elements
To enable `tap` and `fill` commands, register your interactive elements:
```tsx
import { useDevTools } from 'expo-devtools-client';
function LoginScreen() {
const { registerElement } = useDevTools();
const [email, setEmail] = useState('');
return (
<TextInput
ref={(ref) => registerElement({
ref,
type: 'textinput',
accessibilityLabel: 'Email input',
onChangeText: setEmail,
})}
value={email}
onChangeText={setEmail}
/>
);
}
```
## Advanced: Register Zustand Stores
To enable `get_state` command:
```tsx
import { useDevTools } from 'expo-devtools-client';
import { useAuthStore } from './stores/authStore';
function App() {
const { registerStore } = useDevTools();
useEffect(() => {
registerStore('auth', useAuthStore.getState);
}, []);
return <MyApp />;
}
```
## How It Works
```
┌─────────────────┐ WebSocket ┌─────────────────┐
│ Claude Code │ ◄─────────────────────────► │ Expo App │
│ (MCP Client) │ │ (DevToolsClient)│
└────────┬────────┘ └─────────────────┘
│
│ MCP Protocol
▼
┌─────────────────┐
│ MCP Server │
│ (This package) │
└─────────────────┘
```
1. The MCP server runs on your computer and listens for WebSocket connections
2. Your Expo app connects to the MCP server via WebSocket
3. Claude Code sends commands through MCP protocol
4. Commands are forwarded to the app, results returned to Claude
## Troubleshooting
### "Not connected to Expo Go app"
1. Make sure your phone/simulator is on the same network as your computer
2. Check the IP address in the DevToolsProvider logs
3. Try setting the host explicitly: `<DevToolsProvider host="YOUR_IP">`
### Screenshot returns small/corrupted image
Make sure you have `expo-file-system` installed:
```bash
npx expo install expo-file-system
```
### Connection drops frequently
Increase the reconnect interval:
```tsx
<DevToolsProvider reconnectInterval={5000}>
```
## Requirements
- Expo SDK 51+
- React Native 0.74+
- Node.js 18+
- Claude Code or any MCP-compatible client
## Contributing
Contributions welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
## License
MIT - see [LICENSE](LICENSE)
## Credits
Created by [@fysnerd](https://github.com/fysnerd)
Inspired by [Chrome DevTools MCP](https://github.com/anthropics/anthropic-quickstarts/tree/main/mcp-chrome-devtools)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues