KavachModule.forRoot(options) is a NestJS dynamic module that mounts all KavachOS routes as Express middleware. Import it once in your root AppModule.
Install
Setup
1
Create the kavach instance
2
Import KavachModule
3
Bootstrap
NestJS uses Express under the hood by default. The adapter mounts an Express Router directly, so no extra configuration is needed.
Route prefix
The default mount path is/api/kavach. Change it with the basePath option:
/auth/*.
Without a module
If you prefer to mount routes imperatively inmain.ts rather than importing a module, use kavachMiddleware directly:
MCP endpoints
Passmcp to enable the MCP OAuth 2.1 authorization server: