Skip to main content
kavachFastify(kavach, options?) returns an async Fastify plugin. Register it with fastify.register and use Fastify’s built-in prefix option to control the mount path.

Install

Setup

1

Create the kavach instance

2

Register the plugin

The prefix is controlled by Fastify’s register options, not by a basePath option on the adapter. This is consistent with how Fastify plugins work.

MCP endpoints

When mcp is passed, the MCP OAuth 2.1 endpoints are registered on the same plugin. Because Fastify’s prefix scopes routes, the well-known paths are served relative to the plugin root:
All MCP routes include CORS headers and respond to OPTIONS preflight requests.

Endpoint reference

Full example

Last modified on April 29, 2026