# Configuration (laravel-rust-mcp-oauth)

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

- Package: laravel-rust-mcp-oauth (Laravel for Rust, alpha), crates: `laravel-rust-mcp-oauth`
- Maintenance: active; Latest release: 0.1.0 (2026-12-05); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-mcp-oauth), [crates.io](https://crates.io/crates/laravel-rust-mcp-oauth/0.1.0), [docs.rs](https://docs.rs/laravel-rust-mcp-oauth/0.1.0), [Changelog](https://oss.bowerbird.si/mcp-oauth/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-mcp-oauth/blob/8b1d066397c9f1a1cf02d444a910a1c65585c159/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-mcp-oauth/blob/8b1d066397c9f1a1cf02d444a910a1c65585c159/SECURITY.md)
- Based on: [Laravel MCP](https://github.com/laravel/mcp): The public flow of Mcp::oauthRoutes(): discovery, client registration, an approval screen in your app and bearer tokens for the MCP server.; [Laravel Passport](https://github.com/laravel/passport): The authorization server Laravel MCP builds on. This crate needs no Passport, supports Client ID Metadata Documents and uses opaque, hashed tokens instead of JWTs.; [MCP authorization specification](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization): The sign-in flow MCP clients expect, with Client ID Metadata Documents preferred over dynamic registration.
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/mcp-oauth/docs/configuration/
- Source: https://github.com/bowerbird-si/laravel-rust-mcp-oauth/blob/8b1d066397c9f1a1cf02d444a910a1c65585c159/docs/configuration.md

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`.

| Setting | Environment variable | Default | What it sets |
| --- | --- | --- | --- |
| `resource_path` | `MCP_OAUTH_RESOURCE_PATH` | `/mcp` | The path of your MCP route. With `APP_URL` it is the resource tokens are issued for |
| `route_prefix` | `MCP_OAUTH_ROUTE_PREFIX` | `/oauth` | Where `register`, `authorize`, `token` and `revoke` live |
| `scopes` | `MCP_OAUTH_SCOPES` | `mcp` | At 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_registration` | `MCP_OAUTH_DCR` | `true` | Dynamic client registration |
| `client_metadata_documents` | `MCP_OAUTH_CIMD` | `true` | Client ID Metadata Documents |
| `access_token_ttl_seconds` | `MCP_OAUTH_ACCESS_TTL` | `3600` | How long an access token works |
| `refresh_token_days` | `MCP_OAUTH_REFRESH_DAYS` | `180` | How long a refresh token works, from issue |
| `refresh_grace_seconds` | `MCP_OAUTH_REFRESH_GRACE` | `120` | The retry window for a refresh whose answer was lost |
| `code_ttl_seconds` | `MCP_OAUTH_CODE_TTL` | `300` | How long an authorization code works |
| `pending_ttl_seconds` | `MCP_OAUTH_PENDING_TTL` | `1800` | How long the approval page waits for a decision |
| `metadata_cache_hours` | `MCP_OAUTH_METADATA_CACHE_HOURS` | `24` | How long a client's metadata document is cached |
| `metadata_max_stale_hours` | `MCP_OAUTH_METADATA_MAX_STALE_HOURS` | `168` | How long cached metadata may stand in during a refresh or after a transient failure |
| `retention_days` | `MCP_OAUTH_RETENTION_DAYS` | `90` | How long revoked grants stay in the connections list |
| `token_prefix` | `MCP_OAUTH_TOKEN_PREFIX` | `mcp_` | Gives `mcp_at_`, `mcp_rt_` and `mcp_ac_` |
| `client_id_prefix` | `MCP_OAUTH_CLIENT_ID_PREFIX` | `mcp_c_` | The start of dynamically registered client IDs |
| `table_prefix` | `MCP_OAUTH_TABLE_PREFIX` | `mcp_` | The start of the five table names. Use a distinct prefix for each resource |
| `migrations` | `MCP_OAUTH_MIGRATIONS` | `true` | Whether the crate's migrations run. Turn off when another application owns the tables |
| `schedule_prune` | `MCP_OAUTH_SCHEDULE_PRUNE` | `true` | Whether `mcp-oauth:prune` runs daily |
| `authorizations_per_hour` | `MCP_OAUTH_AUTHORIZATIONS_PER_HOUR` | `60` | Per address, checked before any metadata document is fetched |
| `registrations_per_hour` | `MCP_OAUTH_REGISTRATIONS_PER_HOUR` | `30` | Per address |
| `tokens_per_minute` | `MCP_OAUTH_TOKENS_PER_MINUTE` | `60` | Per address with independent limits for the token and revocation endpoints |
| `approvals_per_hour` | `MCP_OAUTH_APPROVALS_PER_HOUR` | `10` | Per account |
| `unauthorized_message` | `MCP_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:

| Method | What it does | Page |
| --- | --- | --- |
| `can_approve(f)` | Who may approve a connection | [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/) |
| `can_use(f)` | Whether a user's tokens work right now | [Protecting routes](https://oss.bowerbird.si/mcp-oauth/docs/protecting-routes/) |
| `register_url(url)` | The create-account link for guests | [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/) |
| `user_display(f)` | The name and email the approval page shows | [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/) |
| `scope_label(scope, label)` | What a scope lets the app do | [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/) |
| `protect_name(name)` | A name unreviewed apps may not imitate | [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/) |
| `known_client(client)` | An assistant to show as verified | [Clients](https://oss.bowerbird.si/mcp-oauth/docs/clients/) |
| `on_grant(f)` | Runs after an approval | [Tokens and connections](https://oss.bowerbird.si/mcp-oauth/docs/tokens-and-connections/) |
| `with_integer_user_ids()` | Integer user IDs in tables your application owns | [Existing tables](https://oss.bowerbird.si/mcp-oauth/docs/existing-tables/) |
| `with_documents(fake)` | Serve metadata documents from memory, for tests | [Testing](https://oss.bowerbird.si/mcp-oauth/docs/testing/) |

## 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](https://oss.bowerbird.si/mcp-oauth/docs/existing-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.
