mcp-ory-kratos
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-ory-kratoslist all identities"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-ory-kratos
MCP server enabling AI assistants to manage Ory Kratos identities, sessions, and authentication flows. Built for developers integrating identity management into Claude Code, GitHub Copilot, or Gemini CLI workflows.
Table of Contents
Related MCP server: MCP Authentik
Prerequisites
Ory Kratos instance running with Admin API access (developed and tested against v26.2.0; the integration suite pins that version)
Node.js 20+ or Bun 1.x installed
One of the supported MCP clients:
Claude Code 1.0+
VS Code 1.99+ with GitHub Copilot (GA in 1.102+)
Gemini CLI 0.1+
Note: Kratos deployment and configuration is out of scope for this MCP server. See the Ory Kratos documentation for deployment guidance.
Installation
Install via npm or run directly with npx:
# Using npm
npm install -g mcp-ory-kratos
# Using npx (no installation required)
npx mcp-ory-kratos
# Using bun
bun add -g mcp-ory-kratosConfiguration
Environment Variables
Variable | Required | Default | Description |
| Yes | - | Kratos Admin API base URL (e.g., |
| No |
| Authentication type: |
| Conditional | - | Required when |
| Conditional | - | JSON object of headers when |
| No |
| Request timeout in milliseconds |
| No |
| Comma-separated toolsets to expose: |
| No |
|
|
| No |
|
|
| No |
|
|
| No |
| Default page cap (1-1000) for tools that scan many pages (analytics, filtered session listing) |
| No |
| Log level: |
Boolean variables accept 1, true, yes, on (case-insensitive); anything else is false.
Admin URL: The Kratos SDK appends
/admin/...to the base URL itself. Trailing slashes are stripped, and ifKRATOS_ADMIN_URLalready ends in/admin(common behind a reverse proxy, e.g.https://ory.example.com/kratos/admin) that suffix is removed for SDK calls so paths do not become/admin/admin/.... Bothhttp://localhost:4434andhttp://localhost:4434/adminwork.
Note: This MCP server can run alongside other MCP servers in your configuration. Each server operates independently.
Claude Code
Add to ~/.claude.json for global configuration:
{
"mcpServers": {
"kratos": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "http://localhost:4434"
}
}
}
}For project-scoped configuration, create .mcp.json in your project root:
{
"mcpServers": {
"kratos": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "http://localhost:4434"
}
}
}
}GitHub Copilot (VS Code)
Create .vscode/mcp.json in your workspace:
{
"servers": {
"kratos": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "http://localhost:4434"
}
}
}
}For secrets handling with input variables:
{
"inputs": [
{
"type": "promptString",
"id": "kratos-url",
"description": "Kratos Admin API URL",
"password": false
}
],
"servers": {
"kratos": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "${input:kratos-url}"
}
}
}
}Gemini CLI
Add to ~/.gemini/settings.json for global configuration:
{
"mcpServers": {
"kratos": {
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "http://localhost:4434"
}
}
}
}For project-scoped configuration, create .gemini/settings.json in your project:
{
"mcpServers": {
"kratos": {
"command": "npx",
"args": ["-y", "mcp-ory-kratos"],
"env": {
"KRATOS_ADMIN_URL": "http://localhost:4434"
}
}
}
}Quick Start
1. Configure Your MCP Client
Choose your MCP client from the Configuration section above and add the appropriate configuration.
2. Verify Installation
Start your MCP client and verify the tools are available:
Claude Code: Run
/mcpto see available serversVS Code: Click the tools icon in Copilot Chat
Gemini CLI: The server starts automatically when tools are needed
3. Try Your First Command
Ask your AI assistant:
"List all identities in Kratos"
The MCP server will execute kratos_list_identities and return the results.
Tool Reference
27 tools, grouped by toolset (enable/disable groups with KRATOS_TOOLSETS). Kind is the MCP annotation: read-only tools survive KRATOS_READ_ONLY=1; destructive tools change or remove data and trigger a confirmation prompt (see Behaviour).
Identity Tools
Toolset: identities
Tool | Kind | Description |
| read-only | List identities; filter by credential identifier (exact or fuzzy), IDs, organization; optional |
| read-only | Get an identity by ID; |
| read-only | Look up an identity by |
| read-only | List identity JSON schemas (paginated) |
| read-only | Get one identity JSON schema by ID |
| create | Create an identity with schema, traits, metadata, credentials and addresses |
| create | Bulk-create up to 100 identities in one non-atomic request, with per-item results and a summary |
| destructive | Full update of an identity (replaces all fields) |
| destructive | Partial update using JSON Patch operations |
| destructive | Activate or suspend an identity; optionally revoke all its sessions |
| destructive | Permanently delete an identity and all associated data |
| destructive | Delete a credential type; |
Session Tools
Toolset: sessions
Tool | Kind | Description |
| read-only | List sessions ( |
| read-only | Get session details by ID |
| read-only | List sessions for one identity |
| destructive | Revoke/disable a session (log user out) |
| destructive | Extend session expiration time |
| destructive | Delete all sessions for an identity |
Courier Tools
Toolset: courier
Tool | Kind | Description |
| read-only | List emails/SMS sent by Kratos with delivery status |
| read-only | Get courier message details including delivery attempts |
Recovery Tools
Toolset: recovery
Tool | Kind | Description |
| create | Generate an account recovery link ( |
| create | Generate an account recovery code ( |
Recovery links and codes are equivalent to full account takeover. Treat them as secrets.
Analytics Tools
Toolset: analytics
Tool | Kind | Description |
| read-only | Aggregated session statistics (auth methods, assurance levels, devices, browsers) |
| read-only | Credential type distribution, MFA and passwordless (passkey) adoption |
Both scan up to maxPages pages and report pagesScanned / truncated.
Health Tools
Toolset: health
Tool | Kind | Description |
| read-only | Check if Kratos is alive and accepting requests |
| read-only | Check if Kratos is ready (database connectivity, dependencies) |
| read-only | Get the Kratos server version |
Behaviour
Every tool declares an outputSchema and returns its result as structuredContent alongside the JSON text; errors come back as isError results with { code, message, kratosStatus?, suggestion? }.
Pagination
List tools take pageSize (1-100, default 20) and pageToken, and return { items, count, nextPageToken }. nextPageToken is absent on the last page; pass it back as pageToken to continue. Tokens are opaque cursors bound to the Kratos instance.
Tools that walk many pages (analytics, kratos_list_sessions with filter) accept maxPages (default KRATOS_MAX_SCAN_PAGES) and return pagesScanned and truncated. When truncated is true the page cap was hit; raise maxPages or pass the returned nextPageToken back as pageToken to resume from the first unscanned page (both analytics tools accept pageToken; an analytics aggregate then covers only the resumed range).
Credential Redaction
When includeCredential is requested, the config of secret-bearing credential types (password, oidc, saml, totp, lookup_secret, webauthn, passkey) is replaced with "[redacted: set KRATOS_ALLOW_CREDENTIAL_EXPOSURE=1]". Type, identifiers, version and timestamps are kept so an agent can still see what is linked. Set KRATOS_ALLOW_CREDENTIAL_EXPOSURE=1 to return the raw config.
Destructive Tools and Confirmation
Tools annotated destructiveHint (delete, disable, update, patch, set state) ask the client to confirm via MCP elicitation before doing anything. If the user declines, the tool returns { cancelled: true } and nothing is changed. Clients without elicitation support skip the prompt (the annotation still lets them warn on their own). Disable the prompt with KRATOS_CONFIRM_DESTRUCTIVE=0, or hide destructive tools entirely with KRATOS_READ_ONLY=1.
Resources
URI | Description |
| All identity schemas ( |
| One identity JSON schema; listed and completable per schema ID |
| Non-sensitive connection info: base URL (credentials stripped), auth type, timeout, enabled toolsets, read-only flag, reachability and Kratos version |
Usage Examples
List Identities
List all identities in KratosFind User by Email
Find the identity with email user@example.comCheck Kratos Health
Is Kratos healthy and ready?View Active Sessions
Show all active sessions in KratosGet Session Analytics
What authentication methods are users using? Show session analytics.Create Recovery Link
Create a recovery link for user with ID abc-123Breaking changes in 0.3.0
0.3.0 is a minor bump (the package is pre-1.0) that changes several contracts. Update clients and scripts as follows:
Contract | 0.2.0 | 0.3.0 | Migration |
|
|
| Rename |
|
|
| Switch to |
|
|
| Read |
Destructive tools (update, patch, set state, extend/disable session, delete identity/credential/sessions) | always returned their result | may return | Check |
Server version over MCP | hard-coded | equals the | Clients that pinned |
Runtime | Node >= 18 | Node >= 20 | Upgrade Node |
Additive changes (no action needed): every tool now carries a title, MCP annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint: false), an output schema and structuredContent; list tools return { items, count, nextPageToken? }; kratos_delete_identity_sessions returns sessionsExisted, kratos_set_identity_state returns sessionsRevoked; new env vars KRATOS_TOOLSETS, KRATOS_READ_ONLY, KRATOS_CONFIRM_DESTRUCTIVE, KRATOS_ALLOW_CREDENTIAL_EXPOSURE, KRATOS_MAX_SCAN_PAGES are all optional.
Troubleshooting
Connection refused
Symptom: ECONNREFUSED or connection timeout errors
Solutions:
Verify Kratos is running:
curl http://localhost:4434/health/aliveCheck
KRATOS_ADMIN_URLis correct (use Admin API port, typically 4434)Ensure Kratos Admin API is accessible from the MCP server's network
401 Unauthorized
Symptom: Authentication errors when calling Kratos API
Solutions:
If Kratos requires authentication, set
KRATOS_AUTH_TYPE=api-keyProvide
KRATOS_API_KEYwith a valid API keyFor custom auth, use
KRATOS_AUTH_TYPE=custom-headerswithKRATOS_CUSTOM_HEADERS
Tool not found
Symptom: MCP client doesn't show Kratos tools
Solutions:
Restart your MCP client after configuration changes
Verify configuration file syntax (valid JSON)
Check file location matches your client's expected path
Run
npx mcp-ory-kratosmanually to verify the server starts
Timeout errors
Symptom: Requests timeout before completing
Solutions:
Increase
KRATOS_TIMEOUT_MS(default: 30000ms)Check network latency to Kratos instance
Verify Kratos isn't overloaded or unresponsive
Development
Local Setup
# Clone the repository
git clone https://github.com/feedback-loop-ai/mcp-ory-kratos.git
cd mcp-ory-kratos
# Install dependencies
bun install
# Start the MCP server
bun run startBuild Commands
# Lint (Biome)
bun run lint
bun run lint:fix # Auto-fix issues
# Type check (src + tests)
bun run typecheck
# Unit tests (hermetic, with coverage) - this is what CI runs
bun run test:unit
# Dependency audit (high severity and above)
bun run audit
# Build the distributable
bun run buildIntegration Tests
The integration suite in tests/api/ runs against a real Kratos (pinned to v26.2.0, configured from tests/kratos/). Start one with Docker and run the suite:
docker compose up -d --wait
bun run test:api
docker compose downTo target another instance, copy .env.test.local.example to .env.test.local and set KRATOS_ADMIN_URL / KRATOS_EXPECTED_VERSION (the suite fails fast on a version mismatch). Override the container version with KRATOS_VERSION=v26.x.y docker compose up -d.
CI runs lint, type check, audit and unit tests on every push and PR, plus the integration job against the docker-compose Kratos.
Contributing
Contributions are welcome! Please follow these steps:
Fork the repository
Create a feature branch (
git checkout -b feature/my-feature)Make your changes
Run lint, type check and tests (
bun run lint && bun run typecheck && bun run test:unit)Commit your changes (
git commit -m 'Add my feature')Push to your branch (
git push origin feature/my-feature)Open a Pull Request
Support
If you find this project useful, consider sponsoring its development:
Your support helps maintain and improve the MCP Ory Kratos server.
License
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
Hosted MCP server for AI agent identity, permissions, verification, and reusable proof.
MCP server that lets AI assistants use all OneSchema features exposed via the public API.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP Server for AI agent identity and authorization. Create, verify, and manage agent identities with trust scores and scoped authorization tokens.MIT
- AlicenseNot gradedqualityAmaintenanceMCP server for Authentik identity management, enabling natural language management of users, groups, applications, flows, policies, providers, and more.109 npm10MIT
- FlicenseNot gradedqualityDmaintenanceFast, low-latency MCP server for authentication services, enabling AI agents like LM Studio and Claude Desktop to perform user authentication operations such as sign-in, sign-up, OTP verification, and token management.-
- AlicenseAqualityAmaintenanceMCP server for Authentik identity provider enabling management of users, groups, apps, tokens, flows, and policy bindings through natural language.7MIT