Hover diagram boxes and action pills to see explanations and matching code highlights. Animations show how traffic moves through the stack.
Hover the Client, MikroTik, mtk-serve, Upstream, and Dashboard shapes β your browser shows a tooltip from each blockβs description.
The MTK SDK orchestrates testing across three layers: client traffic flows through MikroTik (network shaping), then mtk-serve (HTTP interception), reaching upstream APIs. This dashboard controls all layers via WebSocket and REST.
Network shaping, DNS, HTTP proxy rules, scenarios, HAR recording, and pytest fixtures. The accordions below map to MtkTestKit and the dashboard tabs.
Simulate real-world network conditions: bandwidth throttling, latency injection, packet loss, and connection interrupts.
Redirect domain resolution to capture traffic or test with different backends.
Mock API responses, inject errors, add delays. Hover each step for what it means in practice; hover the pills to light up the matching Python below.
Pre-built test flows combining network, DNS, and proxy actions. Run complex test scenarios with a single command.
Simulates geo-blocking by returning 403 Forbidden on specific endpoints
Tests premium, trial, and expired user states via API mocking
Progressive network quality decrease: 4G β 3G β 2G β Edge
Random 5xx errors on API calls to test retry logic
Simulates 10-second offline period then recovery
Capture HTTP sessions as HAR files for replay testing, golden file comparison, and regression testing.
Built-in fixtures and markers for seamless pytest integration.
pip install Install with: pip install mtk-router-sdk[dev]
markers Available markers: @pytest.mark.slow_network, @pytest.mark.offline, @pytest.mark.premium, @pytest.mark.mtk
L2TP tunnels on the router, policy routing per WiβFi slot, and CLI helpers for debugging stuck sessions. Requires SSH to the router and a valid site.json when using slot routing.
List L2TP clients, inspect a tunnel, reset it, or point a slotβs traffic at a tunnel interface (routing mark from site JSON).
REST mtk-serve exposes GET /v1/vpn/clients, POST /v1/slots/{id}/vpn, POST /v1/by-client/vpn, POST /v1/by-ssid/vpn β see the API table below.
SSH-backed commands and the shared RouterClient used by discovery, bootstrap, and exec. Prefer mtk doctor before deeper scripting.
doctor connects (env or --site) and runs capability discovery. exec runs a single RouterOS command and prints JSON. interfaces / ip dump terse tables as JSON.
REST GET /v1/doctor, GET /v1/discovery/profile, POST /v1/discovery/refresh, GET /v1/dashboard/snapshot.
Generate a plan from site.json plus discovery; default is dry-run. Add --apply to push scripts to the router.
REST POST /v1/bootstrap/dry-run, POST /v1/bootstrap.
Resolve a device IP to a slot, block internet per client (runtime firewall), and (via REST) renew or release DHCP leases by IP or SSID.
REST GET /v1/client/resolve, POST /v1/client/block, POST /v1/client/unblock, GET /v1/client/blocked, GET /v1/client/blocked/{ip}, GET /v1/dhcp/leases.
RouterOS /tool sniffer on a slot bridge, filtered to one IPv4; .pcap saved on the router for download or analysis.
REST POST /v1/slots/{id}/sniffer/start, POST /v1/slots/{id}/sniffer/stop, and by-client / by-ssid variants under /v1/by-client/sniffer/*, /v1/by-ssid/sniffer/*.
Beyond mock responses: modify JSON and headers, clear rules, search logs, and manage MITM certificates. Same surface as ProxyClient / kit.proxy when mtk-serve is up.
REST POST /v1/proxy/rules (action modify), POST /v1/proxy/clear, GET /v1/proxy/log, DELETE /v1/proxy/log, GET|POST /v1/proxy/certs, GET /v1/proxy/certs/ca.
Physical lab layout, SSH targets, slot SSIDs, and optional mtk-serve URL for the testing kit. mtk init-site scaffolds a file; env vars override file fields where documented.
Common environment variables (see package docs for the full list):
MTK_SITE_CONFIG β path to site.json (mtk-serve / tooling)MTK_HOST, MTK_USER, MTK_PASSWORD, MTK_PORT β SSH to the routerMTK_SERVICE_URL, MTK_HTTP_PORT, MTK_SERVICE_TOKEN β mtk-serve base URL and optional authMTK_TEST_CLIENT_IP, MTK_PROFILES_DIR, MTK_SCENARIOS_DIR, MTK_RECORDINGS_DIR β testing kit defaultsREST GET|PUT /v1/config/slots, GET|PATCH /v1/config.
Recorder sessions can be diffed against a golden HAR. In tests, TrackedMtkTestKit wraps the kit and reverts network/DNS/proxy mutations after each case.
ChangeTracker records operations from wrapped network, dns, and proxy objects. tracked.teardown() clears them via the underlying MtkTestKit; use tracker.session(kit) for a context-managed scope.
Curated routes the dashboard and SDK call. Base URL is your mtk-serve origin (e.g. http://router:8780). WebSocket /v1/stream pushes live events.
OpenAPI merges these under /v1/*. Methods and paths below match v1_routes.py.
| Method | Path | Summary |
|---|---|---|
| GET | /v1/version | Service version |
| GET | /v1/doctor | Health / discovery snapshot |
| POST | /v1/session | Session cookie helpers |
| DELETE | /v1/session | Clear session |
| GET | /v1/discovery/profile | Capability profile |
| POST | /v1/discovery/refresh | Re-run discovery |
| GET | /v1/dashboard/snapshot | Aggregate UI snapshot |
| GET | /v1/wireless | Wireless table |
| GET | /v1/vpn/clients | L2TP clients |
| GET | /v1/dhcp/leases | DHCP leases |
| GET | /v1/routing/policy | Policy routing |
| GET/PATCH | /v1/config | Site config |
| GET/PUT | /v1/config/slots | Slot definitions |
| POST | /v1/bootstrap/dry-run | Bootstrap plan |
| POST | /v1/bootstrap | Apply bootstrap |
| POST | /v1/slots/{id}/control/lease | Lease control |
| POST | /v1/slots/{id}/control/lease/release | Release lease |
| GET | /v1/slots/{id}/control/status | Control status |
| GET | /v1/slots/{id}/vpn/status | Slot VPN status |
| POST | /v1/slots/{id}/vpn | Set slot VPN gateway |
| GET | /v1/slots/{id} | Slot detail |
| POST | /v1/slots/{id}/sniffer/start | Start sniffer |
| POST | /v1/slots/{id}/sniffer/stop | Stop sniffer |
| GET | /v1/client/resolve | Resolve IP β slot |
| POST | /v1/by-client/control/lease | Lease by client IP |
| POST | /v1/by-client/control/lease/release | Release by client IP |
| POST | /v1/by-client/vpn | VPN by client IP |
| POST | /v1/by-client/sniffer/start | Sniffer by client IP |
| POST | /v1/by-client/sniffer/stop | Stop sniffer by client |
| POST | /v1/by-ssid/control/lease | Lease by SSID |
| POST | /v1/by-ssid/control/lease/release | Release by SSID |
| POST | /v1/by-ssid/vpn | VPN by SSID |
| POST | /v1/by-ssid/sniffer/start | Sniffer by SSID |
| POST | /v1/by-ssid/sniffer/stop | Stop sniffer by SSID |
| POST | /v1/ai/intent | AI intent (experimental) |
| POST | /v1/client/block | Block client internet |
| POST | /v1/client/unblock | Unblock client |
| GET | /v1/client/blocked | List blocked IPs |
| GET | /v1/client/blocked/{ip} | Blocked status for IP |
| WS | /v1/stream | Live event stream |
| GET | /v1/proxy/status | Proxy status |
| GET/POST | /v1/proxy/rules | List / create rules |
| PUT/DELETE | /v1/proxy/rules/{rule_id} | Update / delete rule |
| DELETE | /v1/proxy/rules | Clear all rules |
| POST | /v1/proxy/set | Quick mock response |
| POST | /v1/proxy/error | Quick error response |
| POST | /v1/proxy/clear | Clear by client/path |
| GET | /v1/proxy/log | Request log |
| DELETE | /v1/proxy/log | Clear log |
| GET|POST | /v1/proxy/certs | Cert status / generate |
| GET | /v1/proxy/certs/ca | Download CA |