# Clients (laravel-rust-mcp-oauth)

> Assistants identify themselves to your server in one of two ways, and the crate supports both, so the assistants people use today can connect.

- 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/clients/
- Source: https://github.com/bowerbird-si/laravel-rust-mcp-oauth/blob/8b1d066397c9f1a1cf02d444a910a1c65585c159/docs/clients.md

Assistants identify themselves to your server in one of two ways, and the crate supports both, so the assistants people use today can connect.

## Client ID Metadata Documents

The MCP specification's preferred way. The assistant's `client_id` is an HTTPS URL, such as `https://claude.ai/oauth/mcp-oauth-client-metadata`, that serves a JSON document with its name and callbacks. The crate fetches it, checks that the document names the same URL, and caches it for `MCP_OAUTH_METADATA_CACHE_HOURS` (24).

Anyone can start an authorization with any URL, so fetching is locked down:

- HTTPS on port 443 only, without a user name or password in the URL;
- the host must resolve to public addresses only, and the connection goes to an address that was checked, so DNS can't be switched in between;
- local names such as `localhost` and `*.internal` are refused before any lookup;
- no redirects, no proxy, no cookies, a 5-second timeout and at most 10 KB.

When a refresh fails temporarily (a timeout, a connection error or a 5xx), the server can use a cached copy that is still younger than `MCP_OAUTH_METADATA_MAX_STALE_HOURS` (7 days) at the point of fallback. A 4xx, an invalid document or a document that omits a callback registered before the fetch clears all cached callbacks. The server records this even on the first fetch and waits for `MCP_OAUTH_METADATA_CACHE_HOURS` to elapse before it can restore a registration with a successful fetch.

When two successful fetches overlap and one conflicts with the other’s write, the server keeps only callbacks that occur in both documents, using exact string matching and the stored order. It keeps the other stored metadata and starts a new cache period. If the lists share no callbacks, the server records an invalidation marker. An existing marker takes precedence over a fetch that started before the marker was written. A later refresh without a conflict can register new callbacks.

A 15-second cache lock reduces duplicate fetches. If another request holds the lock, the server uses a cached copy within the same stale limit or shows a `temporarily_unavailable` problem page. With the `discard` store, every request that needs a refresh fetches the document. The database enforces the same invalidation rules with any cache store.

Turn it off with `MCP_OAUTH_CIMD=false`.

## Dynamic registration

Clients that don't publish a document register themselves with `POST /oauth/register` (RFC 7591) and get a `client_id` starting with `mcp_c_`. Turn it off with `MCP_OAUTH_DCR=false`; the registration endpoint then disappears from the metadata.

At most `MCP_OAUTH_REGISTRATIONS_PER_HOUR` registrations per address (30).

## Public clients only

Every client is public (`token_endpoint_auth_method: none`) and proves itself with PKCE S256. A registration that asks for another method is answered as `none`.

Some published metadata documents declare `private_key_jwt`; this version doesn't support it. Those assistants connect through dynamic registration instead, as they do with other servers that accept only public clients.

## Callbacks

A callback (`redirect_uri`) must be one of:

- an HTTPS URL;
- `http://127.0.0.1`, `http://[::1]` or `http://localhost`, on any port, for programs on the person's computer;
- a private-use scheme, such as `cursor://anysphere.cursor-retrieval/oauth/callback`.

Refused: `javascript:`, `data:`, `file:` and similar schemes, plain HTTP to other hosts, fragments, user names in the URL, `..` segments, encoded slashes, ports that aren't numbers, and a query that already carries `code`, `state`, `iss` or `error`. A callback must match a registered one exactly; a loopback callback may differ only in its port.

## Known clients

The crate recognises Claude, Claude Code, ChatGPT, Codex, Cursor, VS Code, Gemini CLI and MCP Inspector, and shows them as verified on the approval page when the evidence holds (see [The approval page](https://oss.bowerbird.si/mcp-oauth/docs/approval-page/)). Add your own:

```rust
use laravel_rust_mcp_oauth::KnownClient;

McpOAuthServiceProvider::<model::Users<User>>::new()
    .known_client(KnownClient::cimd("https://assistant.example/oauth/client.json", "Example Assistant"))
    .known_client(
        KnownClient::redirect_based("Other Assistant", "other")
            .redirect("https://other.example/oauth/callback"),
    )
```

Verification requires a selected HTTPS callback tied to a known client. A known registration that uses a loopback or private-use callback appears as a local program and shows the claimed name.

The list `mcp-oauth:clients` prints shows every client that has registered or connected, with its grants and when it was last used.
