Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/toolchest/oauth/routes.rb

Instance Method Summary collapse

Instance Method Details

#toolchest_oauth(default_mount: nil) ⇒ Object

Mount well-known OAuth discovery routes at the app root. MCP clients discover OAuth endpoints via these paths.

mount Toolchest::Engine => "/mcp"
toolchest_oauth

For multi-mount, call once — the (/*rest) suffix lets the MetadataController return the correct endpoints per mount:

/.well-known/oauth-authorization-server/mcp       → /mcp mount
/.well-known/oauth-authorization-server/admin-mcp → /admin-mcp mount


15
16
17
18
19
20
21
22
# File 'lib/toolchest/oauth/routes.rb', line 15

def toolchest_oauth(default_mount: nil)
  Toolchest.default_oauth_mount = default_mount.to_sym if default_mount

  get "/.well-known/oauth-authorization-server(/*rest)",
    to: "toolchest/oauth/metadata#authorization_server"
  get "/.well-known/oauth-protected-resource(/*rest)",
    to: "toolchest/oauth/metadata#protected_resource"
end