KontextManagementClient is the typed management layer for the Kontext identity control plane. Use it to automate applications, integrations, service accounts, sessions, and traces in CI/CD pipelines, admin tooling, or internal automation.
Install
Initialize
Constructor config
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | — | API base URL. Use "https://api.kontext.dev" for production. |
credentials | { clientId, clientSecret } | — | Service account credentials from the dashboard. |
apiVersion | string | "v1" | API version prefix. |
tokenUrl | string | ${baseUrl}/oauth2/token | OAuth token endpoint. Override for custom auth servers. |
scopes | string[] | ["management:all"] | OAuth scopes to request. |
audience | string | ${baseUrl}/api/${apiVersion} | Token audience claim. |
client.serviceAccounts.create().
Resource IDs used by the Management API are UUIDs. OAuth client IDs are separate (app_<uuid> for applications and sa_<uuid> for service accounts).
Applications
Manage applications registered with your organization.List applications
Get an application
Create an application
Update an application
Archive an application
Rotate client secret
OAuth configuration
Manage integrations
Attach or detach integrations from an application. An application can only use tools from its attached integrations.Method reference
| Method | Parameters | Returns |
|---|---|---|
list(params?) | { limit?, cursor? } | { items: Application[], nextCursor? } |
get(id) | string | { application: Application } |
create(data) | CreateApplicationInput | { application: Application, oauth: ApplicationOAuth } |
update(id, data) | string, UpdateApplicationInput | { application: Application } |
archive(id) | string | void |
rotateSecret(id) | string | { oauth: ApplicationOAuth } |
getOAuth(id) | string | { oauth: ApplicationOAuth } |
updateOAuth(id, data) | string, UpdateApplicationOAuthInput | { oauth: ApplicationOAuth } |
listIntegrations(id) | string | { integrationIds: string[] } |
setIntegrations(id, data) | string, { integrationIds: string[] } | { integrationIds: string[] } |
attachIntegration(appId, integrationId) | string, string | void |
detachIntegration(appId, integrationId) | string, string | void |
revokeAllAgentSessions(id) | string | { success: boolean, disconnectedCount: number } |
Integrations
Manage integrations — the external services your applications connect to.List integrations
Create an integration
Validate an integration
status is one of "pending", "valid", or "invalid".
Method reference
| Method | Parameters | Returns |
|---|---|---|
list(params?) | { limit?, cursor? } | { items: Integration[], nextCursor? } |
get(id) | string | { integration: Integration } |
create(data) | CreateIntegrationInput | { integration: Integration } |
update(id, data) | string, UpdateIntegrationInput | { integration: Integration } |
archive(id) | string | void |
validate(id) | string | { status: "pending" | "valid" | "invalid", message? } |
Service accounts
Service accounts provide machine-to-machine credentials for the Management API. Each service account gets aclientId and clientSecret pair.
Create a service account
Rotate credentials
Revoke a service account
Method reference
| Method | Parameters | Returns |
|---|---|---|
list(params?) | { limit?, cursor? } | { items: ServiceAccount[], nextCursor: string | null } |
get(id) | string | { serviceAccount: ServiceAccount } |
create(data) | { name, description? } | { serviceAccount, credentials: { clientId, clientSecret } } |
revoke(id) | string | void |
rotateSecret(id) | string | { credentials: { clientId, clientSecret } } |
Sessions
View and manage active MCP sessions for your applications.List sessions
Get a session
Revoke all sessions
Method reference
| Method | Parameters | Returns |
|---|---|---|
list(applicationId, params?) | string, { limit?, status?, includeInactive? } | { items: AgentSession[] } |
get(applicationId, sessionId) | string, string | { session: AgentSession } |
revokeAll(applicationId) | string | { success: boolean, disconnectedCount: number } |
Traces
Query tool execution traces for observability and debugging.List traces
userId, sessionId, or agentId to narrow results.
Get a trace with events
Trace statistics
Method reference
| Method | Parameters | Returns |
|---|---|---|
list(params?) | { limit?, cursor?, offset?, userId?, sessionId?, agentId?, applicationId? } | { items: Trace[], nextCursor? } |
get(traceId, params?) | string, { userId? }? | { trace: Trace, events: TraceEvent[] } |
stats(params?) | { period?, userId? } | { stats: TraceStats } |
Events
Query trace events directly, without going through a specific trace.Method reference
| Method | Parameters | Returns |
|---|---|---|
list(params?) | { limit? } | { items: McpEvent[] } |
Token management
The client handles token lifecycle automatically. Two methods are available for manual control.clearToken() when rotating service account credentials — the client picks up the new secret on the next request.
Complete example
Create an application, set up an integration, and attach them together:Error handling
The management client throws the same error types as the rest of the SDK. See Errors for the full reference.- 401 — Invalid or expired service account credentials. Check your
clientIdandclientSecret. - 403 — Insufficient permissions. The service account may need additional scopes.
- 404 — Resource not found. Verify the ID.
- 429 — Rate limit exceeded. The error includes a
retryAftervalue in seconds.
Next steps
- TypeScript SDK — Overview of all SDK entry points and subpath exports.
- Errors — Full error hierarchy, error codes, and handling patterns.