Requirements
- Node.js 18.17 or newer (Node 20+ recommended)
- An MCP server runtime. The SDK is tested against:
- A WaniWani account at app.waniwani.ai
@modelcontextprotocol/sdk and zod are peer dependencies. Install them in your project if you do not already have them.
Install
The SDK has zero runtime dependencies and targets a sub-5KB core bundle. It runs in long-lived Node processes, serverless functions, and edge runtimes.
Create a client
WANIWANI_API_KEY from the environment and uses https://app.waniwani.ai as the base URL. This is the recommended setup.
See API keys for how to obtain and configure the key.
Configuration reference
All fields are optional.Your MCP environment API key. Defaults to
process.env.WANIWANI_API_KEY. If both are missing, track() / flush() / shutdown() throw at runtime.Base URL of the WaniWani API. Override for self-hosted deployments or staging backends.
Fine-tune the event tracking transport.
Fully configured client
Graceful shutdown
In Node environments, the SDK attaches handlers forbeforeExit, SIGINT, and SIGTERM that flush buffered events automatically. For serverless, edge runtimes, tests, or short-lived scripts, call shutdown() explicitly:
Also supported
- Project config file. Create a
waniwani.config.tswithdefineConfig({ ... })from@waniwani/sdk, then import it once at startup. Subsequent calls towaniwani()pick up the registered config. - Framework adapters. Pass the client to
toNextJsHandler(wani, { ... })from@waniwani/sdk/next-jsfor Next.js route handlers.