--- name: waniwani-sdk description: "MCP distribution SDK: build sales funnels, lead generation, booking flows, insurance quote flows, pricing quote flows, and any multi-step conversational MCP app with @waniwani/sdk. Open source createFlow engine (no API key required) with pluggable state backends (in-memory, Redis, Upstash, Cloudflare KV, DynamoDB, or hosted). Optional free tier adds a revenue-first event taxonomy (track leads, prices shown/compared, options selected, and conversions — including off-platform purchases), funnel analytics, knowledge base, and a chat widget. Trigger when the user wants to add an MCP funnel, sales funnel, lead gen flow, booking flow, quote flow, knowledge base / FAQ tool, or embedded chat to an MCP server — or to instrument tracking on a @waniwani/sdk app: emit or track events, record a conversion or revenue, attribute an off-platform purchase back to a lead, or measure where users drop off in a funnel." license: MIT metadata: author: Waniwani --- # Waniwani SDK (`@waniwani/sdk`) The MCP distribution SDK. Build sales funnels, lead generation, booking, insurance quote, and pricing quote apps on top of your MCP server. Open-source flow engine, with an optional free tier for hosted state, event tracking, funnel analytics, knowledge base, and a playground. The split: - **Open source** — `createFlow`, `StateGraph`, the `KvStore` interface, `MemoryKvStore`. Runs with no API key against any state backend you implement. - **Free tier** — set `WANIWANI_API_KEY` to unlock hosted flow state, event tracking, funnel analytics, knowledge base, and the dashboard playground. Docs: [docs.waniwani.ai](https://docs.waniwani.ai) Dashboard: [app.waniwani.ai](https://app.waniwani.ai) ## Install ```bash bun add @waniwani/sdk ``` Core flow engine has no required runtime dependencies. Peer dependencies (`@modelcontextprotocol/sdk`, `zod`, etc.) vary by entry point — see the export table below. ## Quick start — open source path For developers who want pure OSS with no telemetry: ```typescript import { createFlow, MemoryKvStore, START, END } from "@waniwani/sdk/mcp"; import { z } from "zod"; const onboardingFlow = createFlow({ id: "onboarding", title: "User Onboarding", description: "Use when a new user wants to get started.", state: { email: z.string().describe("Work email"), useCase: z.string().describe("What they want to build"), }, }) .addNode("ask_email", ({ interrupt }) => interrupt({ email: { question: "What's your work email?" } }) ) .addNode("ask_use_case", ({ interrupt }) => interrupt({ useCase: { question: "What do you want to build?" } }) ) .addEdge(START, "ask_email") .addEdge("ask_email", "ask_use_case") .addEdge("ask_use_case", END) .compile({ store: new MemoryKvStore() }); await onboardingFlow.register(server); ``` `MemoryKvStore` is fine for dev/tests. For production self-hosting, see [kv-store.md](references/kv-store.md) for Redis, Upstash, Cloudflare KV, and DynamoDB adapters. ## Quick start — free tier path Same code, hosted features added: ```bash # .env WANIWANI_API_KEY=wwk_... ``` ```typescript // Drop the `store` argument — flow state now lives on app.waniwani.ai const flow = createFlow({ /* …same… */ }).compile(); // Optional: auto-track every tool call import { withWaniwani } from "@waniwani/sdk/mcp"; withWaniwani(server); ``` Get a free key at [app.waniwani.ai](https://app.waniwani.ai). See [setup.md](references/setup.md) for full configuration. ## Export paths | Export | Purpose | Tier | Reference | |---|---|---|---| | `@waniwani/sdk` | `waniwani()` client, `track.*` event helpers, `WaniWaniError` | Free tier | [setup.md](references/setup.md), [events.md](references/events.md) | | `@waniwani/sdk/mcp` | `createFlow`, `KvStore`, `MemoryKvStore`, `withWaniwani`, tracking helpers | OSS + Free tier | [flows.md](references/flows.md), [kv-store.md](references/kv-store.md), [events.md](references/events.md) | | `@waniwani/sdk/mcp/react` | `useWaniwani` standalone tracking hook | OSS + Free tier | (rest of this entry point is legacy) | | `@waniwani/sdk/chat` | `ChatEmbed`, themes | Free tier | [chat-widget.md](references/chat-widget.md) | | `@waniwani/sdk/chat/embed.js` | Self-contained `