identity-aiops
Governed SSO/IAM operations for Keycloak and Authentik — login-failure, stale-permission, client-config, and MFA RCA, with unbypassable audit logging (MCP + CLI), budget/runaway guards, dry-run, and undo/rollback.
README
<!-- mcp-name: io.github.AIops-tools/identity-aiops -->
Identity AIops
Governed AI-ops for self-hosted identity providers — Keycloak + authentik.
identity-aiops gives AI agents (and the humans supervising them) a safe,
audited way to operate the identity plane of self-built and small/mid-size
infrastructure: who can sign in, what failed and why, which OAuth clients are
misconfigured, and who still has no second factor. It is built for teams
running their own Keycloak or authentik who want agent-driven identity
operations with receipts — every tool call is audited, and writes carry
risk-tier labels with dry-run previews and undo tokens.
Verification status: modelled on the public Keycloak admin REST API and authentik API v3 and exercised against mocked responses; there is no recorded end-to-end run against a live instance yet.
identity-aiops doctoris the fastest live check — seedocs/VERIFICATION.md.
What it does
| Area | Tools |
|---|---|
| Realm / system | overview, realm settings (brute-force protection, password/OTP policy), identity providers |
| Users | list/search, detail, count, sessions, credentials (MFA surface), groups, members, lockout status |
| Events | authentication events, admin/config-change events |
| Clients | list, detail, per-client sessions, session stats |
| Flagship RCA | login_failure_rca — brute-force (spray/targeted) vs misconfigured client vs expired-credential storm vs lockout storm; stale_access_audit — dormant users, never-logged-in accounts, service accounts used interactively, orphaned sessions; client_misconfig_audit — wildcard/http redirect URIs, public clients with secrets, implicit flow, missing PKCE, password grant (ranked risk); mfa_coverage_analysis — coverage %, gap list |
| Governed writes | disable_user / enable_user (undo pair), revoke_user_sessions, require_password_reset (undo clears the flag), update_client_redirect_uris (undo replays the prior list), rotate_client_secret (masked priorState) |
29 MCP tools: 21 reads (including the 4 analyses) + 6 governed writes + 2 undo
tools (undo_list, undo_apply). The
same tools work on both platforms — a per-target platform field selects the
API shape (auth flow + resource paths).
Supported platforms
| Platform | API | Auth |
|---|---|---|
| keycloak | Admin REST API (/admin/realms/{realm}/...) |
OAuth2 client-credentials grant against /realms/{realm}/protocol/openid-connect/token; short-lived token auto-refreshed on 401 |
| authentik | API v3 (/api/v3/...) |
Long-lived API token (Bearer) |
Platform notes: require_password_reset, rotate_client_secret,
client_sessions, client_session_stats, and user_lockout_status are
Keycloak-shaped (authentik has no equivalent endpoint — the tools return a
teaching error there). authentik contributes the global session list used by
the stale-access audit's orphaned-session check.
Missing a platform (Authelia, Zitadel, Ory...), an endpoint, or an analysis you need? 缺功能提 issue/PR 欢迎留言 — open an issue or PR at https://github.com/AIops-tools/Identity-AIops, feature requests welcome.
What this tool does, and does not, decide
It delivers identity-provider operations — reads and writes — accurately and
records every one of them. It does not decide whether a write is allowed to
happen. That is the agent's judgement, or the permission of the account you
connect it with: give the Keycloak service account (or authentik token) only
the roles you want the agent to have — view-users / view-events /
view-clients and no manage-* — and the writes fail at the server, the place
that actually owns the permission.
So there is no read-only switch, no policy file, no approval gate to configure.
The one thing the tool guarantees is that nothing is silent: every call, over
MCP and over the CLI alike, lands an audit row in
~/.identity-aiops/audit.db, and reversible writes still capture their
before-state (fetched, never guessed) and record a replayable inverse.
Each tool declares a
risk_level, carried into the audit row as a descriptive tier — so a reviewer can see at a glance that a row was, say, a high-risk secret rotation. It is a label, not a gate.
Running a smaller / local model? See agent-guardrails.md — it lists the guardrails this tool now enforces for you (so you don't spend prompt budget restating them) and gives a ready-made system prompt for what's left.
Quick start
uv tool install identity-aiops # or: pipx install identity-aiops
identity-aiops init # wizard: target + realm + credential (encrypted)
identity-aiops doctor # token acquisition + user-count probe per target
identity-aiops overview # one-shot estate summary
For Keycloak, create a confidential client with Service accounts roles
enabled and grant its service account the realm-management roles you want the
agent to have (start with view-users, view-events, view-clients; add
manage-users / manage-clients only if you want the governed writes). For
authentik, create an API token for a (least-privileged) admin user.
CLI surface: users (list/show/sessions/credentials + disable/enable/
revoke-sessions/require-reset), clients (list/show + set-redirect-uris/
rotate-secret), events, overview, doctor, secret, init, mcp.
Write commands take --dry-run and always double-confirm; execution is
delegated to the governed MCP twins so CLI writes land in the audit log too.
MCP configuration
{
"mcpServers": {
"identity-aiops": {
"command": "uvx",
"args": ["--from", "identity-aiops", "identity-aiops-mcp"],
"env": {
"IDENTITY_AIOPS_MASTER_PASSWORD": "<master password for secrets.enc>"
}
}
}
}
env-block caveat: MCP clients launch the server with a minimal environment — variables from your shell profile are NOT inherited. Anything the server needs (
IDENTITY_AIOPS_MASTER_PASSWORD, an alternateIDENTITY_AIOPS_HOME,IDENTITY_AUDIT_APPROVED_BYto attribute writes on the audit trail) must be set in theenvblock above.
Governance
Every MCP tool runs through the vendored governance harness
(identity_aiops/governance/, zero external dependencies):
- Audit — every call (including errors) lands in
~/.identity-aiops/audit.dbwith params, status, and risk level, plus any optional approver/rationale annotation. It records; it does not authorize. - Budget — per-session call/time budgets and a runaway breaker
(
IDENTITY_MAX_TOOL_CALLS,IDENTITY_MAX_TOOL_SECONDS,IDENTITY_RUNAWAY_MAX) — a safety backstop, not an authorization gate. - Risk tier — reads are
low; containment/hygiene writes (disable_user,revoke_user_sessions,require_password_reset) aremedium; access-granting or boundary-replacing writes (enable_user,update_client_redirect_uris,rotate_client_secret) arehigh. The tier is a descriptive label carried onto the audit row, not a gate — whether a write runs is the agent's judgement or the connecting account's permissions.IDENTITY_AUDIT_APPROVED_BY/IDENTITY_AUDIT_RATIONALEare optional annotations recorded when set, never required. - Undo — reversible writes capture the REAL prior state (fetched before
mutating, never guessed) and record a replayable inverse descriptor in
~/.identity-aiops/undo.db. Irreversible writes (revoke_user_sessions,rotate_client_secret) record priorState only — the secret is stored masked, never in clear. - Sanitize — every string an IdP returns is folded through an injection-safe normaliser (bounded length, control characters stripped) before an agent sees it.
- Secrets — credentials live Fernet-encrypted (scrypt-derived key) in
~/.identity-aiops/secrets.enc, never plaintext on disk; a legacyIDENTITY_<TARGET>_SECRETenv var is honoured as fallback andidentity-aiops secret migratemoves it in. TLS verification defaults ON.
Configuration
~/.identity-aiops/config.yaml (created by init):
targets:
- name: sso1
platform: keycloak
base_url: https://sso.example.com
realm: master
username: identity-aiops-agent # the confidential client's client_id
verify_ssl: true
- name: ak1
platform: authentik
base_url: https://auth.example.com
verify_ssl: true
Set IDENTITY_AIOPS_HOME to relocate all state (config, secrets, audit,
undo). IDENTITY_AIOPS_CONFIG points the MCP server at an alternate
config file.
Development
uv sync
uv run pytest -q
uv run ruff check .
MIT License. Part of the AIops-tools line — governed AI-ops tooling for self-hosted infrastructure.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。