
Local daemon plus in-app SDK for inspecting and mocking mobile network traffic during development, live HTTP and socket inspection, per-device mock rules, Socket.IO/WebSocket ack and reply support.
English | 繁體中文
Waffle captures HTTP and Socket traffic from your debug app and lets you mock responses from a local UI or MCP client. The Kotlin Multiplatform SDK supports OkHttp, Ktor Client, Socket.IO, and Ktor WebSocket.
We built Waffle after Flipper was archived and our setup needed to support Android 16 KB memory pages.
With the daemon running and the SDK installed, open http://localhost:9091, launch your debug app, and select its device.
Rules run inside the SDK on the selected device. HTTP mocks answer before the network;
socket ack rules answer locally. Mock bodies support ${randomId}, ${now} and
${randomString(min~max)}.
Use /users/{id} in an HTTP mock to match a single path segment. Under Request conditions, combine Request headers, Query parameters, and JSON Body conditions. Select headers from the latest matching request or add them manually. Every specified
condition must match; other object fields are ignored. Mock this path defaults to
Path only. Choose the captured query, complete JSON object body, or both from the menu, then press the main button to create the rule.
Mock this ack defaults to Event only; its menu can include JSON object fields from
the first outgoing argument. Response data stays separate from these conditions. The device
SDK must support the selected conditions.
HTTP and Socket editors keep Request conditions collapsed by default. Creating a mock with captured conditions expands them automatically and selects the matching tab (Body when both query and body are included). Each device's rules remember their expanded state and the selected condition tab in this browser, including after closing the panel or reloading. Delay settings remain beside the response. Break on this path matches the HTTP method and path only, ignoring query and body conditions. Choose Remove breakpoint to remove that breakpoint.
Use MCP copy_mock_with_fields to replace specified JSON fields in a disabled, device-local copy. The original rule stays unchanged; no SDK update is needed. In the UI, use Copy and edit the response body. See field-copy details.
waffle mcp lets an AI client inspect HTTP and Socket traffic, edit mocks, inject events, and control response breakpoints. It connects to a running daemon. MCP itself requires no additional app SDK integration.
See example prompts and setup for client configuration, tools, and data masking.
The daemon runs on your dev machine. It serves the browser UI, stores mock rules and
keeps adb reverse alive for Android devices.
Requires Node.js 20+, plus adb on your PATH for Android.
npm install -g @dev-weiqi/waffle
waffle startThe UI opens at http://localhost:9091. Without installing:
npx @dev-weiqi/waffle startIf port 9091 is taken, Waffle offers to free it, or pick another port:
PORT=9092 waffle startThe daemon binds to 127.0.0.1 by default. Android (adb reverse), the iOS simulator
and a USB-connected iPhone reach it over localhost. Only a device on Wi-Fi needs it
opened up, together with host in the app (see Start Waffle):
WAFFLE_BIND=0.0.0.0 waffle startUpdate, or pin a version:
npm install -g @dev-weiqi/waffle@latest
npm install -g @dev-weiqi/waffle@1.0.0The macOS app bundles the daemon and UI in one window. Install Node.js
20+ before using it. Download the
.dmg from Releases
(Waffle-server-mac-aarch64.dmg for Apple Silicon, Waffle-server-mac-x64.dmg for
Intel) and drag Waffle.app into /Applications. The port is set in the app's settings.
The dmg is not notarized yet. If macOS says "Waffle is damaged", clear the quarantine flag once:
xattr -d com.apple.quarantine /Applications/Waffle.appAdd core plus the modules for the clients you use. Use the -noop twins in release
builds: same API, empty implementation.
| Client | Waffle artifact |
|---|---|
| OkHttp | io.github.dev-weiqi.waffle:okhttp |
| Ktor Client | io.github.dev-weiqi.waffle:ktor |
| Socket.IO | io.github.dev-weiqi.waffle:socketio |
| Ktor WebSocket | io.github.dev-weiqi.waffle:ktor-ws |
val waffleVersion = "1.0.0"
dependencies {
debugImplementation("io.github.dev-weiqi.waffle:core:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:core-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:okhttp:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:okhttp-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:ktor:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:ktor-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:socketio:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:socketio-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:ktor-ws:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:ktor-ws-noop:$waffleVersion")
}For KMP shared code, add the modules to commonMain:
commonMain.dependencies {
implementation("io.github.dev-weiqi.waffle:core:$waffleVersion")
implementation("io.github.dev-weiqi.waffle:ktor:$waffleVersion")
implementation("io.github.dev-weiqi.waffle:ktor-ws:$waffleVersion")
}The SDK owns its plain WebSocket connection to localhost:9091, using the same
socket and WebSocket primitives as its USB transport. Apps do not need to add a
Ktor client engine for Waffle, and Waffle does not register an engine that could
change the app's own HttpClient() selection. Android apps need the usual
android.permission.INTERNET permission.
Start the SDK once at app launch. It retries daemon connections in the background without passing connection errors to the app.
import dev.weiqi.waffle.core.Waffle
class App : Application() {
override fun onCreate() {
super.onCreate()
Waffle.start(appId = packageName)
}
}The default Waffle.start(appId) works everywhere except Wi-Fi:
| App runs on | Link | Setup |
|---|---|---|
| Android device / emulator |
adb reverse to localhost:9091
|
none (adb on PATH) |
| iOS simulator |
localhost:9091 (shares the Mac's loopback) |
none |
| iPhone over USB | daemon dials the app through usbmuxd | none |
| Any device over Wi-Fi | app to your Mac's LAN IP |
WAFFLE_BIND=0.0.0.0 + host
|
iPhone over USB. The SDK listens on the device's 127.0.0.1:9092 and the daemon
connects in through usbmuxd (built into macOS). The phone must be paired with this Mac
and the app in the foreground; it shows up within about 5 s. Set WAFFLE_USB_PORT on
both sides if 9092 is taken. Only Waffle traffic uses the USB link, so localhost in
the app's own requests still means the phone.
Over Wi-Fi, pass your Mac's LAN address:
Waffle.start(appId = "com.example.app", host = "192.168.1.20")Or override at runtime without rebuilding:
adb shell setprop debug.waffle.port 9092
adb shell setprop debug.waffle.host 192.168.1.20OkHttp:
import dev.weiqi.waffle.okhttp.WaffleOkHttp
val okHttp = OkHttpClient.Builder()
.addInterceptor(WaffleOkHttp.interceptor())
.build()Ktor client:
import dev.weiqi.waffle.ktor.WaffleKtor
val ktor = HttpClient(CIO) {
install(Auth) { /* ... */ }
install(WaffleKtor) // install last, see below
}Install
WaffleKtorafter every plugin that reacts to responses (Auth, retry). A matched mock short-circuits the send chain, so plugins installed after Waffle never see it. Installed last, a mocked 401 still triggersAuth's token refresh.
Socket.IO:
import dev.weiqi.waffle.socketio.WaffleSocketIO
val raw = IO.socket("https://api.example.com")
val socket = WaffleSocketIO.wrap(raw, "https://api.example.com")
socket.connect()
socket.emit("cart:update", mapOf("sku" to "pro"))If your app multiplexes everything over one event, pass a label to on. It returns a
short tag shown as event(tag) in the UI; the real event name is still used for
listeners, the wire and mock matching. Return null for no tag:
socket.on("message", label = { args ->
args.optJSONObject(0)?.optString("type")?.takeIf { it.isNotEmpty() }
}) { args ->
// normal listener
}
// server sends: message {"type":"chat",...} → listed as message(chat)Ktor WebSocket: install the plugin once and plain webSocket calls are monitored:
import dev.weiqi.waffle.ktorws.WaffleKtorWs
val ktor = HttpClient(CIO) {
install(WaffleKtorWs)
install(WebSockets)
}
val session = ktor.webSocketSession("wss://api.example.com/realtime")
session.send("ping")| Artifact | Use it for |
|---|---|
io.github.dev-weiqi.waffle:core |
SDK connection, device identity, mock rule sync |
io.github.dev-weiqi.waffle:okhttp |
OkHttp inspection and HTTP mocks |
io.github.dev-weiqi.waffle:ktor |
Ktor client inspection for Android, iOS and JVM |
io.github.dev-weiqi.waffle:socketio |
Socket.IO inspection, ack mocks, push events |
io.github.dev-weiqi.waffle:ktor-ws |
Ktor WebSocket inspection and reply mocks |
Each artifact has a -noop twin with the same API.
Both sample apps use the Control deck layout: four-column action groups, a fixed Activity dock, and system light/dark colors. Android exposes OkHttp and Ktor; CMP exposes Ktor with the same controls.
npm run setup
npm start
cd client
./gradlew :sample:installDebug
./gradlew :sample-cmp:installDebugRun client and server unit tests from the repository root:
npm testBuild checks from the repository root:
npm --prefix server/daemon run typecheck
npm --prefix server/ui run build
(cd client && ./gradlew :sample:compileDebugKotlin :sample-cmp:compileDebugKotlinAndroid)See the user guide for daily use and the protocol for message formats.
For data masking, its limitations, and daemon access precautions, see Security in the MCP guide.
English | 繁體中文
Waffle captures HTTP and Socket traffic from your debug app and lets you mock responses from a local UI or MCP client. The Kotlin Multiplatform SDK supports OkHttp, Ktor Client, Socket.IO, and Ktor WebSocket.
We built Waffle after Flipper was archived and our setup needed to support Android 16 KB memory pages.
With the daemon running and the SDK installed, open http://localhost:9091, launch your debug app, and select its device.
Rules run inside the SDK on the selected device. HTTP mocks answer before the network;
socket ack rules answer locally. Mock bodies support ${randomId}, ${now} and
${randomString(min~max)}.
Use /users/{id} in an HTTP mock to match a single path segment. Under Request conditions, combine Request headers, Query parameters, and JSON Body conditions. Select headers from the latest matching request or add them manually. Every specified
condition must match; other object fields are ignored. Mock this path defaults to
Path only. Choose the captured query, complete JSON object body, or both from the menu, then press the main button to create the rule.
Mock this ack defaults to Event only; its menu can include JSON object fields from
the first outgoing argument. Response data stays separate from these conditions. The device
SDK must support the selected conditions.
HTTP and Socket editors keep Request conditions collapsed by default. Creating a mock with captured conditions expands them automatically and selects the matching tab (Body when both query and body are included). Each device's rules remember their expanded state and the selected condition tab in this browser, including after closing the panel or reloading. Delay settings remain beside the response. Break on this path matches the HTTP method and path only, ignoring query and body conditions. Choose Remove breakpoint to remove that breakpoint.
Use MCP copy_mock_with_fields to replace specified JSON fields in a disabled, device-local copy. The original rule stays unchanged; no SDK update is needed. In the UI, use Copy and edit the response body. See field-copy details.
waffle mcp lets an AI client inspect HTTP and Socket traffic, edit mocks, inject events, and control response breakpoints. It connects to a running daemon. MCP itself requires no additional app SDK integration.
See example prompts and setup for client configuration, tools, and data masking.
The daemon runs on your dev machine. It serves the browser UI, stores mock rules and
keeps adb reverse alive for Android devices.
Requires Node.js 20+, plus adb on your PATH for Android.
npm install -g @dev-weiqi/waffle
waffle startThe UI opens at http://localhost:9091. Without installing:
npx @dev-weiqi/waffle startIf port 9091 is taken, Waffle offers to free it, or pick another port:
PORT=9092 waffle startThe daemon binds to 127.0.0.1 by default. Android (adb reverse), the iOS simulator
and a USB-connected iPhone reach it over localhost. Only a device on Wi-Fi needs it
opened up, together with host in the app (see Start Waffle):
WAFFLE_BIND=0.0.0.0 waffle startUpdate, or pin a version:
npm install -g @dev-weiqi/waffle@latest
npm install -g @dev-weiqi/waffle@1.0.0The macOS app bundles the daemon and UI in one window. Install Node.js
20+ before using it. Download the
.dmg from Releases
(Waffle-server-mac-aarch64.dmg for Apple Silicon, Waffle-server-mac-x64.dmg for
Intel) and drag Waffle.app into /Applications. The port is set in the app's settings.
The dmg is not notarized yet. If macOS says "Waffle is damaged", clear the quarantine flag once:
xattr -d com.apple.quarantine /Applications/Waffle.appAdd core plus the modules for the clients you use. Use the -noop twins in release
builds: same API, empty implementation.
| Client | Waffle artifact |
|---|---|
| OkHttp | io.github.dev-weiqi.waffle:okhttp |
| Ktor Client | io.github.dev-weiqi.waffle:ktor |
| Socket.IO | io.github.dev-weiqi.waffle:socketio |
| Ktor WebSocket | io.github.dev-weiqi.waffle:ktor-ws |
val waffleVersion = "1.0.0"
dependencies {
debugImplementation("io.github.dev-weiqi.waffle:core:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:core-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:okhttp:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:okhttp-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:ktor:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:ktor-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:socketio:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:socketio-noop:$waffleVersion")
debugImplementation("io.github.dev-weiqi.waffle:ktor-ws:$waffleVersion")
releaseImplementation("io.github.dev-weiqi.waffle:ktor-ws-noop:$waffleVersion")
}For KMP shared code, add the modules to commonMain:
commonMain.dependencies {
implementation("io.github.dev-weiqi.waffle:core:$waffleVersion")
implementation("io.github.dev-weiqi.waffle:ktor:$waffleVersion")
implementation("io.github.dev-weiqi.waffle:ktor-ws:$waffleVersion")
}The SDK owns its plain WebSocket connection to localhost:9091, using the same
socket and WebSocket primitives as its USB transport. Apps do not need to add a
Ktor client engine for Waffle, and Waffle does not register an engine that could
change the app's own HttpClient() selection. Android apps need the usual
android.permission.INTERNET permission.
Start the SDK once at app launch. It retries daemon connections in the background without passing connection errors to the app.
import dev.weiqi.waffle.core.Waffle
class App : Application() {
override fun onCreate() {
super.onCreate()
Waffle.start(appId = packageName)
}
}The default Waffle.start(appId) works everywhere except Wi-Fi:
| App runs on | Link | Setup |
|---|---|---|
| Android device / emulator |
adb reverse to localhost:9091
|
none (adb on PATH) |
| iOS simulator |
localhost:9091 (shares the Mac's loopback) |
none |
| iPhone over USB | daemon dials the app through usbmuxd | none |
| Any device over Wi-Fi | app to your Mac's LAN IP |
WAFFLE_BIND=0.0.0.0 + host
|
iPhone over USB. The SDK listens on the device's 127.0.0.1:9092 and the daemon
connects in through usbmuxd (built into macOS). The phone must be paired with this Mac
and the app in the foreground; it shows up within about 5 s. Set WAFFLE_USB_PORT on
both sides if 9092 is taken. Only Waffle traffic uses the USB link, so localhost in
the app's own requests still means the phone.
Over Wi-Fi, pass your Mac's LAN address:
Waffle.start(appId = "com.example.app", host = "192.168.1.20")Or override at runtime without rebuilding:
adb shell setprop debug.waffle.port 9092
adb shell setprop debug.waffle.host 192.168.1.20OkHttp:
import dev.weiqi.waffle.okhttp.WaffleOkHttp
val okHttp = OkHttpClient.Builder()
.addInterceptor(WaffleOkHttp.interceptor())
.build()Ktor client:
import dev.weiqi.waffle.ktor.WaffleKtor
val ktor = HttpClient(CIO) {
install(Auth) { /* ... */ }
install(WaffleKtor) // install last, see below
}Install
WaffleKtorafter every plugin that reacts to responses (Auth, retry). A matched mock short-circuits the send chain, so plugins installed after Waffle never see it. Installed last, a mocked 401 still triggersAuth's token refresh.
Socket.IO:
import dev.weiqi.waffle.socketio.WaffleSocketIO
val raw = IO.socket("https://api.example.com")
val socket = WaffleSocketIO.wrap(raw, "https://api.example.com")
socket.connect()
socket.emit("cart:update", mapOf("sku" to "pro"))If your app multiplexes everything over one event, pass a label to on. It returns a
short tag shown as event(tag) in the UI; the real event name is still used for
listeners, the wire and mock matching. Return null for no tag:
socket.on("message", label = { args ->
args.optJSONObject(0)?.optString("type")?.takeIf { it.isNotEmpty() }
}) { args ->
// normal listener
}
// server sends: message {"type":"chat",...} → listed as message(chat)Ktor WebSocket: install the plugin once and plain webSocket calls are monitored:
import dev.weiqi.waffle.ktorws.WaffleKtorWs
val ktor = HttpClient(CIO) {
install(WaffleKtorWs)
install(WebSockets)
}
val session = ktor.webSocketSession("wss://api.example.com/realtime")
session.send("ping")| Artifact | Use it for |
|---|---|
io.github.dev-weiqi.waffle:core |
SDK connection, device identity, mock rule sync |
io.github.dev-weiqi.waffle:okhttp |
OkHttp inspection and HTTP mocks |
io.github.dev-weiqi.waffle:ktor |
Ktor client inspection for Android, iOS and JVM |
io.github.dev-weiqi.waffle:socketio |
Socket.IO inspection, ack mocks, push events |
io.github.dev-weiqi.waffle:ktor-ws |
Ktor WebSocket inspection and reply mocks |
Each artifact has a -noop twin with the same API.
Both sample apps use the Control deck layout: four-column action groups, a fixed Activity dock, and system light/dark colors. Android exposes OkHttp and Ktor; CMP exposes Ktor with the same controls.
npm run setup
npm start
cd client
./gradlew :sample:installDebug
./gradlew :sample-cmp:installDebugRun client and server unit tests from the repository root:
npm testBuild checks from the repository root:
npm --prefix server/daemon run typecheck
npm --prefix server/ui run build
(cd client && ./gradlew :sample:compileDebugKotlin :sample-cmp:compileDebugKotlinAndroid)See the user guide for daily use and the protocol for message formats.
For data masking, its limitations, and daemon access precautions, see Security in the MCP guide.