Skip to main content
An MCP server’s metadata stays perfectly valid right up to the moment its client secret lapses — and then every token request fails at once, with nothing in the published configuration having changed. That is only visible from inside the identity provider. Entra first, because it is the only major provider exposing credential expiry through a proper API.

Check for expiring credentials

The secret is read from the environment only — there is deliberately no --client-secret flag, because anything on the command line is readable through ps and lands in shell history.
The app registration needs the Application.Read.All application permission with admin consent. Authentication is Microsoft’s own ClientSecretCredential from @azure/identity, and paging is the Graph SDK’s PageIterator — no Graph URL is built by hand.

Rotate before it lapses

--rotate fixes the expiring-secret finding instead of only reporting it: for each expiring secret it adds a replacement through Graph’s own addPassword action and prints the new value once. The old secret stays valid during the switchover, so rotation needs no downtime; retiring it is your call once the deployment presents the new one. Certificates are report-only — a key pair is something only you can mint.
Rotation writes to the tenant, so it needs Application.ReadWrite.All and never runs without the explicit flag.

Exit codes