tools/list. A single
tool today (generate_qr_url) is gated behind a scoped OAuth token
because it touches the paid QR-generation pipeline. The pattern is
extensible: future protected tools join the same step-up flow.
Two roles, two endpoints
Closient acts as both authorization server and resource server in this stack:| Role | What it does | Discovery endpoint |
|---|---|---|
| Authorization Server | Issues and validates OAuth tokens, hosts the consent screen, manages refresh. | /.well-known/oauth-authorization-server |
| Resource Server (MCP) | Validates the bearer token, enforces scopes, dispatches the tool call. | /.well-known/oauth-protected-resource |
Public tools — no token
These tools accept anonymous calls. No header, no setup:pingvalidate_gtinresolve_gtinlookup_productsearch_productsget_product_detailcompare_productscheck_availability
Protected tools — step-up flow
generate_qr_url requires a bearer token with the qr:generate
scope. The step-up flow is what makes the user experience smooth:
the client doesn’t have to authenticate up front, only when it
actually tries to use a protected tool.
Step by step:
-
First call without a token. The MCP client calls the tool
anonymously. Closient returns
403 Forbiddenwith this header: -
Client reads
resource_metadataand fetches the protected resource metadata document to learn the authorization server URL and supported scopes. - Authorization flow. The client opens the consent screen in the user’s browser (using PKCE per the OAuth 2.1 spec), the user approves, and the client exchanges the authorization code for an access token + refresh token.
-
Retry with the token. The client retries
tools/call generate_qr_urlwithAuthorization: Bearer <token>. Closient validates the token, confirms theqr:generatescope, and dispatches the call.
Scopes
Closient currently exposes one MCP-specific scope. Future protected tools will register additional scopes following the samedomain:action
convention.
| Scope | Required for | Description |
|---|---|---|
qr:generate | generate_qr_url | Generate GS1 Digital Link URLs for QR/Data Matrix encoding. Counts against the user’s QR quota. |
accounts:read, products:read, etc.) are
independent of MCP. They authenticate REST-API calls; they do not
unlock additional MCP tools.
Token lifetimes
| Token | Lifetime |
|---|---|
| Access token | 24 hours |
| Refresh token | 90 days |
Client registration
The MCP spec (Nov 2025 revision) supports three registration paths. All work against Closient:- Client ID Metadata Documents (CIMD) — preferred. The client advertises its metadata at a public URL; Closient fetches it on first contact. No upfront registration required.
- Dynamic Client Registration (RFC 7591) — the client
POSTs to the authorization server’s/registerendpoint and receives aclient_id+client_secret. Useful for clients that want a stable identity but don’t have a public metadata URL. - Pre-registration — for known clients like Claude Desktop and
VS Code, Closient maintains pre-registered application records.
No action on your part; the client uses its built-in
client_id.
Manual token minting
For local development, scripted integrations, or MCP clients that don’t implement the OAuth flow, you can mint a token by hand:Authorization: Bearer <access_token>.
Verifying scope coverage
A quick way to sanity-check that a token has the right scope before calling a protected tool:qr:generate. A
403 with error="insufficient_scope" means the token is valid
but missing the scope — re-run the consent flow and accept the
qr:generate request.
Audit & identity
Every tool call (public or protected) emits one structuredclosient.mcp.audit log line with the agent’s client_id and (for
authorization_code tokens) the consenting end user. See
MCP Identity Propagation for the full audit
schema and the get_current_end_user() accessor for tool authors.
For protected tools, @user_action on the underlying service-layer
function (e.g. apps.products.services.qr_url.build_digital_link_url)
also records a durable database audit row — the answer to “who
generated this QR code?” is queryable forever from the
audit_events table.
See also
- Install the MCP Server
- Tool Reference
- MCP Error Contract
- MCP Identity Propagation
- Authentication (REST API) — API-key auth for the REST API, independent of MCP OAuth.
- RFC 9728 — OAuth 2.0 Protected Resource Metadata
- MCP Authorization spec (draft)