Skip to main content
The @kontext-dev/js-sdk package is the developer entry point to the Kontext identity control plane. Use it to build agents with runtime identity, connect to external systems with short-lived scoped credentials, and keep policy and audit control centralized in Kontext.
@kontext-dev/[email protected] includes hard-cutover runtime integration semantics, including connectType: "user_token" for per-user API key flows and kontext.require(..., { userId }) for confidential server-side exchanges keyed by an external end-user ID.

Choose a path

Server SDK

Build MCP servers with middleware, scoped credentials, and production controls.

Client SDK

Build app-facing clients with auth, tool execution, and token storage.

Frameworks

Integrate with Vercel AI SDK, Cloudflare Agents, and React.

Management SDK

Automate applications, integrations, service accounts, sessions, and traces.
Type signatures and interfaces are in the API Reference.

Install

npm install @kontext-dev/js-sdk

Subpath exports

The package supports both root exports and subpath exports. Subpath imports are recommended when you want the narrowest surface area.
Import PathExportPurpose
@kontext-dev/js-sdkcreateKontextClient, createKontextOrchestrator, Kontext (+ shared types/errors)Root convenience entry point
@kontext-dev/js-sdk/clientcreateKontextClientClient SDK factory
@kontext-dev/js-sdk/serverKontextServer SDK class
@kontext-dev/js-sdk/aitoKontextToolsVercel AI SDK adapter
@kontext-dev/js-sdk/reactuseKontext, KontextProvider, useKontextContextReact hooks and provider
@kontext-dev/js-sdk/react/cloudflareuseKontextAgent, useKontextContextReact hooks for Cloudflare Agents
@kontext-dev/js-sdk/cloudflarewithKontext, KontextCloudflareOAuthProvider, DurableObjectKontextStorageCloudflare Agents adapter
@kontext-dev/js-sdk/managementKontextManagementClientManagement API client
@kontext-dev/js-sdk/mcpKontextMcpLow-level MCP client
@kontext-dev/js-sdk/errorsKontextError, translateError, isKontextError, isNetworkError, isUnauthorizedErrorError types, translation, and guards
@kontext-dev/js-sdk/verifyKontextTokenVerifierToken verification
@kontext-dev/js-sdk/oauthOAuth utilitiesOAuth helpers

Peer dependencies

Install peer dependencies based on which entry points you use.
PackageVersionRequired For
@modelcontextprotocol/sdk^1.26.0Server SDK (@kontext-dev/js-sdk/server)
express^4.21.0 or ^5.0.0Server SDK (@kontext-dev/js-sdk/server)
ai^4.0.0Vercel AI adapter (@kontext-dev/js-sdk/ai)
react^18.0.0 or ^19.0.0React adapter (@kontext-dev/js-sdk/react)
agents>=0.4.0Cloudflare adapter (@kontext-dev/js-sdk/cloudflare)
Your package manager will warn about missing peer dependencies when you import an entry point that needs them.

Environment variables

VariableUsed ByDescription
KONTEXT_CLIENT_SECRETServer SDKClient secret for token exchange. Set this instead of passing clientSecret in code.
KONTEXT_TOKEN_ISSUERServer SDKCustom token issuer URL(s). Comma-separated for multiple issuers.
KONTEXT_CLIENT_IDCloudflare adapterApplication client ID. Read automatically by the withKontext mixin.
The server SDK reads KONTEXT_CLIENT_SECRET automatically. You do not need to pass it in the constructor if the environment variable is set.