Class: Mcp::OauthMetadataController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/mcp/oauth_metadata_controller.rb

Instance Method Summary collapse

Instance Method Details

#protected_resourceObject

RFC 9728 - OAuth 2.0 Protected Resource Metadata
Claude Desktop fetches this to discover which authorization server
protects this MCP resource.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/mcp/oauth_metadata_controller.rb', line 47

def protected_resource
  base_url = "#{request.protocol}#{request.host_with_port}"

   = {
    resource: base_url,
    authorization_servers: [base_url],
    bearer_methods_supported: %w[header],
    scopes_supported: %w[mcp]
  }

  render json: 
end

#showObject

RFC 8414 - OAuth 2.0 Authorization Server Metadata



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/mcp/oauth_metadata_controller.rb', line 26

def show
  base_url = "#{request.protocol}#{request.host_with_port}"

   = {
    issuer: base_url,
    authorization_endpoint: "#{base_url}/oauth/authorize",
    token_endpoint: "#{base_url}/oauth/token",
    revocation_endpoint: "#{base_url}/oauth/revoke",
    response_types_supported: %w[code],
    grant_types_supported: %w[authorization_code],
    code_challenge_methods_supported: %w[S256],
    token_endpoint_auth_methods_supported: %w[none client_secret_basic client_secret_post],
    scopes_supported: %w[mcp]
  }

  render json: 
end