# Keycloak Admin API

> Keycloak Admin API is a free MCP server for security. Read-only-by-default tools for each Keycloak admin operation on a single realm. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Free
- **Platforms:** CLI, API
- **Website:** https://openapi.sferadev.com/keycloak-api
- **Repository:** https://github.com/sferarc/openapi/tree/HEAD/packages/keycloak-api
- **MCP Registry name:** io.github.sferarc/keycloak-api-mcp
- **Categories:** security, developer tools
- **Listing updated:** 2026-11-14

## About

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.

## Features

- **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

## Install

### Claude Code (Terminal)

```sh
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
```

### Claude Desktop (claude_desktop_config.json)

```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>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```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>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```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>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```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>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```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>"
      }
    }
  }
}
```

## 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

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [Ouroboros](https://ai-powered.com/mcp/ouroboros): Ouroboros is an open-source MCP server for developer tools.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [Concord MCP](https://ai-powered.com/mcp/concord-mcp): Concord MCP is a freemium MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/keycloak-admin-api
