Repository navigation
Add admin user creation MCP capability - #626
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new ChangesAdmin User Creation Capability
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Admin
participant adminUserCreateCapability
participant auditAdminCapabilityInvocation
participant AppDB
Admin->>adminUserCreateCapability: handler(email, username)
adminUserCreateCapability->>auditAdminCapabilityInvocation: wrap(createUser call)
auditAdminCapabilityInvocation->>AppDB: adminCreateUserWithPasswordSetup(email, username, baseUrl)
AppDB-->>auditAdminCapabilityInvocation: createdUser
auditAdminCapabilityInvocation->>auditAdminCapabilityInvocation: log audit (buildCreatedUserAuditReason)
auditAdminCapabilityInvocation-->>adminUserCreateCapability: createdUser
adminUserCreateCapability-->>Admin: { createdUser }
Related issues: None found. Related PRs: None found. Suggested labels: enhancement, admin, mcp Suggested reviewers: kentcdodds 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-626.kentcdodds.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/worker/src/mcp/capabilities/admin/admin-user-create.ts (1)
11-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse top-level
z.email()instead of deprecated.email()chain.Zod v4 promotes string-format validators to top-level functions;
z.string().email()still works but is deprecated and will be removed in a future major version.♻️ Proposed fix
const inputSchema = z.object({ - email: z - .string() - .email() - .describe('Email address for the account to create.'), + email: z + .email() + .describe('Email address for the account to create.'),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/worker/src/mcp/capabilities/admin/admin-user-create.ts` around lines 11 - 23, The input schema in admin-user-create should use the top-level email validator instead of the deprecated string method. Update the email field in inputSchema to use z.email() directly, keeping the existing describe text and preserving the username field behavior. Locate this in admin-user-create.ts where inputSchema is defined.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/worker/src/mcp/capabilities/admin/admin-user-create.ts`:
- Around line 11-23: The input schema in admin-user-create should use the
top-level email validator instead of the deprecated string method. Update the
email field in inputSchema to use z.email() directly, keeping the existing
describe text and preserving the username field behavior. Locate this in
admin-user-create.ts where inputSchema is defined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6071f56e-2609-4241-9306-13f890b2eee6
📒 Files selected for processing (5)
docs/contributing/adding-capabilities.mdpackages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.tspackages/worker/src/mcp/capabilities/admin/admin-shared.tspackages/worker/src/mcp/capabilities/admin/admin-user-create.tspackages/worker/src/mcp/capabilities/admin/domain.ts
Summary
admin_user_createto the admin MCP capability domain.adminCreateUserWithPasswordSetupso MCP creation matches the admin UI flow: create account, assign defaultuserrole, verify email, and return a reset-password setup link.Testing
npm run validate✅System recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@36cfdbb· Head:417cfabClassification: extends — this PR adds one mutating admin capability to the existing admin MCP domain and reuses the existing admin user creation service.
Primitives touched
capability-registryadmin_user_createin the admin domainrbacrequiredRole: 'admin'capability gatemcp-serverd1-app-dbSystem map
Change flow
sequenceDiagram participant Host as MCP host participant Cap as admin_user_create participant Service as adminCreateUserWithPasswordSetup participant DB as APP_DB Host->>Cap: execute codemode.admin_user_create({ email }) Cap->>Service: call existing admin UI service Service->>DB: create user, assign user role, create setup token Cap->>DB: write sanitized audit event Cap-->>Host: created user metadata + setup linkInvariants
per-user-isolation: the capability creates account metadata and setup-token state only through the existing admin service; it does not read or expose user content.requiredRole: 'admin') and enforced again at execute time.Summary by CodeRabbit