Existing tables

laravel-rust-mcp-oauth Alpha Laravel for Rust

If another implementation of the same MCP resource already issues tokens, share its tables to keep assistants connected while you move over.

The tables

With the default prefix mcp_:

TableHolds
mcp_oauth_clientsEvery client: its ID, how it registered (cimd or dcr), name, callbacks, family, when its document was fetched
mcp_grantsA person's permission for an app and scope set, with last use and revocation timestamps
mcp_authorization_requestsPending approvals
mcp_authorization_codesCodes, as SHA-256 digests, with their callback, challenge, resource and scopes
mcp_tokensAccess and refresh tokens, as SHA-256 digests, with their expiry, rotation and revocation

The exact columns are in the crate's database/migrations/. They stay stable within a minor version.

Sharing them

One set of tables serves exactly one MCP resource. Applications with different resources must use different table_prefix values. Sharing tables is for two implementations of the same resource.

Point the crate at the tables and let the other implementation keep owning the schema.

MCP_OAUTH_MIGRATIONS=false
MCP_OAUTH_SCHEDULE_PRUNE=false
MCP_OAUTH_TABLE_PREFIX=mcp_
MCP_OAUTH_TOKEN_PREFIX=acme_
MCP_OAUTH_CLIENT_ID_PREFIX=acme_c_
MCP_OAUTH_SCOPES=acme
McpOAuthServiceProvider::<model::Users<User>>::new()
    .with_integer_user_ids() // when the grants table's user column is an integer

Then both directions work:

  • tokens the other application issued verify and refresh here;
  • tokens this crate issues are stored the same way: hex digests, replaced_by_id, rotated_at and revoked_at. So the other application can verify them too, and you can switch back.

The other application must follow the same rules for the rows to mean the same thing: SHA-256 hex digests of the full token, refresh rotation with the same grace window, and a revoked grant ending all its tokens.

Shared grants use their stored analytics family. When issuing grants in either application, derive that label from a known CIMD client ID or the selected known callback, and use other when neither is available.

String account IDs and public client IDs must compare byte for byte, including trailing spaces. The bundled migrations use utf8mb4_0900_bin on MySQL and utf8mb4_nopad_bin on MariaDB. If you own the tables, use equivalent collations. Use mariadb:// to select the MariaDB dialect.

The metadata store uses metadata_fetched_at as a cache version. Use the same timestamp precision as the database connection. A row with an empty callback list represents an invalidated document.

Moving over

  1. Run both against the same tables, with this crate's migrations and schedule off.
  2. Move the discovery documents and OAuth endpoints, then the MCP route.
  3. Once nothing uses the old application, turn the schedule on here and let this crate own the migrations.