Skip to content
MCP server

Keycloak Admin API

Read-only-by-default tools for each Keycloak admin operation on a single realm

Runs locallyStatus and history
Install
Pricing
Free
Platforms
CLI, API
Runs
Locally
Version
3.8.1
Listing updated
3 days ago

About Keycloak Admin API

Keycloak Admin API is a free MCP server for security. It runs locally on your machine and is started by your AI client.

This is an unofficial server, not made or endorsed by Keycloak. It is generated from the Keycloak Admin REST API's OpenAPI spec and exposes one tool per admin operation for one realm. By default it lists only read tools; setting KEYCLOAK_MCP_ALLOW_WRITES to 1 also lists the ones that change data, and KEYCLOAK_MCP_RESOURCES narrows tools to chosen resources such as users, groups or roles.

You point it at your own self-hosted Keycloak with KEYCLOAK_URL and KEYCLOAK_REALM, and authenticate with either a fixed access token or a confidential client with a service account using the client credentials grant. A separate token realm can be named if the client lives elsewhere, for example master.

It runs locally over stdio from the npm package keycloak-api. The same package is a typed TypeScript client for the Admin and Account APIs, with optional Effect bindings, and its README documents token refresh functions and custom fetch.

Install

Run in a terminal

claude mcp add keycloak-api-mcp --env KEYCLOAK_URL='<KEYCLOAK_URL>' --env KEYCLOAK_REALM='<KEYCLOAK_REALM>' --env KEYCLOAK_TOKEN='<KEYCLOAK_TOKEN>' --env KEYCLOAK_CLIENT_SECRET='<KEYCLOAK_CLIENT_SECRET>' -- npx -y keycloak-api

Add to claude_desktop_config.json

{
  "mcpServers": {
    "keycloak-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-api"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_REALM": "<KEYCLOAK_REALM>",
        "KEYCLOAK_TOKEN": "<KEYCLOAK_TOKEN>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>"
      }
    }
  }
}

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "keycloak-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-api"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_REALM": "<KEYCLOAK_REALM>",
        "KEYCLOAK_TOKEN": "<KEYCLOAK_TOKEN>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>"
      }
    }
  }
}

Add to .vscode/mcp.json

{
  "servers": {
    "keycloak-api-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "keycloak-api"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_REALM": "<KEYCLOAK_REALM>",
        "KEYCLOAK_TOKEN": "<KEYCLOAK_TOKEN>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>"
      }
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "keycloak-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-api"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_REALM": "<KEYCLOAK_REALM>",
        "KEYCLOAK_TOKEN": "<KEYCLOAK_TOKEN>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>"
      }
    }
  }
}

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "keycloak-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-api"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_REALM": "<KEYCLOAK_REALM>",
        "KEYCLOAK_TOKEN": "<KEYCLOAK_TOKEN>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>"
      }
    }
  }
}

Configuration

  • KEYCLOAK_URLBase URL of the server, such as https://keycloak.example.comRequired
  • KEYCLOAK_REALMRealm the tools act onRequired
  • KEYCLOAK_TOKENA fixed access token; otherwise set KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET
  • KEYCLOAK_CLIENT_IDA confidential client with a service account, for the client credentials grant
  • KEYCLOAK_CLIENT_SECRETSecret of that client
  • KEYCLOAK_TOKEN_REALMRealm of that client, if not KEYCLOAK_REALM (for example master)
  • KEYCLOAK_MCP_ALLOW_WRITES1 to list the tools that change data
  • KEYCLOAK_MCP_RESOURCESComma separated resources to list tools for, such as users,groups,roles

What it does

One tool per operation
Each Keycloak admin operation becomes its own tool.
Read-only default
Write tools appear only when explicitly enabled.
Resource filter
Limit tools to resources like users, groups or roles.
Flexible auth
Fixed token or client credentials with a service account.
Typed client
Same package ships a TypeScript client for Admin and Account APIs.

Good for

  • Ask an assistant to list users or groups in a realm
  • Audit roles and client settings without clicking through the console
  • Create a user from a chat once writes are enabled
  • Script Keycloak administration with a typed client

Pricing

Free

Free npm package

Prices change. Check openapi.sferadev.com before you buy.

Keycloak Admin API FAQ

Is this made by Keycloak?

No. It is unofficial and not affiliated with or endorsed by Keycloak.

Can it change data by default?

No. Write tools are listed only when KEYCLOAK_MCP_ALLOW_WRITES is set to 1.

What do I need to run it?

KEYCLOAK_URL, KEYCLOAK_REALM and a token or client ID and secret.

How does it run?

Locally over stdio from the npm package keycloak-api.

Is Keycloak Admin API free?

Yes. Keycloak Admin API is free to use.

How do I add Keycloak Admin API to Claude Code?

Run this command in your terminal: claude mcp add keycloak-api-mcp --env KEYCLOAK_URL='<KEYCLOAK_URL>' --env KEYCLOAK_REALM='<KEYCLOAK_REALM>' --env KEYCLOAK_TOKEN='<KEYCLOAK_TOKEN>' --env KEYCLOAK_CLIENT_SECRET='<KEYCLOAK_CLIENT_SECRET>' -- npx -y keycloak-api

What are the best alternatives to Keycloak Admin API?

The closest alternatives to Keycloak Admin API are REA, Codebase Memory, GitHub, Serena MCP: the IDE for your agent and XERJ.

Alternatives to Keycloak Admin API

  1. REA

    MCP server

    CLI and MCP server that lets coding agents reverse engineer apps and binaries

    Runs locally
    • Open source
    • 464K GitHub stars
    • Developer tools
  2. Codebase Memory

    MCP server

    Local MCP server that builds a code knowledge graph for AI coding agents

    Runs locally
    • Open source
    • 48.7K GitHub stars
    • Knowledge and memory
  3. GitHub

    MCP server

    Official MCP server connecting AI assistants to GitHub repos, issues and workflows

    Not checked yet
    • Remote
    • Open source
    • 34.5K GitHub stars
    • Developer tools
  4. MCP toolkit giving coding agents symbol-level code retrieval and editing

    Runs locally
    • Open source
    • 31.5K GitHub stars
    • Developer tools
  5. XERJ

    MCP server

    Local search engine for AI agents with cited answers over your code and docs

    Runs locally
    • Open source
    • 19.2K GitHub stars
    • Knowledge and memory
  6. Ouroboros

    MCP server

    Spec-first layer that pins requirements and verifies results of AI coding agent work

    Runs locally
    • Open source
    • 6.4K GitHub stars
    • Developer tools