Expose admin client/token credential creation and revocation over MCP
Problem and intended workflow
Access administration should be delegated to a trusted admin agent, too. The user states the tasks and controls assumptions and results in the UI; the agent chooses the policy fields, creates scenario profiles, provisions restricted execution identities, verifies the grant, and revokes temporary access when done.
The v0.70.0 MCP profiles tool can create policies, inspect effective tools, explain access, and assign/reassign an already provisioned client. It cannot complete credential bootstrap or revocation through the exposed MCP tools. The admin agent must currently leave MCP and invoke CLI (or a separate setup interface).
Add an admin-only MCP credential lifecycle for clients and agent tokens, so this flow requires neither CLI nor manual REST calls:
task brief → profiles → review assumptions/effective access → create locked client or pinned token → verify worker → inspect results → revoke
Keep the trusted admin agent's credential separate from the worker's credential. Selecting a profile in an admin session does not remove the admin's authority: it can clear the selection. The worker must receive its own server-enforced restricted identity.
Captured reproduction
Tested 2026-10-10 using the official v0.70.0 personal darwin/arm64 release archive, build revision 48ad26eee224a57b05e06c2be300047b4747c985 (release build metadata reports vcs.modified=true). Scratch HOME/config/data, loopback port 18874, telemetry/socket disabled, trusted synthetic stdio servers, no real service credentials or external writes.
-
Connect a trusted admin agent over MCP and inspect
tools/list. The inventory includesprofiles; no native client/token credential-management tool is exposed. -
Create
daily-researchthroughprofileswith a read cap, explicit deny rules, unknown tools denied, and code/management off.effective_toolsconfirms the intended one-tool grant. -
Attempt to assign a new client through MCP:
{ "name": "profiles", "arguments": { "operation": "assign", "client": "delegated-worker", "profile": "daily-research", "mode": "locked" } }Actual: MCP
isError: true, with:{ "code": "no_client_credential", "error": "client delegated-worker has no active client credential; connect it with a profile first" } -
A
profilescall withoperation: "create_token"is refused as unknown. The advertised operations arelist, get, create, update, delete, rename, classify, assign, list_clients, effective_tools, explain; there is no credential-create/revoke operation in that inventory. -
CLI
client add ... --profile daily-research --lock --expires-in 1hbootstraps the client, after which MCP assignment works. CLItoken create ... --profile daily-research --expires 1halso works. These CLI steps are the gap, not evidence of an execution authorization bypass. -
Restricted workers correctly reject forbidden writes, admin operations, and profile escape. MCP reassignment changes the existing client's effective policy on its next request without reconnecting. The separate token remains pinned to its own profile.
-
CLI token revocation makes an existing session's next request return HTTP 401,
Agent token invalid: token has been revoked. Preserve that behavior when exposing revocation through MCP.
The bounded retest retained tool schemas, request/response evidence, CLI outputs, screenshots and a fixture dispatch ledger; 44 assertions verified observed outcomes, including the missing capabilities. Essential reproduction details are included here without requiring local artifacts. Current main was not runtime-retested.
Capability acceptance criteria
- [ ] Discoverable, documented native admin MCP operations create a custom execution client credential and an agent token with an explicit profile, binding/pin, expiry, and identity/name. Reuse existing credential/config services and guards rather than implementing a separate authorization model. A dedicated tool is fine; do not require shell/code-execution escape hatches.
- [ ] MCP can list/show safe credential metadata and revoke either kind of identity. Revocation invalidates subsequent requests on already initialized sessions. Creation returns the raw credential only in the intended one-time delivery response; later list/show/profile/explain calls never return raw secrets or hashes.
- [ ] Restricted client credentials, agent tokens and unconfined/unauthenticated callers cannot discover or invoke privileged credential-management operations. Validate actual authorization on execution, not just tool visibility. Preserve applicable
require_mcp_auth, anonymous-binding guard,read_only_modeanddisable_managementbehavior. - [ ] Worker grants are server-enforced: locked client or pinned token; permitted servers/tools only; explicit handling of unknown tools; no unintended profile switching. Do not silently default a task identity to All servers or full permissions when the requested profile is invalid or missing.
- [ ] Handle duplicate client/token identities, invalid or deleted profiles, malformed expiry and conflicting requests with clear structured errors and no partial/orphan grants. Failed creation/assignment must not leave a broader usable credential behind.
- [ ] Credential delivery and audit are separated: full secrets may be delivered once to the authorized caller, but must be redacted from activity bodies/exports, debug logs, errors, notifications and retained configuration. Record actor, target identity, profile/mode, expiry, operation and result using safe metadata.
- [ ] Document the boundary between credential provisioning and installing a client application's config. For custom clients, provide the supported endpoint/header snippet; if built-in connect is exposed, preserve its preview/commit/staged-rotation behavior. Do not assume the agent can write a remote client's config.
Required end-to-end tests
Use an isolated daemon and deterministic synthetic upstreams with a dispatch counter. The success path below must use MCP only for administration, with no exec/CLI, hand-written REST management call, or direct test-store mutation to create/revoke identities. Initial daemon/fixture setup is allowed.
- [ ] Fresh client path: admin initializes → creates a restrictive profile → creates a new client credential locked to it → worker initializes using that credential → allowed read succeeds → write/private read/other-server/admin operation/profile escape are refused → admin revokes client through MCP → next request on the same session fails.
- [ ] Fresh token path: admin creates a token pinned to the profile with a short expiry → worker initializes → allowed and denied calls match the effective grant → admin revokes through MCP → same-session request fails. Verify expiry independently as well.
- [ ] Live reassignment: admin moves an existing client from research to a triage profile with one exact write exception; the next request on the same credential/session uses the new grant, without reconnecting or rewriting client config. A separate research token's grant stays unchanged.
- [ ] Parity and negative paths: compare effective-tools/access-explain decisions with real calls on supported routing surfaces, including direct/nested dispatch where applicable. Verify deleted pins fail closed, non-admin calls cannot mutate credentials, write-disabled management is honored, and duplicate/invalid requests leave no usable partial grant.
- [ ] Secret handling: capture logs, activity/export bodies, errors and notifications after create/list/show/revoke; assert that the delivered credential appears only in its authorized one-time response, not retained audit output. Check that revoked credentials cannot obtain metadata or tools through an existing session.
- [ ] Dispatch proof: denied and revoked calls produce zero upstream dispatches. Inspect semantic MCP results/inner errors, not HTTP 200 or a wrapper's success alone.
UI verification criteria
The user should inspect the admin agent's work; the user should not have to manually construct server lists, permission tiers or rule globs.
- [ ] After MCP provisioning, Profiles and Clients/Tokens show the new identity, its profile, lock/pin source, explicit expiry, and accurate active/revoked state. Profile
Used by/Assigned tolinks open the correct filtered identity view. - [ ] The review path exposes the agent's recorded assumptions and the exact effective callable tools, including write/destructive exceptions. Do not label a grant simply Read-only when it admits such exceptions. Clearly distinguish assumption prose from enforced resource/destination restrictions.
- [ ] Existing UI review works with credentials created by MCP: profile Tools → Callable shows the intended tool set; Clients exposes the correct locked binding; Activity shows allowed calls and blocked policy decisions with reasons and attributable identities. Verify with screenshots and behavioral assertions.
- [ ] MCP assignment/revocation updates open views without a manual refresh. Preserve unsaved user edits when an admin agent changes a profile; show a conflict/reload affordance. Capture before/after assignment and revocation states.
- [ ] Present an intentional short task lease as planned expiry; do not imply the user must reconnect merely because a freshly created one-hour worker credential expires soon. Task completion/revocation should remain visible as an outcome.
- [ ] Retain a readable admin lifecycle audit showing who issued/revoked which identity and for which profile, without exposing its secret. Provide deep links the admin agent can give the user for assumptions, grant and task results. A unified task review/diff view is a useful follow-up, but basic lifecycle review must work with this change.
Related work and scope
Related: #1548 (preflight/dispatch policy parity). Use effective-tools/access-explain plus actual calls to verify grants until that issue is fixed; a false-ready preflight must not make lifecycle E2E tests pass.
The requested scope is client/token creation, safe inspection and revocation over MCP, with UI parity and end-to-end proof. Rotation/regeneration may reuse this boundary later; a broad task-orchestration redesign is not required to ship the missing lifecycle.