@kavachos/sveltekit
v2.0.0
Published
SvelteKit adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Readme
@kavachos/sveltekit
SvelteKit adapter for KavachOS.
Install
pnpm add kavachos @kavachos/sveltekitUsage
Create src/routes/api/kavach/[...path]/+server.ts:
import { createKavach } from 'kavachos';
import { kavachSvelteKit } from '@kavachos/sveltekit';
const kavach = createKavach({
database: { provider: 'sqlite', url: 'kavach.db' },
});
const handlers = kavachSvelteKit(kavach);
export const GET = handlers.GET;
export const POST = handlers.POST;
export const PATCH = handlers.PATCH;
export const DELETE = handlers.DELETE;
export const OPTIONS = handlers.OPTIONS;This handles the full KavachOS REST API under /api/kavach: agent CRUD, authorization, delegations, audit logs, and dashboard stats.
With MCP OAuth 2.1
import { createMcpModule } from 'kavachos/mcp';
import { kavachSvelteKit } from '@kavachos/sveltekit';
const mcp = createMcpModule({
issuer: 'https://your-app.com',
// ...
});
const handlers = kavachSvelteKit(kavach, { mcp });When mcp is provided, the OAuth 2.1 endpoints are enabled:
GET /.well-known/oauth-authorization-serverGET /.well-known/oauth-protected-resourcePOST /mcp/registerGET /mcp/authorizePOST /mcp/token
API surface
kavachSvelteKit(kavach, options?) returns an object with GET, POST, PATCH, DELETE, and OPTIONS handlers for SvelteKit's +server.ts files.
| Option | Type | Description |
|--------|------|-------------|
| mcp | McpAuthModule | Enables MCP OAuth 2.1 endpoints |
| basePath | string | URL prefix before the catch-all segment. Defaults to /api/kavach |
For full docs on agent identity, permissions, delegation, and audit, see the main kavachos package.
Links
License
MIT
