Skip to main content
A Waniwani deployment has two pieces you can self-host independently:
  1. The MCP app — the server that hosts your createFlow tools and serves MCP clients.
  2. The KV store — where flow state lives between tool calls.
These are orthogonal. The most common setup is “self-host the MCP app, let Waniwani host the KV store” — your infra for the server, the Waniwani Platform for state and dashboards. The next step is self-hosting the KV too, eliminating any outbound call to app.waniwani.ai.

1. Self-host the MCP app

Deploy the server you wrote on infrastructure you control. By itself this gets you self-hosted MCP + hosted state (the Hybrid row above).

Scaffold

Start from the MCP Distribution Template or any MCP server of your own:

Wire up the server

server.ts
When .compile() is called with no store and WANIWANI_API_KEY is set, the SDK uses WaniwaniKvStore automatically. That’s the Hybrid setup.

Deploy

Any platform that can run Node 18.17+ works: Vercel, Render, Railway, Fly.io, Cloudflare Workers, AWS Lambda, Google Cloud Run. See Deployment overview for the choice between this and Managed Hosting.

Register with Waniwani

In the Waniwani dashboard, create a self-hosted project and paste your deployed MCP URL. Waniwani routes chat requests, widget rendering, and analytics ingestion through that URL.

2. Self-host the KV store

Pass your own KvStore to .compile() and the engine never touches app.waniwani.ai for state. Useful when you have data-residency constraints, run in fully open-source mode, or want all state inside your existing infrastructure.

Pick a backend

See KV store adapters for recipes. Quick decision tree:
  • Vercel / Netlify / Cloudflare Workers → Upstash Redis or Cloudflare KV
  • AWS Lambda → DynamoDB
  • Long-running Node → ioredis against a managed Redis (Render, Railway, Fly)
  • Local box → SQLite via better-sqlite3

Implement the interface

kv-store.ts

Pass it to .compile()

flow.ts
State now reads and writes against your backend. Nothing about flow state ever leaves your infrastructure.

Fully open-source mode

Combine the two: self-host the MCP app, pass a custom KvStore, omit WANIWANI_API_KEY. Result: no outbound calls to app.waniwani.ai, no telemetry, no hosted dashboards. The engine is fully usable in this mode.

Verifying it’s truly offline

The only outbound calls the SDK makes are when the waniwani() client is instantiated with an API key, or when WaniwaniKvStore is used. Neither happens in fully open-source mode.

Switching modes later

The same code moves between modes by editing one or two lines:
  • OSS → Hybrid: drop the store argument from .compile(), set WANIWANI_API_KEY.
  • Hybrid → OSS: pass a custom store to .compile().
  • Self-hosted → Managed Hosting: see Deployment overview.
Existing sessions stay where they started; there is no automatic state migration between stores.