Authenticate with the Perk MCP server

Authenticate an AI client with the Perk MCP server using the OAuth 2.0 authorization code flow with PKCE and Dynamic Client Registration (DCR). Covers required scopes, browser sign-in and consent, token lifetime, and how to revoke access.

This article explains how an AI client authenticates with the Perk Model Context Protocol (MCP) server so it can call tools on your behalf. The Perk MCP server uses the OAuth 2.0 authorization code flow with Proof Key for Code Exchange (PKCE), and supports Dynamic Client Registration (DCR), so most clients complete the whole flow with no manual setup.

How authentication works in Perk

The Perk MCP server authenticates AI clients using the OAuth 2.0 authorization code flow with Proof Key for Code Exchange (PKCE). The MCP server acts as an OAuth 2.0 authorization server for AI clients. It publishes discovery metadata, registers clients, and issues and validates access tokens, while Perk's authorization server handles sign-in and consent.

The client drives the flow. You do not build or host any of it yourself. The steps are:

  1. The client discovers the OAuth 2.0 metadata from the server URL you configured.
  2. The client registers itself with the MCP server using Dynamic Client Registration (DCR).
  3. The client starts an authorization code flow with PKCE.
  4. You complete sign-in and consent in the browser using your existing Perk credentials.
  5. The client receives an access token from the MCP server and sends it on each tool call.
sequenceDiagram
    autonumber
    participant You as You (Browser)
    participant Client as AI Client<br/>(Claude, Cursor, Codex, ...)
    participant MCP as Perk MCP Server
    participant AuthServer as Perk Authorization Server
    participant Platform as Perk Platform<br/>(Travel, Spend, Invoice, Events)

    Client->>MCP: Discover OAuth 2.0 metadata
    MCP-->>Client: Authorization, token & registration endpoints
    Client->>MCP: Register client (Dynamic Client Registration)
    MCP-->>Client: Client ID (no manual setup)
    Client->>You: Open browser to sign in and consent<br/>(PKCE code challenge)
    You->>AuthServer: Sign in with Perk credentials
    You->>AuthServer: Approve requested scopes
    AuthServer-->>You: Redirect with authorization code
    You-->>Client: Authorization code
    Client->>MCP: Exchange code + PKCE verifier
    MCP-->>Client: Access token (scoped to your role via RBAC)
    Client->>MCP: Tool call, with access token
    MCP->>AuthServer: Validate token
    AuthServer-->>MCP: Token valid + scopes
    MCP->>Platform: Read/write travel, spend, invoice, event data
    Platform-->>MCP: Data
    MCP-->>Client: Tool result

The access token is scoped to your role and your company's modules through role-based access control (RBAC). A client can only read what you could already access in Perk.

Who does what

Three parties take part in every connection:

  • AI client: Registers with Perk MCP, runs the authorization code flow with PKCE, and presents an access token on each tool call.
  • Perk MCP server: Publishes OAuth 2.0 metadata, registers clients, issues access tokens, validates them on every request, and calls Perk's APIs on your behalf.
  • Perk's authorization server: Authenticates you and shows the consent screen.

Register a client with Dynamic Client Registration

The Perk MCP server supports Dynamic Client Registration (DCR), defined in RFC 7591, so clients register themselves automatically. DCR lets a client obtain its own credentials at connection time instead of using a pre-registered client ID and secret.

Perk MCP handles registration itself, so there are no shared or pre-provisioned client secrets. It accepts a client only when its redirect destinations are on an allowlist, which prevents a malicious client from receiving an authorization code at a destination it controls. Clients that support DCR need no manual client ID or secret. For example, the MCP Inspector connects with the client ID and secret fields left empty, and DCR handles registration.

Complete sign-in and consent in the browser

After a client starts the flow, you complete sign in and consent in the browser. The client opens your browser to the Perk sign-in page, where you authenticate with your existing Perk credentials.

External authorization consent is required. You approve the access the client requests before the client receives an access token. This step ties the token to your identity and to the scopes you approve. Consent is required for every new client connection.

The flow follows the standard OAuth 2.0 authorization code flow with PKCE:

  1. The client sends you to sign in. It includes a PKCE code challenge, so only the client that started the flow can redeem the resulting authorization code.
  2. You sign in with your Perk credentials and approve access on a Perk consent screen.
  3. The client redeems the authorization code with its PKCE verifier and receives an access token.

In-progress sign-in state expires after 15 minutes. If you don't complete sign-in in that time, the client starts again.

Scopes

Scopes control which resources an access token can read. Perk uses colon-separated scope strings, and a client requests the scopes it needs during sign-in. The following scopes are verified for this release.

ScopeWhat it grants
user:readRead user profile and search results. Required.
trip:readRead trips and trip breakdowns. Required.
expenses:readRead the signed-in user's expenses.
report:writeGenerate, poll, and download travel and spend reports.
team-insights-report:writeGenerate, poll, and download travel reports for your team - for line managers, cost object owners, and approvers.
my-travel-policy:readRead the user's travel and spend policy.
trips:writeSearch for and initiate booking of flights, hotels, trains, and cars, and build a checkout link. Checkout itself completes in the Perk web app.
spend:expenses:writeCreate, edit, submit, and approve expenses, and upload and match receipts. One shared scope covers all expense write operations.
events:writeCreate a Perk Event.
trip-approval-links:readGet a link the user can open to approve or decline a specific trip. This is a read scope — it returns a link; the user follows the link, and completes the action in the Perk web app.

Downloading or polling a report — travel or spend — uses report:write, the same scope that generates it. The invoice, event, and card tools need no additional scope; access follows your existing Perk role and permissions. The card and transaction tools also require a Spend subscription.

Perk grants your token only the scopes that match your existing Perk permissions, and removes any scope you aren't entitled to. The scopes a client requests are therefore an upper bound, not a grant.

Per-request validation

On every request, Perk MCP validates the access token against Perk's authorization server before it runs a tool. It then calls Perk's APIs on your behalf, with your permissions. Perk applies the same RBAC and company-level data separation as the Perk web app. A traveler sees only their own data. Admin, reporting, and approval functions need the matching Perk role. The assistant can't access anything you couldn't already access in Perk.

Token lifetime, refresh, and revoke

The OAuth 2.0 client manages token lifetime and refresh for you, renewing the access token as needed without you re-authorizing each time. Access tokens last 1 hour. Perk MCP stores your OAuth tokens and client registration for up to 60 days, and the period restarts each time your client refreshes its access token. If you don't use the connection for an extended period, your client asks you to sign in again.

Token or stateHeld byLifetimeStorage
Access tokenAI client1 hourClient
Stored OAuth tokensPerk MCPUp to 60 days, restarting each time the client refreshes its access tokenEncrypted
Client registrationPerk MCPUp to 60 days, restarting on refreshEncrypted
In-progress sign-in statePerk MCP15 minutesEncrypted

Environments

Connect production clients to the production server URL https://mcp.perk.com/api/mcp/mcp.

📘

Sandbox

A test environment is available. Confirm its base URL with the Perk API team before you point a client at it. OAuth discovery metadata is host-specific, so use the exact server URL you configured — for example, do not swap 127.0.0.1 for localhost or the reverse.

Bear in mind, travel and spend reporting functionality is not available in the sandbox environment.

Next steps


Did this page help you?