Skip to content

feat(onboarding): admin-consent link + bring-your-own-app guidance + restart-after-az-login - #37

Merged
Gregory Joseph (gnjoseph) merged 1 commit into
feat/spe-mcp-serverfrom
agents/pr3-wi24-consent
Jul 9, 2026
Merged

feat(onboarding): admin-consent link + bring-your-own-app guidance + restart-after-az-login#37
Gregory Joseph (gnjoseph) merged 1 commit into
feat/spe-mcp-serverfrom
agents/pr3-wi24-consent

Conversation

@gnjoseph

Copy link
Copy Markdown
Collaborator

Implements the owning-app consent & bring-your-own-app onboarding improvements from the PR #3 review.

What changed

1. Copy-paste admin-consent link (src/tools/create-app.ts)

After the owning app is created (or reused) and its SPE permissions are requested, the tool output now appends a Grant admin consent section with a copy-paste tenant-wide admin-consent URL:

https://login.microsoftonline.com/{tenantId}/adminconsent?client_id={appClientId}
  • {tenantId} = the real signed-in tenant id (identity.tenantId); {appClientId} = the newly created/reused app's public client id (app.appId).
  • If you are a Global Administrator — opening the link grants consent for the entire tenant in one step.
  • If you are NOT an admin — copy the link and send it to your tenant admin to grant consent on your behalf.
  • Non-blocking / informational: no browser is opened, provisioning is not gated on consent, and nothing throws. The URL contains only the tenant id + public client id — never a token/secret.
  • Surfaced on both the create and reuse paths (a reused app may have just had permissions re-requested best-effort, so consent can still be pending).
  • Missing-tenant fallback: if the tenant id is genuinely unavailable, the link targets organizations and the section notes it.

2. Skill reference removed (src/tools/create-app.ts)

Removed the dangling Ports the full-setup skill \02-app.ps1`` comment. There is no appropriate public URL to point at, so it was removed rather than inventing one.

3. Bring-your-own-app clarification (src/index.ts)

The config.clientId startup branch now clearly documents that this is the bring-your-own-app path — the caller has already pre-created an owning app (via --client-id / SPE_CLIENT_ID) and the server signs in as that app (no owning app is provisioned). A new startup line makes this explicit on stderr.

4. Restart-after-az login guidance (src/index.ts)

The bootstrap "not signed in" message now tells users to restart the MCP server after az login, because auth/session state is stamped at startup (a restart begins a fresh session and re-primes authentication).

5. New pure module + tests

src/onboarding-messages.ts houses the message builders (adminConsentUrl, adminConsentSection, byoAppStartupNote, azLoginNotSignedInMessage) so the copy is unit-tested in one place.

Test evidence

  • npm run lint ✅ · npm run typecheck ✅ · npm run build
  • npm test ✅ — 713 passed | 3 skipped (baseline ~698 + 15 new tests).
  • New/updated tests assert: the exact admin-consent URL (correct {tenantId} + client_id={appId}), the admin-vs-non-admin explanation, non-blocking wording, the missing-tenant fallback, no secret/token in the URL (only client_id), and that the vague skill reference is gone.

Guardrails

…restart-after-az-login

Addresses PR #3 review comments on the owning-app onboarding flow:

- create-app: after the owning app is created (or reused) and its SPE
  permissions are requested, append a copy-paste tenant-wide admin-consent
  link (https://login.microsoftonline.com/{tenantId}/adminconsent?client_id={appId})
  built from the real signed-in tenant id + the app's public client id.
  Explains the Global-Admin (grant tenant-wide) vs non-admin (forward the
  link) paths. Non-blocking/informational: no browser is opened, provisioning
  is never gated on consent, and the URL carries no secret.
- create-app: remove the dangling "full-setup skill 02-app.ps1" reference
  (no public URL to point at, so removed rather than invented).
- index.ts: clarify the config.clientId branch is the bring-your-own-app path
  (a pre-created owning app supplied via --client-id / SPE_CLIENT_ID) and emit
  an explicit startup line saying no owning app will be provisioned.
- index.ts: extend the bootstrap "not signed in" message to instruct users to
  RESTART the server after `az login`, since auth/session state is stamped at
  startup (a restart begins a fresh session and re-primes auth).
- New src/onboarding-messages.ts houses the pure message builders with the
  missing-tenant fallback (organizations) + unit tests; extend create-app tests
  to assert the URL, admin/non-admin copy, no-secret guarantee, and skill-ref
  removal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gnjoseph
Gregory Joseph (gnjoseph) merged commit e6ec51e into feat/spe-mcp-server Jul 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant