discourse/plugins/discourse-ai/lib/mcp
Sam cbb63ef66a
FEATURE: Add advanced OAuth options for MCP servers (#38913)
Adds three new configurable fields to MCP server OAuth:

- `oauth_authorization_params` — JSON object merged into authorization
  requests (e.g. `{"access_type":"offline"}` for Google APIs)
- `oauth_token_params` — JSON object merged into token exchange and
  refresh requests (e.g. `{"audience":"..."}` for resource indicators)
- `oauth_require_refresh_token` — fails OAuth if the provider does not
  return a refresh token, surfacing misconfiguration early

The OAuth flow is also improved in several ways:

- Reads `token_endpoint_auth_methods_supported` from discovery metadata
  and negotiates the correct client authentication method
  (client_secret_basic, client_secret_post, or none)
- Validates client registration requirements before starting the flow,
  giving actionable error messages when dynamic registration is
  unavailable
- Null values in custom params remove default parameters, allowing
  overrides like removing the `resource` indicator

Additionally, the MCP client now passes through tool result errors
(isError: true) instead of raising exceptions, so the AI can see
and reason about tool-level failures.
2026-04-01 08:47:23 +11:00
..
client.rb FEATURE: Add advanced OAuth options for MCP servers (#38913) 2026-04-01 08:47:23 +11:00
oauth_client_registration.rb
oauth_discovery.rb FEATURE: Add advanced OAuth options for MCP servers (#38913) 2026-04-01 08:47:23 +11:00
oauth_flow.rb FEATURE: Add advanced OAuth options for MCP servers (#38913) 2026-04-01 08:47:23 +11:00
oauth_token_store.rb
tool_registry.rb