feat: add agent selection to MCP authorization challenge - #6066
Conversation
|
|
Running ultrareview automatically — This change introduces a new agent authorization path in the MCP consent flow, touching authorization logic, new SQL queries, cache namespaces, feature flags, and token redemption with security-sensitive fail-closed behavior.... I'll post findings when complete. |
DemoWhat it shows:
|
There was a problem hiding this comment.
Ultrareview completed in 13m 20s
All reported issues were addressed across 20 files
Not reviewed (too large): server/internal/mcp/consent_assets/consent-tools.js (~2 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.
Linked issue analysis
Linked issue: AIM-196: feat: add agent selection to the existing MCP authorization challenge
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Allow an authenticated human to choose self or an eligible existing agent. | The consent screen adds an agent selector for resolved human sessions, with same-organization candidate filtering and support for owners or callers with exact agent:authorize permission. |
| ✅ | Show only active, unblocked agents whose live direct policy allows endpoint-scoped mcp:connect. | Candidates are filtered for lifecycle, deletion, owner membership, organization, and live agent policy using the challenged endpoint and fixed mcp:connect check. |
| ✅ | Repeat authorizer, tenant, lifecycle, ownership, endpoint, direct-policy, and owner-policy checks at final authorization. | The final approve_agent path reloads the endpoint and reruns target matching, human membership/policy, agent lifecycle and ownership, direct agent policy, and owner policy checks. |
| ✅ | Fix the requested policy to endpoint-scoped mcp:connect without broadening scope, switching endpoints, mutating direct agent policy, or creating an agent. | The authorization target snapshots the endpoint and mcp:connect scope, validates it against the final endpoint, and the flow only records a handoff; it does not create agents or update policy. |
| ✅ | Require explicit agent authorization, disable reusable consent for agent subjects, and fail closed until agent-session minting exists. | Agent approval uses a distinct approve_agent action, skips reusable consent persistence, stores an isolated agent grant namespace, and token redemption rejects the handoff until the downstream session lane is available. |
| ✅ | Keep existing human-subject MCP authorization behavior unchanged. | Agent-specific UI and processing are gated behind resolved human authorization and selected-agent state; self approval continues through the existing consent and tool-selection paths. |
| Keep agent selection disabled for production cohorts until the AIM-199 safety gate passes. | The PR adds independently default-off M1 and M2 feature gates and documents the safety-gate dependency, but the diff does not show an explicit AIM-199 evaluation or enforcement beyond operational flag configuration. |
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 13 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
ca78e45 to
972317d
Compare
de0c246 to
1295ae7
Compare
This comment has been minimized.
This comment has been minimized.
972317d to
db91a5a
Compare
4b3bc2b to
8e9fc1d
Compare
8e9fc1d to
65b7a4e
Compare
fec3154 to
1f0a170
Compare
This comment has been minimized.
This comment has been minimized.
Replace the native agent_id select with a bordered radio-card group that names each actor and its consequence, lead the page with the actor choice so selecting an agent no longer collapses content above the control, show an explanatory policy panel carrying the selected agent's name, swap the summary verb to "Authorizing" for agent grants, and render only a pointer to Agent management when no agent is eligible instead of a one-option picker. Preview test now covers both agent-selection states and ships the real consent script so served previews exercise the actual interactions.
65b7a4e to
c038d19
Compare

Summary
Adds a feature-gated picker for eligible existing agents in the MCP authorization challenge. Agent approval is bound to the challenged endpoint's fixed
mcp:connectpolicy and rechecks the human authorizer, agent lifecycle and ownership, direct agent policy, and owner policy before producing the authorization handoff.Technical details
Stacked dependency
Targets
main; the prerequisite #6055 is merged.Authorization boundary
The picker lists same-organization agents that the caller may authorize and whose direct policy permits the requested endpoint. Approval creates no agent, reusable consent, credential, or admission decision; the downstream agent-session minting path consumes the isolated authorization handoff, and token redemption fails closed until that path is available.
Agent approval uses distinct consent actions and cache namespaces so older servers cannot silently reinterpret it as human approval during a rolling deployment.
Summary by cubic
Implements AIM-196 by extending the MCP authorization challenge from human-only approval to a feature-gated choice between the human and an eligible existing same-organization agent. Agent approval uses a fixed endpoint-scoped
mcp:connecthandoff; it creates no agent, reusable consent, credentials, or session, and token redemption fails closed until agent-session support exists.Authorization safeguards
agent:authorize; live direct-agent policy must allow the challenged endpoint.Rollout
gram-agent-management-m1andgram-agent-mcp-authorization-m2disabled for production cohorts until AIM-199 passes; existing human-only and in-flight challenges remain unchanged.Written for commit 0e4dd56. Summary will update on new commits.