MCP with the company account#
Besides service credentials, the Empowerment Center MCP server accepts OAuth tokens from the organization's identity provider, the same one used for single sign-on. The user configures the assistant with just the server address and, the first time, signs in with their company account: there is no secret to copy or to expire.
Before you start#
- The MCP server has to be enabled (see MCP server).
- The installation has to have single sign-on configured with an OIDC provider (or SAML with a separate OIDC issuer). See the security chapter.
ECENTER_PUBLIC_URLhas to be configured: with OAuth it is mandatory and without it the backend does not start.- Users need, as always, API and MCP access and Access to Empowerment Center, and an enabled account in ECenter with the same login the provider gives.
This mode only exists in the MCP server. The query API only accepts service credentials.
How it works#
ECenter acts as the resource server of the MCP authorization specification: it neither issues tokens nor registers clients.
- The assistant calls
/api/mcpwithout a token. - ECenter responds
401with the headerWWW-Authenticate: Bearer resource_metadata="https://ecenter.example.org/.well-known/oauth-protected-resource/api/mcp", scope="ecenter.mcp". - The assistant reads that metadata, which says which provider issues the tokens and which scope to request.
- The assistant opens the provider's sign-in page (authorization code flow with PKCE) and the user signs in with their company account.
- The assistant calls again with the access token. ECenter checks the signature with the provider's keys, the issuer, the dates, the audience (that the token is for this server), the client, the
ecenter.mcpscope and the login. - The ECenter user with that login comes in, with all their privileges, through the
MCPchannel and with the referenceoauth:<client_id>.
The resource is always ECENTER_PUBLIC_URL + /api/mcp. A token issued for another resource is not accepted.
Configure ECenter#
ecenter.security.bearer:
public-url: https://ecenter.example.org # mandatory: the resource is this + /api/mcp
oauth:
sso-provider: empresa # the SSO registration (spring.security.oauth2.client.registration.empresa)
issuer-uri: # if the token issuer is not the SSO's
audiences: [] # by default, the resource
scopes: [ecenter.mcp] # those the token has to carry
scopes-supported: [] # those announced, if requested under another name
allowed-clients: [] # accepted client_id values; empty, any
clock-skew: 30s
| Property | What it is |
|---|---|
sso-provider |
The name of the single sign-on registration. The issuer and the login attribute (login-attribute, by default preferred_username) come from it. |
issuer-uri |
The token issuer, if it is not the registration's (Entra ID with v1 tokens, or a SAML sign-in). |
audiences |
The audiences accepted. By default, the resource. |
scopes |
The scopes the token has to carry, in scope or scp. |
scopes-supported |
What is announced in the metadata, if the provider requests the scope under another name. |
allowed-clients |
The client_id values of the accepted assistants. Recommended in Entra ID. |
clock-skew |
The accepted clock skew. |
A half-done configuration does not start: an sso-provider that is no registration, an empty public-url, or audiences, allowed-clients, issuer-uri or scopes-supported without sso-provider.
The proxy has to send /.well-known/oauth-protected-resource/ to the backend as well as /api/. The frontend image already does. Check it:
It must respond 200 with resource, authorization_servers, scopes_supported and bearer_methods_supported. Without OAuth configured, 404.
With this, the Connect an assistant (MCP) card in Service credentials offers With the company account and a configuration snippet with just the address.
Warning
The login has to come from a value the user cannot change. If the provider lets the email be edited and the login is the email, a user could impersonate another. Use the same immutable value as in single sign-on and SCIM provisioning.
Guide for Keycloak#
Keycloak does not support the resource parameter (RFC 8707): the audience is set by a client scope with an Audience mapper.
- Use the realm of the ECenter single sign-on.
- In Client scopes › Create client scope, create
ecenter.mcp: type None, OpenID Connect protocol, Include in token scope enabled. If you want a consent screen, enable Display on consent screen with a text such as “Query Empowerment Center with your permissions”. - In that client scope, Mappers › By configuration › Audience: Included Custom Audience with the exact resource (
https://ecenter.example.org/api/mcp), Add to access token enabled and Add to ID token disabled. - Create the assistant's client (Clients › Create client): OpenID Connect, Client authentication disabled (public), only Standard flow, the assistant's Valid redirect URIs, Web origins
+if the assistant runs in the browser and, in Advanced, Proof Key for Code Exchange Code Challenge MethodS256. In its Client scopes tab, addecenter.mcpas Optional or Default. - Check the login: by default it is
preferred_username, which has to match the ECenter login. - In ECenter,
ecenter.security.bearer.oauth.sso-providerwith the registration name, andpublic-url.
ECenter does not register clients: create the client of each assistant by hand and give it its client ID. Keycloak also supports dynamic client registration and, experimentally, Client ID Metadata Documents; use them if your organization allows them.
Guide for Microsoft Entra ID#
Entra ID does not support the resource parameter in its v2 endpoint, nor dynamic registration: the scope is requested with the API's identifier and each assistant is registered by hand.
- The API (App registrations; it can be the same application as single sign-on): Expose an API › Application ID URI (
api://<application id>) › Add a scopeecenter.mcp, with admin and user consent. In the Manifest,requestedAccessTokenVersion: 2, so that the issuer is the same as in sign-in. - The assistant's client: another public App registration with its Redirect URIs; in API permissions, My APIs › the ECenter one › Delegated
ecenter.mcp, with Grant admin consent. Give its client ID to the assistant. -
ECenter:
ecenter.security.bearer: public-url: https://ecenter.example.org oauth: sso-provider: empresa # the Entra ID OIDC registration (…/v2.0) audiences: [<API application id>] # the aud of a v2 token is the id, not the URL scopes: [ecenter.mcp] # as it arrives in scp scopes-supported: [api://<application id>/ecenter.mcp] # as the assistant requests it allowed-clients: [<assistant client ID>]
In a v2 token, preferred_username is the UPN. If the ECenter login is another value, add it as an optional claim of the access token and name it in the single sign-on login-attribute. With v1 tokens, the issuer is https://sts.windows.net/<tenant>/ (put it in issuer-uri), the audience is the Application ID URI and the client goes in appid.
Errors#
| HTTP | code |
When | What to do |
|---|---|---|---|
| 401 | CREDENTIAL_REQUIRED |
No token. It carries resource_metadata so that the assistant discovers where to request it. |
Normal on the first call. |
| 401 | INVALID_CREDENTIAL |
The token is not valid: signature, issuer, expiry, audience, client not accepted or no enabled account with that login. It does not say which. | Look at the reason in the audit (below). |
| 403 | INSUFFICIENT_SCOPE |
Everything is valid except the scope. | The assistant has to authorize again requesting ecenter.mcp. |
| 503 | IDENTITY_PROVIDER_UNAVAILABLE |
The provider's keys cannot be read. It carries Retry-After. |
Check that the backend reaches the provider. A newly rotated key comes in on retrying, within 30 s at most. |
In the audit, the accesses appear as signing in with the company account from the client '…' through the MCP server, and the rejections with their reason: the token belongs to another issuer, is for another resource, has expired, the client is not accepted, it lacks the scope or there is no enabled account with the token's login.
A frequent mistake with Keycloak is removing ecenter.mcp from the scope the assistant requests: the token arrives without the ECenter audience (that client scope sets it) and is rejected as “for another resource”.