mcp-fritzbox
A Model Context Protocol (MCP) server for interfacing with AVM FRITZ!Box routers. Control smart home devices, monitor network status, and administer your router through any MCP-compatible client.
README
mcp-fritzbox
A Model Context Protocol (MCP) server for interfacing with AVM FRITZ!Box routers (FRITZ!OS 8.20+). Control smart home devices, monitor network status, and administer your router through any MCP-compatible client.
Design Architecture
MCP Client (Claude Desktop, Claude Code, etc.)
│ stdio or HTTP/SSE
MCP Server (server.ts)
│ routes tool calls
├── SmartHomeClient ──→ REST API (/api/v0/smarthome/)
├── TR064Client ──────→ SOAP (TR-064 UPnP)
└── AuthProvider ─────→ SID login (login_sid.lua) + HTTP Digest
Components
| Component | File | Responsibility |
|---|---|---|
| AuthProvider | src/auth/auth-provider.ts |
MD5 challenge-response SID login, HTTP digest credentials for TR-064, lazy re-auth on session expiry |
| SmartHomeClient | src/client/smart-home.ts |
REST calls to the FRITZ!Box Smart Home API for thermostats and switches |
| TR064Client | src/client/tr064.ts |
SOAP calls for router administration (WAN status, bandwidth, guest WiFi, etc.) |
| HTTP Client | src/client/http.ts |
Shared axios instance with 403 interceptor for automatic SID renewal |
| MCP Server | src/server.ts |
Tool registration and error handling — maps MCP tool calls to client methods |
Tools
Smart Home
| Tool | Arguments | Output |
|---|---|---|
list_devices |
none | { smartHomeDevices: [...], networkDevices: [...] } — combined smart home actors and network hosts |
set_thermostat |
ain: string, temperature: number | "ON" | "OFF" |
Updated thermostat state (target temp, current temp, battery) |
toggle_switch |
ain: string, state: boolean |
Updated switch state with current power reading (mW) and total energy (Wh) |
get_device_stats |
ain: string |
Temperature history or energy consumption statistics |
Router Administration (TR-064)
| Tool | Arguments | Output |
|---|---|---|
get_system_info |
none | { modelName, firmwareVersion, serialNumber } |
get_wan_status |
none | { externalIp, connectionStatus, uptime, lastError } |
get_bandwidth_stats |
none | { totalBytesSent, totalBytesReceived, maxBitRateUp, maxBitRateDown } |
toggle_guest_wifi |
enable: boolean |
{ enabled, ssid, securityMode } |
get_device_log |
count?: number |
Array of recent system log lines (default: 20) |
reconnect_wan |
none | { message: "WAN reconnect initiated..." } — forces new external IP |
Setup Guide
1. Create a FRITZ!Box User
- Open your FRITZ!Box web UI at
http://fritz.box - Navigate to System → FRITZ!Box Users → Add User
- Set a username and password
- Enable these permissions:
- Smart Home — required for thermostat/switch control
- FRITZ!Box Settings — required for TR-064 (WAN status, guest WiFi, etc.)
- Access from the Internet — only if you need remote access
- Click Apply
2. Install
From GitHub:
git clone https://github.com/ghbalf/mcp-fritzbox.git
cd mcp-fritzbox
npm install
npm run build
3. Configure
Set environment variables:
export FRITZBOX_HOST=fritz.box # default, or use IP: 192.168.178.1
export FRITZBOX_USERNAME=your_user
export FRITZBOX_PASSWORD=your_pass
Or pass CLI flags:
node dist/index.js --host 192.168.178.1 --user admin --pass secret
CLI flags override environment variables.
4. Connect to an MCP Client
Claude Code — add a .mcp.json to your project root:
{
"mcpServers": {
"fritzbox": {
"command": "node",
"args": ["/path/to/mcp-fritzbox/dist/index.js"],
"env": {
"FRITZBOX_HOST": "fritz.box",
"FRITZBOX_USERNAME": "your_user",
"FRITZBOX_PASSWORD": "your_pass"
}
}
}
}
Claude Desktop — add to claude_desktop_config.json:
{
"mcpServers": {
"fritzbox": {
"command": "node",
"args": ["/path/to/mcp-fritzbox/dist/index.js"],
"env": {
"FRITZBOX_HOST": "fritz.box",
"FRITZBOX_USERNAME": "your_user",
"FRITZBOX_PASSWORD": "your_pass"
}
}
}
}
HTTP/SSE mode (for remote clients):
node dist/index.js --http --port 3000
# SSE endpoint: http://localhost:3000/sse
# Message endpoint: http://localhost:3000/messages
5. Verify Connection
FRITZBOX_USERNAME=your_user FRITZBOX_PASSWORD=your_pass npm run test:integration
Development
npm run start:dev # Run with tsx (no build needed)
npm run build # Compile TypeScript
npm test # Run unit tests
npm run test:watch # Watch mode
npm run test:integration # Live FRITZ!Box connection test
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
AUTH_FAILED (SID all zeros) |
Wrong username or password | Verify credentials in FRITZ!Box UI under System → FRITZ!Box Users |
CONNECTION_FAILED (ECONNREFUSED) |
FRITZ!Box unreachable | Check FRITZBOX_HOST — try IP address 192.168.178.1 instead of fritz.box |
CONNECTION_FAILED (ETIMEDOUT) |
Network issue or wrong port | Ensure you're on the same LAN; check no firewall blocks port 80/49000 |
403 Forbidden (persistent) |
User lacks permissions | Enable "Smart Home" and "FRITZ!Box Settings" in the user's FRITZ!Box permissions |
DEVICE_NOT_FOUND |
Invalid AIN | Run list_devices first to find valid Actor Identification Numbers |
INVALID_PARAMETER (temperature) |
Out of range | Temperature must be 8.0–28.0°C, or "ON" / "OFF" for boost/off mode |
| SOAP fault on guest WiFi | No guest network configured | Set up a guest network in FRITZ!Box UI first (WiFi → Guest Access) |
| TR-064 401 Unauthorized | Digest auth rejected | User needs "FRITZ!Box Settings" permission; some models require explicit TR-064 access |
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。