Search

Connectors

Contact support

Helpdesk portal

Build a custom MCP Server on Peliqan with Microsoft Azure Entra oAuth

If you want to enforce permissions per user in your custom MCP Server, you have to use oAuth. This can be done for example by using SSO (single sign on) with Microsoft Azure (Entra ID). If you want to build a custom MCP Server without oAuth (using an API key instead), click here.

Contents

How to build a Custom MCP Server on Peliqan with oAuth and SSO to Azure

Use the following script template:

Click to expand script

Update the settings in this Python script:

  • Your Microsoft Azure tenant id
  • Your Peliqan account id
  • Add user mappings: the key is the Azure username, the value is the personal API key of the user in Peliqan (see User Settings > API keys)

Add two API endpoints and link them both to the above API handler script:

  • POST /mcp
  • GET /mcp/*/*

Set both endpoints to “public”:

image
image

App registration in Azure

You need to create two apps in Azure under App registrations:

1. App registration for oAuth authorization flow (with client secret)

  • Client id
  • Client secret
  • Redirect URI
    • Redirect URI for Claude: https://claude.ai/api/mcp/auth_callback
    • Redirect URI for ChatGPT: see ChatGPT Settings > Create app > oAuth > Advanced. For example: https://chatgpt.com/connector/oauth/xxxxxxxxxx
    • Note for ChatGPT: you’ll need to start adding an MCP Server in ChatGPT, and click on Advanced Settings to see the redirect URI from ChatGPT. Once you have it, cancel adding the app in ChatGPT (we’ll complete this step below).

    • Redirect URI for Microsoft Copilot: for example https://global.consent.azure-apim.net/redirect/cr25b-5f...ea2a
    • Note for Copilot: you’ll need to start adding an MCP Server in Copilot (with authentication type oAuth, see details below) and save, in order to see the newly generated redirect URI.

image

2. App registration for the MCP Server resource

  • Set the Application ID URI: for example https://api.eu.peliqan.io/123/mcp (use the exact URL of this MCP Server)
  • Add a scope under "Expose an API", e.g. "peliqan_scope"
  • Add groups claim under “Token configuration” > Add groups claim > All groups
image

Expose an API:

image

Result of adding a scope:

image

Add groups claim:

image

Add the second app in the first app under "API permissions" > “+ Add a permission” > APIs my organization uses > find the second app, check its scope under “Permissions” and click on “Add permissions”:

image

Configure your MCP Server using oAuth in ChatGPT

In ChatGPT click on your account name (bottom left corner), click Settings.

In Settings, go to Apps, and click “Create App”:

image
  • Fill in the URL of your MCP Server URL: https://api.eu.peliqan.io/{your_peliqan_account_id}/mcp
  • Select “oAuth” for Authentication
  • Check the checkbox “I understand”
  • Open Advanced Settings: enter the client id and client secret from your App Registration in Azure (from first app which has a client secret). See example client id 43b1e67a-1424-4104-840d-315f58b631f7 in the screenshot from ChatGPT below.
  • Click on the “Create” button
  • Test your MCP Server: ask ChatGPT “Ask the Peliqan MCP to say hello.”
image

Configure your MCP Server using oAuth in Claude

In Claude, go to Customize > Connectors. Click the “+” icon and select “Add custom connector”.

Enter the URL of your custom MCP Server, expand the “Advanced” section and enter the client_id and client_secret from your Azure app.

image

Configure your MCP Server using oAuth in Microsoft Copilot

In Copilot Studio, add an Agent and add a Tool of type “MCP Server” to the agent.

Select oAuth for the MCP Server authentication type, and enter following details:

  • client_id and client_secret from your first Azure app
  • Authorization URL: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize
  • Token URL template: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
  • Refresh url: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
  • Scopes: https://api.eu.peliqan.io/123/mcp/peliqan_scope openid profile offline_access
  • Note: the first scope is the scope URL from your second Azure app

After saving, copy the redirect URI generated by Copilot and use it in the Azure app registration for the second app (see above).

Add an MCP Server in Copilot Studio:

image

Enter oAuth details for the MCP Server:

image

Publish your agent in Copilot Studio to make it available in Copilot chat. Next, you can access your Agent in Copilot chat and use it to access your MCP Server.

In Copilot, each user will have to add a connection to the Agent (MCP server), by authorizing access (oAuth flow) with their Microsoft account.

Troubleshooting in Copilot Studio

If you don’t have permissions to publish you agent, follow the below steps to allow a user to publish an agent:

Click to expand

If you get an error “A custom connector with display name xxx already exists”, follow the below steps:

Click to expand