Available in🇮🇳 India
The Razorpay MCP Server uses OAuth 2.0 to authenticate MCP clients securely. OAuth provides enhanced security compared to using secret keys directly, as it enables granular permissions and user-based authorisation.
Benefits
Benefits
- Enhanced Security: No need to share API secret keys directly.
- Granular Permissions: Control access at a more detailed level.
- User-Based Authorisation: Individual user consent and access management.
- Token Expiration: Temporary access tokens that can be refreshed or revoked.
Client Registration Methods
Razorpay MCP Server supports two methods for registering OAuth clients:Dynamic Client Registration (DCR)
Dynamic Client Registration (DCR)
Your application registers itself programmatically by calling the
/register endpoint. This is the recommended approach for MCP clients.How it worksDCR allows MCP clients to register themselves programmatically with the Razorpay authorisation server, instead of requiring manual creation of client credentials.When a client sends a registration request to the /register endpoint, the authorisation server creates a new client with a unique client_id and client_secret.Manual Registration
Manual Registration
Write to the Razorpay Support Team to generate a Client id and secret manually.
OAuth Flow
The Razorpay MCP Server implements the OAuth 2.0 Authorisation Code flow. Here is how the integration works:- Discover Endpoints: Retrieve OAuth endpoints from the well-known configuration.
- Register Client: Register your application using Dynamic Client Registration.
- Request Authorisation: Direct users to the authorisation endpoint.
- Receive Authorisation Code: Handle the callback with the temporary code.
- Exchange for Access Token: Trade the authorisation code for an access token.
- Access MCP Tools: Use the access token to call Razorpay MCP Server tools.
Integration Steps
Step 1: Discover OAuth Endpoints
Step 1: Discover OAuth Endpoints
Before starting the OAuth flow, retrieve the available endpoints and supported configurations using the well-known endpoint.
GET https://mcp.razorpay.com/.well-known/oauth-authorization-serverResponse Parameters
Response Parameters
issuer
: string The OAuth 2.0 issuer identifier.authorization_endpoint
: string The URL for requesting user authorisation.token_endpoint
: string The URL for exchanging authorisation codes for tokens.registration_endpoint
: string The URL for Dynamic Client Registration. MCP clients use this endpoint to register programmatically and obtain client credentials.scopes_supported
: array List of available OAuth scopes.response_types_supported
: array Supported OAuth response types.grant_types_supported
: array Supported OAuth grant types.token_endpoint_auth_methods_supported
: array Supported methods for authenticating at the token endpoint. For example, client_secret_post indicates that the client secret is sent in the request body.code_challenge_methods_supported
: array PKCE (Proof Key for Code Exchange) challenge methods. S256 indicates SHA-256.Step 2: Register Your Client
Step 2: Register Your Client
Register your application to obtain a Client id and secret. You can use either of the following methods:
- Dynamic Client Registration (Recommended): Your application registers itself programmatically by sending a
POSTrequest to the/registerendpoint. - Manual Registration: Write to the Razorpay Support Team to generate client credentials.
Dynamic Client Registration
Send aPOST request to the registration endpoint with your client details.POST https://mcp.razorpay.com/registerRequest Parameters
Request Parameters
client_name mandatory
: string A human-readable name for your client application.redirect_uris mandatory
: array List of redirect URIs to which the authorisation server redirects the user after an authorisation grant. These must exactly match the redirect_uri parameter used in authorisation requests.grant_types mandatory
: array OAuth 2.0 grant types the client will use. Supported values: authorization_code, refresh_token.response_types mandatory
: array OAuth 2.0 response types the client will use. Use code for the authorisation code flow.scope optional
: string Requested OAuth scopes. For example, read_only.token_endpoint_auth_method optional
: string Authentication method for the token endpoint. Use none for public clients.client_uri optional
: string URL of the client application’s home page.Response Parameters
Response Parameters
client_id
: string Unique identifier assigned to your client. Use this in authorisation and token requests.client_secret
: string Secret key for your client. Store this securely and use it when exchanging authorisation codes for tokens.client_id_issued_at
: integer Unix timestamp indicating when the client credentials were issued.client_name
: string The registered name of your client application.redirect_uris
: array The registered redirect URIs for your client.grant_types
: array The grant types your client is authorised to use.response_types
: array The response types your client is authorised to use.token_endpoint_auth_method
: string The authentication method assigned for the token endpoint. For example, client_secret_post.application_type
: string The type of client created. For example, public.scope
: string The scopes granted to your client.application_id
: string Unique identifier for the application associated with the client.Step 6: Use Access Token to Call MCP Tools
Step 6: Use Access Token to Call MCP Tools
Include the access token in the Authorisation header when making requests to Razorpay MCP Server tools.
GET https://mcp.razorpay.com/api/tool-endpointToken Management
Token Expiration
Token Expiration
Access tokens expire after a set period. Monitor the
expires_in value and implement token refresh logic in your application.Token Storage
Token Storage
Store access tokens securely:
- Never commit tokens to version control.
- Use environment variables or secure vaults.
- Encrypt tokens at rest.
- Clear tokens from memory after use.
Token Revocation
Token Revocation
If you need to revoke a token before expiration, contact Razorpay Support team or implement token management in your application settings.