feat(mcp): user_view MCP App — interactive user profile (KLA-403)#20
Merged
Conversation
Adds the user-detail MCP App: pass username/email/ID, get back a structured profile with header, MFA enrollment, group memberships, SSH keys, and recent insights events. Mirrors the dashboard's "fan out parallel API calls + aggregate" pattern, leans on the typed-tool helper from PR #19, and uses the shared jcApp scaffolding from PR #18. Server side (apps_user.go): - userViewArgs: single User field (resolves via the existing UserConfig resolver, so username/email/24-char ID all work) - userViewData: header + mfa + groups[] + ssh_keys[] + recent_events[] + warnings[] - fetchUserViewData fans out four goroutines: * GET /systemusers/{id} for the header & MFA flags * V2 /users/{id}/memberof for group memberships (sorted by name) * V1 /systemusers/{id}/sshkeys for SSH keys * Insights /events filtered by initiated_by.username, last 30d, limit 50 - Best-effort sub-fetches: a transient failure on groups or SSH keys becomes a Warnings entry, doesn't block the rest of the view - last_login is derived from the most recent event (cheap, no extra call) - previewSSHKey trims public keys to "<algo> <12-char-prefix>…" so the UI panel stays scannable Client side (apps_html/user.html): - Header card: avatar (initials), name + email + "joined / last seen", status badges (Active/Suspended/Locked + MFA on/off) - Groups: pill list - SSH keys: name + algo-prefixed preview + create date table - Recent events: timestamp + service + event_type + result + client IP - Refresh re-runs user_view with the username captured from the initial payload (survives the iframe reload without needing args replayed) Tests (apps_user_test.go): - previewSSHKey covers algo-prefixed, short, and unstructured inputs - fetchUserViewData_Aggregates: full fixture (user + 2 groups + 1 ssh key + 2 events) verifies header, MFA enrollment, group sort, ssh preview shape, event count, last_login derivation - fetchUserViewData_RequiresUser: empty input rejected - user_view exposes _meta.ui.resourceUri - ui:// resource has common.js injected and the marker stripped - Tool count 196 → 197, expected list adds user_view Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- apps_user.go: fetch user detail synchronously before fanning out so the Insights events filter can use the canonical username (not the caller's raw input, which may be an email or hex ID). - user.html: read mfa.status === "ENROLLED" alongside totp_enabled so non-TOTP MFA enrollments still show the badge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 64f5432. Configure here.
Drop the hand-rolled joinWarnings helper in favour of strings.Join, addressing Cursor Bugbot's low-severity nit on PR #20. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CodeQL flagged the el(...) helper's `appendChild(c)` branch as a client-side XSS sink because the analyzer can't prove `c` is a Node. Tighten the helper across the three apps to only accept strings (which go through createTextNode) or instances of Node — same runtime behaviour, but gives CodeQL the type proof it needs to mark the path sanitized. Closes the open dashboard.html alert (repos/TheJumpCloud/jc-cli/code-scanning/alerts/1) and pre-empts the same alert showing up on insights.html and user.html. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| children.forEach(function(c) { | ||
| if (typeof c === 'string') node.appendChild(document.createTextNode(c)); | ||
| else if (c) node.appendChild(c); | ||
| else if (c instanceof Node) node.appendChild(c); |
| if (c == null) return; | ||
| if (typeof c === "string") n.appendChild(document.createTextNode(c)); | ||
| else n.appendChild(c); | ||
| else if (c instanceof Node) n.appendChild(c); |
Remove the catch-all setAttribute / style-passthrough fallback in the
el() DOM builder across the three MCP Apps. No callers exercised that
branch (every attr is className or textContent, plus dashboard's fixed
inline style palette), and keeping it open meant a future caller
passing {href: untrusted} or {onclick: ...} would silently introduce
an XSS sink.
Helpers are now strictly text-content + className only; anything else
is dropped. Coerce values to String() defensively. Doesn't close the
js/xss CodeQL alerts (analyzer can't prove inter-procedural Node
provenance — to be dismissed as false positive), but eliminates the
real future-misuse footgun.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jrennichjc
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
What's in the box
Server (`apps_user.go`)
Client (`apps_html/user.html`)
Tests (`apps_user_test.go`, 5 tests)
Test plan
Closes KLA-403.
🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it introduces new multi-endpoint aggregation logic (V1/V2/Insights) and a sizeable embedded HTML UI; failures or schema mismatches could surface as incorrect or partial profile data.
Overview
Adds a new MCP App,
user_view, which takes a user identifier (username/email/ID) and returns a structured profile payload that MCP App-capable hosts render via a newui://jc/userHTML resource.Server-side, the new handler resolves the user then fans out in parallel to fetch group memberships, SSH keys (with key previews), and last-30d Insights events (bounded), returning best-effort results with
warningswhen sub-fetches fail.Also tightens the DOM helper used by the existing
dashboardandinsightsapps to be text/Node-only (dropping unknown attributes) to reduce XSS surface, and updates tool registration/tests to include the new tool and expected tool count.Reviewed by Cursor Bugbot for commit cacdeed. Bugbot is set up for automated code reviews on this repo. Configure here.