Skip to content
dev-weiqiPublic

About

Self-hosted Flipper alternative: monitor and mock your app's HTTP & Socket traffic. KMP SDK + local daemon/UI.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

English | 繁體中文

Waffle 🧇

Latest version npm Maven Central License

Waffle captures HTTP and Socket traffic from your app and lets you mock responses from a local UI or MCP client.

Waffle API traffic panel

We built Waffle after Flipper was archived and our setup needed to support Android 16 KB memory pages.

Use the UI

Start the daemon and your SDK-enabled debug app, then select the device at http://localhost:9091.

  • API shows live requests and responses, headers, JSON, images, and animated WebP. Look for the mock badge or copy a request as cURL.
  • Socket shows Socket.IO and WebSocket connections, events, payloads, acknowledgments, and server pushes.
  • Mocks lets you configure HTTP responses, delay-only rules, Socket.IO acknowledgments, WebSocket replies, and push events for the selected device.

Select Mock this path on an HTTP request or Mock this ack on an outgoing Socket event. The device SDK applies the rule locally. See the mock editor guide to match specific requests or customize replies.

AI tools through MCP

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.

Install the monitor

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 start

The UI opens at http://localhost:9091. Without installing:

npx @dev-weiqi/waffle start

If port 9091 is taken, Waffle offers to free it, or pick another port:

PORT=9092 waffle start

The 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 start

Update, or pin a version:

npm install -g @dev-weiqi/waffle@latest
npm install -g @dev-weiqi/waffle@1.0.0

Desktop app

The 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.app

Add the SDK

The Kotlin Multiplatform SDK supports OkHttp, Ktor Client, Socket.IO, and Ktor WebSocket.

Add 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")
}

Connection to the daemon

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 Waffle

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.20

Attach your clients

OkHttp:

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 WaffleKtor after 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 triggers Auth'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")

Modules

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.

Local development

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:installDebug

Run client and server unit tests from the repository root:

npm test

Build 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.

Security

For data masking, its limitations, and daemon access precautions, see Security in the MCP guide.

About

Self-hosted Flipper alternative: monitor and mock your app's HTTP & Socket traffic. KMP SDK + local daemon/UI.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages