# Device Scanner MCP

An MCP (Model Context Protocol) server that detects WiFi, Ethernet, and USB devices — and lets you SSH into them, deploy files, run tests, and manage services, all through Claude Code.

**Works with any company/product** — all config lives in `.env`.

## Features

- **23 tools** covering scanning, SSH, SCP, deployment, testing, health checks, logs, services, and more
- **WiFi-hop**: auto-switches WiFi to a device (no internet), runs commands, switches back
- **Ethernet/USB**: direct SSH — no hopping needed
- **Multi-device**: run commands across multiple devices in one call
- **GTest parser**: structured pass/fail results from test binaries
- **Zero hardcoded secrets** — everything in `.env`

## Quick Install

### For Claude Code users

```bash
claude mcp add device-scanner -- uvx device-scanner-mcp
```

Or with pip:

```bash
pip install device-scanner-mcp
claude mcp add device-scanner -- python -m device_scanner_mcp
```

### Setup

1. Create a `.env` file in your working directory (copy from `.env.example`):

```env
COMPANY_NAME=MyCompany
OFFICE_SSIDS=Office-WiFi,Guest-WiFi
DEVICE_PREFIXES=MYDEVICE_,SENSOR_
DEVICE_MYDEVICE=192.168.4.1,192.168.5.1,,root,password
DEVICE_ALIASES=Robot:MYDEVICE
```

2. Run Claude Code and start using the tools.

## Tools

### Scanning
| Tool | Description |
|------|-------------|
| `scan_wifi` | List visible WiFi networks |
| `scan_network_adapters` | List Ethernet/WiFi/BT adapters |
| `scan_usb_devices` | List USB devices |
| `scan_all_connections` | All of the above |

### Direct SSH/SCP (Ethernet & USB)
| Tool | Description |
|------|-------------|
| `device_ssh` | Run commands on device |
| `device_ssh_batch` | Run a script on device |
| `device_scp_push` | Push file to device |
| `device_scp_pull` | Pull file from device |
| `device_ping` | Check device reachability |
| `multi_device_ssh` | Run commands on multiple devices |

### WiFi Hop (auto switches WiFi back and forth)
| Tool | Description |
|------|-------------|
| `wifi_hop_ssh` | Hop + run commands + hop back |
| `wifi_hop_ssh_batch` | Hop + run script + hop back |
| `wifi_hop_scp_push` | Hop + push file + hop back |
| `wifi_hop_scp_pull` | Hop + pull file + hop back |

### Device Management
| Tool | Description |
|------|-------------|
| `device_deploy` | Tar + push + extract in one call |
| `device_health` | CPU, RAM, disk, temp, uptime |
| `device_reboot` | Reboot + wait for recovery |
| `device_run_tests` | Run test binaries, parse GTest results |
| `device_logs` | Fetch dmesg, syslog, journal logs |
| `device_service` | Start/stop/restart systemd services |
| `device_process_list` | List running processes |

### WiFi Management
| Tool | Description |
|------|-------------|
| `wifi_switch` | Switch between office WiFi networks |
| `wifi_status` | Current WiFi connection info |

## .env Configuration

See [.env.example](.env.example) for full documentation. Key settings:

```env
# Company
COMPANY_NAME=MyCompany

# Office WiFi (with internet)
OFFICE_SSIDS=Office-5G,Guest-WiFi

# Device SSID prefixes (no internet)
DEVICE_PREFIXES=ROBOT_,SENSOR_

# Device profiles: wifi_ip,eth_ip,usb_ip,user,password
DEVICE_ROBOT=192.168.4.1,192.168.5.1,192.168.6.1,root,password

# Aliases: product_name:ssid_prefix
DEVICE_ALIASES=MainRobot:ROBOT
```

## License

MIT
