keycloak-mcp: Instructions file for Claude Code

CLAUDE.md

keycloak-mcp CLAUDE.md is an instructions file for Claude Code from shigechika/keycloak-mcp. It costs 1,368 tokens per session, scanned A, original, MIT.

A set of Claude Code instructions for developing a Keycloak administration server. It documents the project structure, commands, authentication, tests, and coding conventions.

In plain words
What is it for?
Guiding development and review of Keycloak API access, authentication, retries, pagination, user and group tools, security checks, events, sessions, and the daily report.
Why use it?
It gives an assistant the repository's expected workflow and security boundaries before it changes code. The documented connection uses service-account authentication rather than a human password or one-time code.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md.

This is shigechika/keycloak-mcp's own configuration. It tells Claude Code how to work on keycloak-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything keycloak-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to shigechika/keycloak-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/shigechika/keycloak-mcp/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/shigechika/keycloak-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for keycloak-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/shigechika/keycloak-mcp/claude-md/github.svg)](https://agentmods.dev/instructions/shigechika/keycloak-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/shigechika/keycloak-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/shigechika/keycloak-mcp/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for keycloak-mcp CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/shigechika/keycloak-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/shigechika/keycloak-mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,368 This file is loaded in full into every session.
When invoked 1,368 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01368 $0.01368
Opus 5.5 $0.00547 $0.00547
Sonnet 5.5 $0.00274 $0.00274
Haiku 4.5 $0.00137 $0.00137

Measured 16d ago against content hash 30c6478dee05, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

keycloak-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

Overview

MCP server for the KeyCloak Admin REST API. Authenticates as a Service Account (OIDC Client Credentials Grant — no human password or TOTP); never calls the userinfo endpoint and never creates user sessions (the project describes this as "Infinispan-safe" — see README.md). Exposes 33 tools (users, MFA/credentials, groups, brute-force/security, events, admin events, sessions/clients, and a daily_brief morning report) over stdio transport, plus two opt-in group-change tools (plan_group_changes, apply_group_changes) registered only when KEYCLOAK_GROUP_WRITE_ROOT is set.

Commands

uv sync --dev
uv run pytest -v                  # all tests
uv run ruff check .               # lint
uv run ruff format --check .      # format check

This mirrors .github/workflows/ci.yml (matrix: Python 3.10–3.14 on Ubuntu, plus one Windows 3.12 job to catch stdio newline regressions). Plain-pip equivalents are documented in README.md's Development section.

Architecture

  • keycloak_mcp/auth.py — TokenManager: Client Credentials Grant token fetch/cache, refreshed 30s before expiry.
  • keycloak_mcp/client.py — KeyCloakClient: thin httpx wrapper over the Admin REST API; retries 429/502/503/504 and transport errors with exponential backoff; _paginate pages list endpoints.
  • keycloak_mcp/sites.py — SiteClassifier: labels IPs with a site name from an optional KEYCLOAK_SITES_INI file.
  • keycloak_mcp/server.py — MCPServer (mcp 2.x) server; all @mcp.tool() functions.
  • keycloak_mcp/group_changes.py — opt-in group moves: plan_changes / apply_changes (policy, digest, add-before-remove with read-back).
  • keycloak_mcp/__main__.py — CLI entry point (--check, --version) plus a Windows-only stdout wrapper that strips CRLF back to LF.

Required env vars: KEYCLOAK_URL, KEYCLOAK_CLIENT_ID, KEYCLOAK_CLIENT_SECRET. Optional: KEYCLOAK_REALM (default master), KEYCLOAK_SITES_INI, KEYCLOAK_DEFAULT_DATE_FROM_HOURS (default 24), and the heavy-tool bounds KEYCLOAK_DEADLINE (default 45s), KEYCLOAK_MAX_EVENTS (default 200000), KEYCLOAK_MAX_USERS (default 5000) — a wall-clock deadline + caps so a wide event window or a whole-realm get_totp_users returns a disclosed partial (⚠️) instead of blowing the ~60s gateway and hammering KeyCloak (see _paginate's deadline/max_total and server.py's _deadline_seconds/_max_events/_max_users). Each 0/negative disables. Group changes (keycloak_mcp/group_changes.py, registered by server.register_group_tools): KEYCLOAK_GROUP_WRITE_ROOT (unset = tools not registered), KEYCLOAK_PROTECTED_GROUPS (;-separated full paths, each must exist), KEYCLOAK_GROUP_BATCH_MAX (default 30), KEYCLOAK_GROUP_MODE (multi default / single = adding replaces every other membership, no DELETE sent), KEYCLOAK_GROUP_DEADLINE (default KEYCLOAK_DEADLINE). The digest is a staleness check, not an approval token; the approval gate belongs to the client. Configuration snapshots (keycloak_mcp/config_snapshot.py): KEYCLOAK_STATE_DIR (unset = none). Only daily_brief writes (first run of a day, complete reads only); get_config_changes compares and never writes. Secret-named string values are redacted before storing. KEYCLOAK_USER_ATTRIBUTE_WHITELIST (default unset, comma-separated attribute keys) opts specific custom user attributes into get_user's output — unset, get_user never fetches or surfaces attributes at all (see _user_attribute_whitelist/get_user_by_id), so no custom attribute reaches tool output, hence LLM context, unless an operator explicitly names it. A whitelisted key that matches _looks_like_credential_key's substring list (password, secret, token, …) is reported as blocked rather than shown — a safety net on top of the whitelist, not a guarantee for arbitrarily-named credential attributes.

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +4 lines · +65 tokens per session 30c6478dee05
  2. 18d ago Changed · +11 lines · +218 tokens per session 1d2442a19eab
  3. 28d ago Changed · +7 tokens per session a6dab8adec12
  4. 1mo ago Changed 7871c8188a9a
  5. 1mo ago First seen · 77 lines · 1,078 tokens per session scan A 88997e8e618b

Subscribe to this mod's changes

keycloak-mcp CLAUDE.md is an instructions file published in the GitHub repository shigechika/keycloak-mcp (0 stars, last pushed yesterday), licensed MIT. It adds 1,368 tokens to every session, about $0.0055 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories