Skip to content

Show every MCP role of a member on the roles and users pages - #1777

Closed
helpcodeai wants to merge 3 commits into
mainfrom
fix/roles-page-all-assignments
Closed

helpcodeai wants to merge 3 commits into
mainfrom
fix/roles-page-all-assignments

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

A member can hold several MCP roles: ones an admin set by hand, ones that come from a single sign-on group sync, and grants with no workspace that apply everywhere. They can use the tools of all of them combined (RolesService.getAllowedToolIds). But Settings → Roles and the older admin roles page only showed and edited the deprecated single users.mcpRoleId, through the deprecated PUT /api/roles/assign/:userId. So an admin could pick role X, see X on the page, and the member still reached more connectors through a synced role nobody could see. The users pages had the same problem in their read-only "MCP role" column.

Changes

  • Backend
    • New GET /api/roles/members (ADMIN): every member of the active workspace with all their role assignments { roleId, roleName, source, global }, plus connectors, the connectors their roles reach. connectors is null when roles don't limit the member (an ADMIN, or no role while the workspace has no tool list) and [] when they reach nothing. Every query is filtered by organizationId. Grants with no workspace are included, using the same scope as getAllowedToolIds.
    • GET /api/roles/assignments/:userId now returns 404 for a user who isn't a member. Before, it would show that user's workspace-independent grants to any admin.
    • GET /api/users also returns mcpRoles (all assignments, same shape). The Swagger docs now mark mcpRoleId / mcpRole as deprecated.
    • Fixed the GET /api/roles description: it said a member with no role always reaches every tool, which stopped being true once a workspace has a tool list.
  • Frontend
    • New shared MemberRoleAssignments table, used by both /settings/roles and /admin/roles. For each member who isn't an admin it shows every role as a chip. Manual roles are edited with a multi-select that calls PUT /api/roles/assignments/:userId, which replaces only manual roles. Synced roles are read-only and labelled "from single sign-on group", with a link to Settings → Single sign-on → Role mappings. Roles that apply in every workspace are labelled "all workspaces" and are also read-only. A new column shows how many connectors the member's roles reach.
    • One line above the table: a member can use the tools of all their roles together.
    • The users pages (/settings/users, /admin/users) show all role chips instead of the single deprecated role.
    • roles.assignToUser (the deprecated endpoint) is removed from lib/api.ts. The backend endpoint stays for old clients.
    • i18n keys added in en, de and it. The unused settingsRoles.assign.noRestriction is removed.
  • Docs: docs/api-reference.md (role assignment endpoints and sources; also fixes an existing error: it said the rate-limit editor UI did not exist yet, but it does), docs/operations/member-visibility.md (step 3 said to assign roles under Settings → Users, but they are assigned under Settings → Roles), docs/sso.md.

Cloud and self-hosted behave the same; nothing here depends on the deployment mode. No schema change.

Type

  • Bug fix

Testing

  • Added/updated unit tests (roles.service.spec.ts: getMemberAssignments, getUserRoles membership check; users.service.spec.ts: mcpRoles)
  • Added Playwright spec tests/e2e/role-assignments.spec.ts. Not run locally because no dev server is allowed on the shared machine. CI runs it.

Commands, with actual results:

  • packages/backend: npx jest src/roles/roles.service.spec.ts src/users/users.service.spec.ts --maxWorkers=2 → 2 suites, 82 tests passed
  • packages/backend: npm run lint → 0 errors, 11 warnings that were already there (none in new code). eslint --fix changed no files.
  • packages/backend: npx tsc --noEmit -p tsconfig.json → exit 0
  • packages/frontend: npm run lint → 0 errors, 51 warnings. The ones in the touched files are the existing set-state-in-effect / exhaustive-deps pattern of these pages.
  • packages/frontend: npx tsc --noEmit -p tsconfig.json → exit 0

Checklist

  • My code follows the existing code style
  • I have tested my changes locally (unit tests, lint, typecheck)
  • I have updated documentation
  • This PR has a descriptive title

Related Issues

None filed.

Access is the union of all role assignments, but the roles pages showed
and edited only the deprecated single users.mcpRoleId, so a role granted
by a single sign-on group stayed invisible. Add GET /api/roles/members
with all assignments and the connectors they reach, edit manual roles
through PUT /api/roles/assignments/:userId, mark synced and all-workspace
roles read-only, and return mcpRoles from GET /api/users.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant