Skip to main content
Let’s connect the MCP server to the identity provider your company already uses, so people sign in with their company login. The server only checks the tokens. Your provider runs the sign-in. In this example the provider’s issuer is https://auth.example.com, the server is https://mcp.example.com/mcp, and the service account is MCPSVC.
Every person’s SQL runs as the DB2i_USER service account. The token says who is calling, but it never reaches the IBM i. Give MCPSVC only the authority that everyone who can sign in may use. To run SQL as each person, use IBM i sign-on instead.

What you need

  • An OAuth 2.1 or OpenID Connect provider that issues JWT access tokens signed with an asymmetric algorithm (RS256, ES256, EdDSA, …).
  • A service account profile on the IBM i.
  • HTTPS in front of the server: a reverse proxy, or the server’s own certificate (MCP_TLS_CERT_FILE, MCP_TLS_KEY_FILE).

Register the server with your provider

In your provider’s admin console:
  • Register an API (resource) with the identifier https://mcp.example.com/mcp, so tokens carry it in their aud claim.
  • Optionally create a scope such as mcp:tools and grant it to the people allowed to use the server.
  • Turn on a client registration method your assistants support: dynamic client registration, or Client ID Metadata Documents.

Find the issuer

The server compares the issuer character for character. Read it from the provider’s metadata:
Copy the value exactly, including any trailing slash.

Configure the server

Create .env:
.env
Behind a proxy, also set MCP_TRUSTED_PROXIES to the proxy’s address. If your provider can’t put the resource URL in aud, set OAUTH_AUDIENCE to the value it uses. Start the server:
The log shows OAuth authentication enabled.

Check it works

Call the server without a token:
You get 401 Unauthorized with a WWW-Authenticate: Bearer … resource_metadata="…" header. That header is what tells assistants where to sign in. Now add https://mcp.example.com/mcp to an assistant. It opens your provider’s sign-in page on first use.

Good to know

  • JWT access tokens only. Opaque tokens and token introspection aren’t supported.
  • One provider per server. Scopes apply to the whole server, not per tool.
  • Clocks must agree. The server allows no clock skew when it checks a token’s expiry.

Next steps

Reference

Every setting and the token rules.

Troubleshooting

Token and startup errors.