MCP
OAuth endpoints for MCP clients.
This page documents the current Ruby port behavior. Ruby uses snake_case option names and auth.api method names; HTTP paths and JSON keys keep the upstream wire shape where implemented.
Some UI or provider-specific setup from upstream is app-provided in Ruby. The protocol endpoints below are implemented, but you must supply your own pages, callbacks, client objects, or provider metadata where noted by the option names.
Configure
require "better_auth"
auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
plugins: [
BetterAuth::Plugins.mcp(resource: "https://api.example.com/mcp", login_page: "/login")
]
)Usage
server = auth.api.get_mcp_o_auth_config
resource = auth.api.get_mcp_protected_resource
token = auth.api.mcp_o_auth_token(
body: {
grant_type: "authorization_code",
code: params[:code],
client_id: client_id
}
)Routes
| Method | Path | Ruby API method |
|---|---|---|
GET | /.well-known/oauth-authorization-server | auth.api.get_mcp_o_auth_config |
GET | /.well-known/oauth-protected-resource | auth.api.get_mcp_protected_resource |
POST | /mcp/register | auth.api.mcp_register |
GET | /mcp/authorize | auth.api.mcp_o_auth_authorize |
POST | /mcp/token | auth.api.mcp_o_auth_token |
GET | /mcp/userinfo | auth.api.mcp_o_auth_user_info |
Options
Current Ruby options accepted by BetterAuth::Plugins.mcp:
scopesoidc_configresourcelogin_pagestore
Support Notes
- The examples above are based on Ruby plugin source and tests in
packages/better_auth. - If an upstream section is not represented here, treat it as not yet documented or not yet supported by the Ruby port until the matching Ruby implementation exists.