home_router
Provides tools to control Nokia GPON home routers (e.g., G-2425G-A), enabling listing of connected devices, blocking/unblocking internet access via parental control rules, and managing access policies.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@home_routerCheck if my daughter's iPad is online"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Nokia / Airtel GPON Home Router API & Web Dashboard
Control, automate, and manage your Nokia G-2425G-A GPON Home Gateway (commonly deployed by Airtel Xstream Fiber and other ISPs) via Web Dashboard, MCP (Model Context Protocol), REST API, and CLI ā with persistent Device Nicknames (SQLite) and zero browser automation!
š” Why This Project?
The Problem
Most home fiber routers (such as Airtel's Nokia GPON ONT) do not provide an official API or integration for smart home ecosystems. Whenever you want to:
Check which devices are currently connected to your Wi-Fi,
Assign friendly nicknames (e.g. "Akanksha Phone", "Guestroom TV"),
Block internet access for a specific device (e.g., managing children's screen time),
Or automate network rules based on time or smart home states...
...you are forced to manually open a browser, navigate a sluggish web portal, type credentials, and click through multiple nested settings menus.
Worse, because the router's web portal uses a complex client-side hybrid encryption scheme (RSA-1024 + AES-128-CBC via custom SJCL JavaScript), simple curl scripts or standard HTTP requests fail. Most developers resort to heavy, brittle browser automation (like Selenium or Puppeteer).
The Solution
This project fully reverse-engineers the router's RSA + AES cryptographic handshake in pure Python.
It communicates directly with the router's internal endpoints with sub-second response times and zero browser overhead. It combines a local SQLite database to store persistent device metadata (nicknames, custom notes, first/last seen) and wraps that core engine into four ready-to-use interfaces:
š Web Dashboard ā Sleek dark glassmorphism web app with live search, nickname editing, and 1-click block/unblock toggles.
š¤ MCP Server ā Allows AI Agents (like Antigravity, Claude, Cursor) to control your Wi-Fi and block/unblock by friendly nicknames.
ā” REST API (FastAPI) ā Perfect for Home Assistant, webhooks, and custom automation.
š„ļø CLI ā Instant terminal commands and bash scripting.
Related MCP server: OpenWRT SSH MCP Server
šÆ Real-World Use Cases
1. š¤ AI Agent Voice & Chat Control (via MCP)
Connect this project to any MCP-compatible AI assistant (e.g., Claude Desktop, Antigravity IDE, Cursor). You can simply say:
"Set a nickname 'Akanksha Phone' for device f6:cf:28:1c:bd:e5."
"Block Guestroom TV from internet access."
"Is the Living Room TV connected to the Wi-Fi right now?"
"Unblock Akanksha Phone."
The AI agent will inspect your connected devices, resolve the target by nickname/hostname/IP/MAC, and execute the action on your router automatically.
2. š Visual Web Dashboard
Open http://localhost:8000/ to monitor all connected devices in a responsive web UI:
Live Stats Bar: Total Devices, Active Online, Blocked count, and Custom Nicknames count.
Instant Search & Filter: Filter by All, Online, Blocked, or Custom Nickname.
Inline Nickname Editor: Assign friendly nicknames and location notes to any device.
1-Click Block/Unblock: Toggle access with immediate in-flight loading spinners and toast notifications.
3. š Home Assistant Integration
Integrate your router into Home Assistant using the REST API:
Bedtime Automations: Automatically block children's tablets and gaming consoles at 10:00 PM on school nights.
Presence Detection: Trigger automations when specific phones join or leave the network.
Dashboard Toggles: Create dedicated "Block / Unblock Internet" switch buttons on your Home Assistant Lovelace dashboard.
⨠Features
š·ļø Persistent Device Nicknames ā Stored in SQLite (
data/router.db) so you can reference devices by human-friendly names like "Guestroom TV".šÆ Smart Multi-Target Resolution ā Block/unblock/query by Nickname, Hostname, IP address, or MAC address (supports partial/case-insensitive matching).
š List Connected Devices ā Hostname, IP address, MAC address, active online status, and connection interface (Ethernet, 2.4GHz 802.11, 5GHz 802.11ac).
š« Block Devices ā Block internet access 24/7 for any device via Parental Control rules.
ā Unblock Devices ā Remove blocking rules instantly.
š List Blocked Policies ā View all active access restriction policies and schedules.
š Auto-Sync & Self-Healing Sessions ā Automatic re-login and session recovery if router sessions expire.
š Zero Browser Overhead ā Pure cryptographic authentication via
pycryptodomeandrequests.
šļø Architecture: Four Ways to Interact
Interface | Best For | Entry Point |
Web Dashboard | Visual management, editing nicknames, live device list |
|
MCP Server | AI agents (Claude, Antigravity, Cursor) |
|
REST API | Home Assistant, Node-RED, custom automation |
|
CLI | Fast terminal access, cron jobs, shell scripts |
|
š¦ Installation
# Clone the repository
git clone https://github.com/surajnai567/airtel-router-api.git
cd airtel-router-api
# Install dependencies
pip install -r requirements.txtDependencies: requests, pycryptodome, python-dotenv, fastapi, uvicorn, mcp
āļø Configuration
Create a .env file in the root directory (or copy from .env.example):
ROUTER_IP=192.168.1.1
ROUTER_USERNAME=admin
ROUTER_PASSWORD=your_router_password
# Optional: REST API & Dashboard settings
API_HOST=0.0.0.0
API_PORT=8000š Security Note: The
.envanddata/*.dbfiles are included in.gitignoreso your router credentials and local database are never committed.
š 1. Web Dashboard & REST API
Start the server:
python -m api.serverOpen
http://localhost:8000/in your browser to view the Web Dashboard.Open
http://localhost:8000/docsfor interactive Swagger API documentation.
REST Endpoints
Method | Path | Description | Payload |
|
| List all connected devices with nicknames & blocked status | ā |
|
| List all blocked devices with nicknames | ā |
|
| Set or clear friendly nickname |
|
|
| Block device by Nickname, Hostname, IP, or MAC |
|
|
| Unblock device by Nickname, Hostname, IP, or MAC |
|
|
| Health check & router connection status | ā |
š¤ 2. MCP Server Usage (For AI Agents)
Expose router tools directly to AI agents using the Model Context Protocol (MCP).
Available MCP Tools
list_devices()ā Returns formatted table withNickname,Hostname,IP,MAC,Active,Blocked, andInterface.set_device_nickname(target, nickname, notes=None)ā Sets or updates a device's friendly nickname.block_device(target, policy_name=None)ā Blocks device by Nickname (e.g."Guestroom TV"), Hostname, IP, or MAC.unblock_device(target)ā Unblocks device by Nickname, Hostname, IP, or MAC.list_blocked_devices()ā Returns active blocked devices with their nicknames and policies.
MCP Configuration
Add this server to your MCP client config (e.g. claude_desktop_config.json or mcp_config.json):
{
"mcpServers": {
"home_router": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"cwd": "d:/project/routerapi"
}
}
}š„ļø 3. CLI Usage
# List all connected/known devices (with nicknames)
python -m cli.main list
# List all currently blocked devices
python -m cli.main blocked
# Block a device by MAC address or Nickname
python -m cli.main block AA:BB:CC:DD:EE:FF
# Block a device with a custom policy name
python -m cli.main block AA:BB:CC:DD:EE:FF --name "Kid_Tablet_Block"
# Unblock a device by MAC address
python -m cli.main unblock AA:BB:CC:DD:EE:FFš 4. Python Library Usage
from core import RouterAPI
# Initialize and authenticate
router = RouterAPI(ip_address="192.168.1.1", username="admin", password="admin_password")
if router.login():
# 1. Set a friendly nickname
router.set_nickname("f6:cf:28:1c:bd:e5", "Akanksha Phone")
# 2. Get all devices (auto-synced with SQLite)
devices = router.list_devices()
for d in devices:
print(f"[{'ONLINE' if d['active'] else 'OFFLINE'}] {d['nickname'] or d['hostname']} ({d['ip']}) - {d['mac']}")
# 3. Block directly by nickname!
router.block_device("Akanksha Phone")
# 4. Unblock by nickname!
router.unblock_device("Akanksha Phone")
# Clean up session
router.logout()š Project Structure
routerapi/
āāā core/ # Core business logic (the engine)
ā āāā __init__.py # Re-exports RouterAPI, DB helpers, and crypto
ā āāā client.py # RouterAPI client class with smart target resolution
ā āāā crypto.py # AES-CBC + RSA encryption implementation
ā āāā db.py # SQLite database layer for persistent nicknames
ā
āāā api/ # REST API & Web Dashboard
ā āāā __init__.py
ā āāā server.py # FastAPI server with CORS, static routes, & models
ā āāā static/ # Web Dashboard assets
ā āāā index.html # Dashboard HTML template
ā āāā style.css # Dark glassmorphism stylesheet
ā āāā app.js # Frontend state management & async API calls
ā
āāā mcp_server/ # Model Context Protocol interface
ā āāā __init__.py
ā āāā server.py # MCP server exposing router tools to AI
ā
āāā cli/ # Terminal interface
ā āāā __init__.py
ā āāā main.py # Argparse CLI entry point
ā
āāā data/ # Local SQLite storage (git-ignored)
ā āāā router.db # Persistent device metadata & nicknames
ā
āāā .env # Credentials (git-ignored)
āāā .env.example # Template environment configuration
āāā .gitignore
āāā requirements.txt # Project dependencies
āāā Readme.md # Project documentationā ļø Notes & Disclaimer
Session Expiry & Self-Healing: Router sessions naturally time out after inactivity. The API and MCP servers automatically manage re-authentication on subsequent calls.
Parental Control Compatibility: Supports both NEW firmware (
NPCProfileListgroup-based access control) and OLD firmware (pc_configaccess policies).Tested Hardware: Tested on Nokia G-2425G-A GPON Home Gateway (Airtel Xstream Fiber).
š License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Web search, browser automation, scraping, crawling and CAPTCHA solving for AI agents.
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
- mcp-serverOAuthcom.make
Give your AI agents the tools to build, manage, and run automation workflows.
Drive real Android & iOS devices and web browsers from natural language for mobile + web QA. 290+ tools across device control, app management, automation sessions, browser automation, and flow recording / replay. Bearer-auth ā get a token at robotactions.com ā Profile ā API Tokens.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Ubiquiti UniFi network infrastructure for monitoring devices, managing clients, and performing configuration tasks like blocking/unblocking devices and viewing network health.101GPL 3.0
- AlicenseAqualityFmaintenanceEnables AI agents to manage OpenWRT routers remotely via SSH, supporting system monitoring, network management, OpenThread Border Router configuration, and package management through natural language commands.1916MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to manage UniFi network infrastructure through 50+ tools covering devices, clients, networks, WiFi, firewall rules, and guest access using the official UniFi Network API.5243 npm5MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with direct access to multi-vendor network devices for tasks like configuration management, health checks, and topology discovery through 35 specialized tools. It enables natural language control over platforms including Cisco, Juniper, and Nokia using SSH, NETCONF, and SNMP protocols.11MIT