Set Up MCP Authentication

Last modified by superadmin on 2026/11/25 21:24

Make agents such as OpenCode sign in through the browser as real wiki users, with the OpenID Connect Provider and token authentication.

Steps

What a signed-in agent may read and write is bounded by its user's rights (see MCP User Permissions). Until this is set up, an unauthenticated caller is refused with HTTP 401 unless the wiki allows guest access, in which case the caller is served as the guest user with read tools only, and a client must be given credentials itself.

  1. Install the OpenID Connect Provider extension.
  2. Open "Users & Rights > OpenID Connect" in the wiki's administration and set the clients to "Dynamic mode", or keep "Static mode" and register each client.

    The Clients part of the OpenID Connect administration section, with the Dynamic mode option highlighted and selected

  3. Open "Users & Rights > Authentication" and set the authenticator to "Token based authenticator" (see "Select the Authenticator").

    The Authentication service administration section, with Token based authenticator highlighted in the list of authentication services

    LLM 1.0.1+ Until you do, the endpoint does not advertise the OIDC Provider, so agents get a plain HTTP 401 and cannot sign in, and the MCP administration section shows this warning:

    The MCP Server administration section, with the warning shown while the authenticator is not Token based authenticator highlighted

  4. Set up a fallback authenticator if the wiki still needs its own login form (see the Token Authenticator documentation). To sign users in through your organization's identity provider, follow Use Single Sign-On.
  5. Connect an agent and check that it is sent through the login flow. With guest access off, the first unauthenticated call receives HTTP 401 with a WWW-Authenticate header pointing at this wiki's protected-resource metadata, and the client then opens the consent screen.

    The consent screen the wiki shows the connecting agent, listing what the client is requesting access to, with the Accept button highlighted

FAQ

What happens if I set up no authentication at all?

The endpoint uses whatever authentication XWiki is configured with and does not ask for any of its own. An unauthenticated caller is refused with HTTP 401 unless the wiki allows guest access, and a caller that presents credentials which fail to authenticate is always refused, even with guest access on.

Is the OIDC Provider required?

For the browser sign-in flow on this page, yes. Without it the endpoint answers a bare 401 with no WWW-Authenticate challenge, so the client cannot discover a provider; configure the client with credentials itself instead, for example HTTP Basic, which XWiki's authenticator checks like any other request.

Does guest access replace authentication?

No. With guest access on, a caller that sends no credentials at all is served as the guest user and never sees the login flow. A request that sends credentials which fail is still refused with 401.

Which user is an agent then acting as?

The one it authenticated as, with that account's rights and nothing more, which is why the account you hand to an agent matters: see MCP User Permissions.

How can I see what an agent did?

Every tool call is logged at INFO with the tool, the acting user, the outcome (ok, error, refused or failed) and the duration. The arguments are never logged.

More

To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.

Related

Get Connected