Skip to content

VirtualMCPServer ignores scopes field in protected resource metadata (RFC 9728) #4850

Description

@gastoncan

Version: v0.18.0 (operator + vmcp)

Summary: The scopes field in incomingAuth.oidcConfig.inline and incomingAuth.oidcConfigRef is accepted by the CRD and operator but ignored by the vmcp binary. The /.well-known/oauth-protected-resource endpoint always returns scopes_supported: ["openid"] regardless of configuration.

Impact: MCP clients (Claude Code, VS Code) read scopes_supported from the protected resource metadata to build their DCR registration request. When offline_access is not advertised, clients register without it → Keycloak creates the DCR client without offline_access as a valid scope → client auth fails with invalid_scope when requesting openid offline_access.

Steps to reproduce:

  1. Create a VirtualMCPServer with scopes configured:
incomingAuth:
  type: oidc
  oidcConfigRef:
    name: my-oidc-config
    audience: "mcp-gateway"
    scopes:
      - openid
      - offline_access
  1. Check the CR confirms the scopes:
$ kubectl get virtualmcpserver vmcp -n mcp -o json | jq '.spec.incomingAuth.oidcConfigRef.scopes'
["openid", "offline_access"]
  1. Check the discovery endpoint:
$ curl -s https://mcp-gateway.domain/.well-known/oauth-protected-resource | jq .
{
  "resource": "https://mcp-gateway.domain/mcp",
  "authorization_servers": ["https://keycloak.domain/realms/mcp"],
  "bearer_methods_supported": ["header"],
  "scopes_supported": ["openid"]    ← offline_access missing
}
  1. Also tested with incomingAuth.oidcConfig.type: inline and scopes inside the inline block — same result.

CRD documentation confirms the field should work:

scopes:
  description: |-
    Scopes is the list of OAuth scopes to advertise in the well-known endpoint (RFC 9728).
    If empty, defaults to ["openid"].

Expected: scopes_supported: ["openid", "offline_access"]
Actual: scopes_supported: ["openid"]

Environment: Operator v0.18.0, vmcp v0.18.0, Keycloak 26.3.3, Kubernetes 1.31


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

authbugSomething isn't workingkubernetesItems related to KubernetesvmcpVirtual MCP Server related issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions