You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An azd environment variable is stored by the azd CLI for each environment. It is passed to the "azd up" command and can configure both provisioning options and application settings.
6
+
7
+
When adding new azd environment variables, update these files:
8
+
9
+
1.**infra/main.parameters.json**: Add the new parameter mapping from azd env variable to Bicep parameter
10
+
- Use format `${ENV_VAR_NAME}` for required values
11
+
- Use format `${ENV_VAR_NAME=default}` for optional values with defaults
Copy file name to clipboardExpand all lines: README.md
+113-5Lines changed: 113 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ A demonstration project showcasing Model Context Protocol (MCP) implementations
17
17
-[Deploy to Azure](#deploy-to-azure)
18
18
-[Deploy to Azure with private networking](#deploy-to-azure-with-private-networking)
19
19
-[Deploy to Azure with Keycloak authentication](#deploy-to-azure-with-keycloak-authentication)
20
+
-[Deploy to Azure with Entra OAuth Proxy](#deploy-to-azure-with-entra-oauth-proxy)
20
21
21
22
## Getting started
22
23
@@ -332,35 +333,41 @@ This project supports deploying with OAuth 2.0 authentication using Keycloak as
332
333
333
334
### Deployment steps
334
335
335
-
1. Set the Keycloak admin password (required):
336
+
1. Enable Keycloak authentication:
337
+
338
+
```bash
339
+
azd env set MCP_AUTH_PROVIDER keycloak
340
+
```
341
+
342
+
2. Set the Keycloak admin password (required):
336
343
337
344
```bash
338
345
azd env set KEYCLOAK_ADMIN_PASSWORD "YourSecurePassword123!"
339
346
```
340
347
341
-
2. Optionally customize the realm name (default: `mcp`):
348
+
3. Optionally customize the realm name (default: `mcp`):
342
349
343
350
```bash
344
351
azd env set KEYCLOAK_REALM_NAME "mcp"
345
352
```
346
353
347
-
3. Deploy to Azure:
354
+
4. Deploy to Azure:
348
355
349
356
```bash
350
357
azd up
351
358
```
352
359
353
360
This will create the Azure Container Apps environment, deploy Keycloak with the pre-configured realm, deploy the MCP server with OAuth validation, and configure HTTP route-based routing.
354
361
355
-
4. Verify deployment by checking the outputs:
362
+
5. Verify deployment by checking the outputs:
356
363
357
364
```bash
358
365
azd env get-value MCP_SERVER_URL
359
366
azd env get-value KEYCLOAK_DIRECT_URL
360
367
azd env get-value KEYCLOAK_ADMIN_CONSOLE
361
368
```
362
369
363
-
5. Visit the Keycloak admin console to verify the realm is configured:
370
+
6. Visit the Keycloak admin console to verify the realm is configured:
364
371
365
372
```text
366
373
https://<your-mcproutes-url>/auth/admin
@@ -397,3 +404,104 @@ This project supports deploying with OAuth 2.0 authentication using Keycloak as
397
404
| DCR | Open (anonymous) | Require initial access token | Any client can register without auth |
398
405
399
406
> **Note:** Keycloak must be publicly accessible because its URL is dynamically generated by Azure. Token issuer validation requires a known URL, but the mcproutes URL isn't available until after deployment. Using a custom domain would fix this.
407
+
408
+
---
409
+
410
+
## Deploy to Azure with Entra OAuth Proxy
411
+
412
+
This project supports deploying with Microsoft Entra ID (Azure AD) authentication using FastMCP's built-in Azure OAuth proxy. This is an alternative to Keycloak that uses Microsoft Entra with your Azure tenant for identity management.
413
+
414
+
### What gets deployed with Entra OAuth
415
+
416
+
| Component | Description |
417
+
|-----------|-------------|
418
+
|**Microsoft Entra App Registration**| Created automatically during provisioning with redirect URIs for local development, VS Code, and production |
419
+
|**OAuth-protected MCP Server**| FastMCP with AzureProvider for OAuth authentication |
420
+
|**CosmosDB OAuth Client Storage**| Persists OAuth client registrations across server restarts |
421
+
422
+
### Deployment steps for Entra OAuth
423
+
424
+
1. Enable Entra OAuth proxy:
425
+
426
+
```bash
427
+
azd env set MCP_AUTH_PROVIDER entra_proxy
428
+
```
429
+
430
+
2. Set your tenant ID so that the App Registration is created in the correct tenant:
431
+
432
+
```bash
433
+
azd env set AZURE_TENANT_ID "<your-tenant-id>"
434
+
```
435
+
436
+
3. Deploy to Azure:
437
+
438
+
```bash
439
+
azd up
440
+
```
441
+
442
+
During deployment:
443
+
-**Preprovision hook**: Creates a Microsoft Entra App Registration with a client secret, and stores the credentials in azd environment variables
444
+
-**Postprovision hook**: Updates the App Registration with the deployed server URL as an additional redirect URI
445
+
446
+
4. Verify deployment by checking the outputs:
447
+
448
+
```bash
449
+
azd env get-value MCP_SERVER_URL
450
+
azd env get-value ENTRA_PROXY_AZURE_CLIENT_ID
451
+
```
452
+
453
+
### Environment variables
454
+
455
+
The following environment variables are automatically set by the deployment hooks:
456
+
457
+
| Variable | Description |
458
+
|----------|-------------|
459
+
|`ENTRA_PROXY_AZURE_CLIENT_ID`| The App Registration's client ID |
460
+
|`ENTRA_PROXY_AZURE_CLIENT_SECRET`| The App Registration's client secret |
461
+
462
+
These are then written to `.env` by the postprovision hook for local development.
463
+
464
+
### Testing locally
465
+
466
+
After deployment, you can test locally with OAuth enabled:
467
+
468
+
```bash
469
+
# Run the MCP server
470
+
cd servers && uvicorn auth_mcp:app --host 0.0.0.0 --port 8000
471
+
```
472
+
473
+
The server will use the Entra App Registration for OAuth and CosmosDB for client storage.
474
+
475
+
### Use Entra OAuth MCP server with GitHub Copilot
476
+
477
+
The Entra App Registration includes these redirect URIs for VS Code:
478
+
479
+
-`https://vscode.dev/redirect` (VS Code web)
480
+
-`http://127.0.0.1:{33418-33427}` (VS Code desktop local auth helper, 10 ports)
481
+
482
+
To use the deployed MCP server with GitHub Copilot Chat:
483
+
484
+
1. To avoid conflicts, stop the MCP servers from `mcp.json` and disable the expense MCP servers in GitHub Copilot Chat tools.
485
+
2. Select "MCP: Add Server" from the VS Code Command Palette
486
+
3. Select "HTTP" as the server type
487
+
4. Enter the URL of the MCP server, either from `MCP_SERVER_URL` environment variable or `http://localhost:8000/mcp` if running locally.
488
+
5. If you get an error about "Client ID not found", open the Command Palette, run **"Authentication: Remove Dynamic Authentication Providers"**, and select the MCP server URL. This clears any cached OAuth tokens and forces a fresh authentication flow. Then restart the server to prompt the OAuth flow again.
489
+
6. You should see a FastMCP authentication screen open in your browser. Select "Allow access":
0 commit comments