Skip to content
Latest (currently 2026.11.0) has the newest features, bug fixes, and CVE patches of Solo Enterprise for agentgateway.

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Set up downstream-only login

Page as Markdown

Front an MCP server with the gateway’s OAuth issuer so users authenticate with the downstream IdP only.

Use downstream-only login to require users to sign in through your identity provider (IdP) when an MCP client connects to the gateway. The gateway validates the user’s token and forwards the request to the MCP server. The backend does not require a per-user upstream OAuth credential.

This example uses the Everything MCP resource created by brokered setup. Sign in through Keycloak at connection time, then call the Echo tool.

Before you begin

  1. Complete Set up brokered elicitation. Reuse its running STS, Keycloak, OAuth issuer, and Everything MCP resource. Keep GATEWAY_URL exported.
  2. Install Node.js 22.19 or later to run MCP Inspector locally.
  3. Make sure that local ports 6274 and 6275 are available. Keep the gateway port-forward running if you selected that connection method.

Step 1: Review the downstream-only resource

Brokered setup creates the Everything backend as an EnterpriseAgentgatewayBackend, and creates its route. The sample already selects downstream-only login, so you can continue without changing the resources. The backend has no upstream OAuth elicitation mapping or backend token exchange policy. The issuer therefore completes this resource’s flow after downstream login. For the complete resource and route example, see Register the MCP resource.

Review the authentication settings under the spec.policies.mcp section.

spec:
  policies:
    mcp:
      authentication:
        mode: Strict
        issuer: "${KEYCLOAK_ISSUER}"
        audiences: [agw-issuer]
        jwks:
          backendRef:
            group: agentgateway.dev
            kind: AgentgatewayBackend
            name: keycloak-jwks
          cacheDuration: 5m
          jwksPath: /realms/downstream-mcp/protocol/openid-connect/certs
        resourceMetadata:
          agentgateway.dev/issuer-proxy: "http://enterprise-agentgateway.agentgateway-system.svc.cluster.local:7777/oauth-issuer"
          resource: "${GATEWAY_URL}/mcp"
          authorizationServers: ["${GATEWAY_URL}/mcp"]
SettingPurpose
authentication.modeRequires a Keycloak token for MCP requests.
issuer, audiences, and jwksValidate the token issuer, audience, and signature against the Keycloak realm from setup.
resourceMetadata.agentgateway.dev/issuer-proxyRegisters the resource for the brokered issuer. The issuer reads this value from an EnterpriseAgentgatewayBackend or an EnterpriseAgentgatewayPolicy (not the upstream AgentgatewayBackend or AgentgatewayPolicy APIs). To register multiple backends with the same brokered issuer, use an EnterpriseAgentgatewayPolicy that targets the backends.
resource and authorizationServersIdentify the public MCP URL, including its path and any non-default port.

Step 2: Check authentication discovery

Before signing in, check that the gateway rejects an unauthenticated request and advertises its OAuth issuer. These checks diagnose routing and authentication configuration; browser login in the next step completes the brokered flow.

  1. Send a request without a bearer token.

    curl -i "${GATEWAY_URL}/mcp"

    Expect 401 Unauthorized with a WWW-Authenticate header pointing to ${GATEWAY_URL}/.well-known/oauth-protected-resource/mcp.

  2. Read the protected resource metadata.

    curl -fsS "${GATEWAY_URL}/.well-known/oauth-protected-resource/mcp" | jq '{resource, authorization_servers}'

    Both values must identify ${GATEWAY_URL}/mcp. For the local port-forward example:

    {
      "resource": "http://localhost:3000/mcp",
      "authorization_servers": ["http://localhost:3000/mcp"]
    }
  3. Read the authorization server metadata.

    curl -fsS "${GATEWAY_URL}/.well-known/oauth-authorization-server/mcp" | jq '{issuer, authorization_endpoint, token_endpoint, registration_endpoint}'

    The issuer must identify ${GATEWAY_URL}/mcp. The endpoint URLs use ${GATEWAY_URL}/oauth-issuer. For the local port-forward example:

    {
      "issuer": "http://localhost:3000/mcp",
      "authorization_endpoint": "http://localhost:3000/oauth-issuer/authorize",
      "token_endpoint": "http://localhost:3000/oauth-issuer/token",
      "registration_endpoint": "http://localhost:3000/oauth-issuer/register"
    }

Step 3: Sign in and call a tool

For the local port-forward, use the Inspector URL shown in the following steps. For a LoadBalancer, use your public MCP URL in the Inspector’s URL field:

echo "${GATEWAY_URL}/mcp"

Connect through MCP Inspector to complete the browser login and call the backend. These steps use MCP Inspector 2.9.0.

  1. In a separate terminal, start the Inspector.

    npx -y @modelcontextprotocol/inspector@2.9.0
  2. Open http://localhost:6274 or the http://127.0.0.1:6274 URL from the startup output. The example allows callbacks to either address.

  3. Click Add Servers > Add manually.

    MCP Inspector with the Add Servers menu open and the Add manually option selected.
    MCP Inspector with the Add Servers menu open and the Add manually option selected.

    Enter the following values and click Add.

    FieldValue
    Server IDdownstream-mcp
    Transportstreamable-http
    URLhttp://localhost:3000/mcp
  4. Turn on the connection switch for downstream-mcp. The browser redirects to Keycloak. Sign in as alice with password alice-password.

    If the gateway returns redirect_uri is not allowed, compare the request’s redirect_uri with the callback allowlist in brokered setup. For example, a 127.0.0.1 callback does not match a localhost entry. Add the missing callback URI, restart STS (or upgrade the controller Helm values in Kubernetes mode), and start a new connection from the Inspector.

  5. Verify that the browser returns to the Inspector and the server status changes to Connected. The flow completes after the Keycloak login, without an upstream provider login or an elicitation consent screen.

    MCP Inspector showing downstream-mcp connected to http://localhost:3000/mcp with the connection switch on.
    MCP Inspector showing downstream-mcp connected to http://localhost:3000/mcp with the connection switch on.
  6. Open Tools, select Echo Tool, and enter Hello from downstream-only login in the message field. Click Execute Tool.

    Expected result:

    Echo: Hello from downstream-only login
    

    The STS log also confirms the selected flow:

    "msg":"downstream callback processed, completing downstream-only flow"
    

Optional backend authentication

A backend that requires a shared service credential can still use downstream-only login. Configure API key backend authentication on that backend. The Everything MCP server in this example needs no credential.

If your backend is an HTTP API, follow OpenAPI to MCP to expose its operations as tools. OpenAPI conversion is independent of the downstream login flow.

Clean up

Disconnect and remove downstream-mcp in the Inspector, then stop the Inspector with Ctrl+C. Keep the sample MCP resource, shared issuer, and IdP while another brokered guide uses them. Otherwise, clean up the shared infrastructure.