Configuration

laravel-rust-mcp-oauth Alpha Laravel for Rust

Every setting has a default, so a new application needs none of them; this page lists each one with its environment variable.

The settings are the McpOAuthConfig config section. Set them in .env, or change the section in your own provider's config.

SettingEnvironment variableDefaultWhat it sets
resource_pathMCP_OAUTH_RESOURCE_PATH/mcpThe path of your MCP route. With APP_URL it is the resource tokens are issued for
route_prefixMCP_OAUTH_ROUTE_PREFIX/oauthWhere register, authorize, token and revoke live
scopesMCP_OAUTH_SCOPESmcpAt least one space-separated RFC 6749 scope token. The first is the default. An empty environment value uses the framework default. offline_access is always offered
dynamic_registrationMCP_OAUTH_DCRtrueDynamic client registration
client_metadata_documentsMCP_OAUTH_CIMDtrueClient ID Metadata Documents
access_token_ttl_secondsMCP_OAUTH_ACCESS_TTL3600How long an access token works
refresh_token_daysMCP_OAUTH_REFRESH_DAYS180How long a refresh token works, from issue
refresh_grace_secondsMCP_OAUTH_REFRESH_GRACE120The retry window for a refresh whose answer was lost
code_ttl_secondsMCP_OAUTH_CODE_TTL300How long an authorization code works
pending_ttl_secondsMCP_OAUTH_PENDING_TTL1800How long the approval page waits for a decision
metadata_cache_hoursMCP_OAUTH_METADATA_CACHE_HOURS24How long a client's metadata document is cached
metadata_max_stale_hoursMCP_OAUTH_METADATA_MAX_STALE_HOURS168How long cached metadata may stand in during a refresh or after a transient failure
retention_daysMCP_OAUTH_RETENTION_DAYS90How long revoked grants stay in the connections list
token_prefixMCP_OAUTH_TOKEN_PREFIXmcp_Gives mcp_at_, mcp_rt_ and mcp_ac_
client_id_prefixMCP_OAUTH_CLIENT_ID_PREFIXmcp_c_The start of dynamically registered client IDs
table_prefixMCP_OAUTH_TABLE_PREFIXmcp_The start of the five table names. Use a distinct prefix for each resource
migrationsMCP_OAUTH_MIGRATIONStrueWhether the crate's migrations run. Turn off when another application owns the tables
schedule_pruneMCP_OAUTH_SCHEDULE_PRUNEtrueWhether mcp-oauth:prune runs daily
authorizations_per_hourMCP_OAUTH_AUTHORIZATIONS_PER_HOUR60Per address, checked before any metadata document is fetched
registrations_per_hourMCP_OAUTH_REGISTRATIONS_PER_HOUR30Per address
tokens_per_minuteMCP_OAUTH_TOKENS_PER_MINUTE60Per address with independent limits for the token and revocation endpoints
approvals_per_hourMCP_OAUTH_APPROVALS_PER_HOUR10Per account
unauthorized_messageMCP_OAUTH_UNAUTHORIZED_MESSAGE"Connect your account to use this server."The description in the 401

The application refuses to start when a lifetime is zero, a prefix contains characters that aren't safe in tokens or SQL names, or APP_URL isn't HTTPS outside local and testing.

Provider options

Hooks and lists that an environment variable can't hold go on the provider:

MethodWhat it doesPage
can_approve(f)Who may approve a connectionThe approval page
can_use(f)Whether a user's tokens work right nowProtecting routes
register_url(url)The create-account link for guestsThe approval page
user_display(f)The name and email the approval page showsThe approval page
scope_label(scope, label)What a scope lets the app doThe approval page
protect_name(name)A name unreviewed apps may not imitateThe approval page
known_client(client)An assistant to show as verifiedClients
on_grant(f)Runs after an approvalTokens and connections
with_integer_user_ids()Integer user IDs in tables your application ownsExisting tables
with_documents(fake)Serve metadata documents from memory, for testsTesting

One resource per table set

The crate protects the MCP resource at APP_URL plus resource_path. Each set of tables serves exactly one resource. Set a different table_prefix for each application with a different resource. Only implementations of the same resource may share tables.

If you change resource_path under the same prefix, existing tokens keep working. To end those connections, call McpOAuth::revoke_all for each user.