createKontextClient
KontextClient instance. See Client SDK for the full usage guide.
KontextClientConfig
Configuration passed tocreateKontextClient.
| Option | Type | Description |
|---|---|---|
clientId | string | Your application’s OAuth client ID. |
redirectUri | string | Where to redirect after OAuth. Must match your application’s registered URI. |
url | string? | MCP server endpoint for single-endpoint mode. Omit for hybrid/orchestrated mode. |
serverUrl | string? | Kontext API base URL. Defaults to https://api.kontext.dev. |
storage | KontextStorage? | Token persistence backend. Defaults to MemoryStorage. |
sessionKey | string? | Namespace prefix for storage keys. Use for multi-user isolation. |
onAuthRequired | (url: URL) => ... | Called when the user needs to authenticate. Open or redirect to the URL. |
onIntegrationRequired | (url, info) => void | Called when an integration needs connecting. Show the connect URL to the user. |
onStateChange | (state) => void | Called on every state transition. |
KontextClient
The client instance returned bycreateKontextClient.
ClientState
| State | Meaning |
|---|---|
idle | Client created, not yet connected. |
connecting | Connection in progress. |
ready | Connected and authenticated. Tools are available. |
needs_auth | User needs to sign in before connecting. |
failed | Connection failed. Check the error event for details. |
KontextTool
A tool discovered through the client SDK.server field is present in hybrid mode, indicating which integration the tool belongs to. In single-endpoint mode, all tools come from one server and this field is omitted.
ToolResult
Result fromclient.tools.execute().
content is the text representation. raw contains the full MCP CallToolResult response.
IntegrationInfo
Integration status fromclient.integrations.list().
connected is false, connectUrl may provide a Kontext manage/connect URL so the user can finish required auth. This can be OAuth or API key (user_token) setup. See Tools for handling disconnected integrations.
KontextStorage
Token persistence interface. Implement this to store tokens outside of memory.MemoryStorage resets on page reload. See Storage for custom implementations.
ConnectSessionResult
Returned byclient.getConnectPageUrl().