Ejento AI
GuidesQuickstart
RecipesREST APIsRelease NotesFAQs
GuidesQuickstart
RecipesREST APIsRelease NotesFAQs
Ejento AI
  1. MCP Servers
  • How to Setup Ejento on Azure
  • Prerequisites
  • Deployment on Azure
  • Setup After Deployment
    • Custom Domain Set Up
    • Microsoft SSO Authentication
    • Okta SSO Authentication
    • SharePoint Connection Set Up
    • Developer API Set Up
    • Azure AI Search Indexer
  • MCP Servers
    • Slack
    • Jira
    • Azure
    • Snowflake
    • Azure Cosmos DB
  • Overview
    • Azure Resources
GuidesQuickstart
RecipesREST APIsRelease NotesFAQs
GuidesQuickstart
RecipesREST APIsRelease NotesFAQs
Ejento AI
  1. MCP Servers

Azure Cosmos DB

References: GitHub Repo · Official Docs

What is the MCP Toolkit?#

The Azure Cosmos DB MCP Toolkit is a purpose-built MCP server that lets AI agents query, filter, and semantically search Cosmos DB using natural language — deployed as a containerised Azure Container App with managed identity and optional Entra ID authentication.

Why use this over the Azure MCP Server?#

Microsoft's generic Azure MCP Server covers broad Azure services but has significant gaps when it comes to Cosmos DB:
CapabilityAzure MCP ServerCosmos DB MCP Toolkit
Vector / semantic searchNot supportedNative — uses Azure OpenAI embeddings
FocusBroad Azure surfacePurpose-built for Cosmos DB
DeploymentLocal / stdio onlyAzure Container App with managed identity
AuthenticationCLI credential passthroughManaged identity + Entra ID SSO
The biggest differentiator is vector search — the Toolkit vectorizes a user's query at runtime using Azure OpenAI and runs a cosine-similarity search across your container. The Azure MCP Server has no equivalent capability.

Prerequisites#

Azure subscription (Contributor or Owner)
Azure Container Registry (ACR) — external, not provisioned by the template
Azure Cosmos DB for NoSQL account
Azure OpenAI resource with an embedding model deployed (e.g. text-embedding-3-small)
Azure CLI (az login authenticated)
Docker Desktop
Cloned repo: git clone https://github.com/AzureCosmosDB/MCPToolKit.git

1. Deploy Infrastructure#

The repo includes a Bicep template that provisions:
ResourceType
mcp-toolkit-app-identityUser-assigned Managed Identity
mcp-toolkit-envContainer Apps Environment
mcp-toolkit-appContainer App
The ACR is not included — you'll connect yours in Step 4.
Required parameters:
ParameterDescriptionExample
cosmosEndpointCosmos DB endpointhttps://<account>.documents.azure.com:443/
aifProjectEndpointAzure OpenAI endpointhttps://<resource>.openai.azure.com/
embeddingDeploymentNameEmbedding model nametext-embedding-3-small
embeddingDimensionsDimension size (0 for ada-002)1536
After deployment, save these outputs — you'll need them later:
managedIdentityPrincipalId
managedIdentityClientId
containerAppUrl

2. Build & Push the Docker Image#

From the repo root, authenticate to your ACR and push the image:

3. Assign Roles to the Managed Identity#

The user-assigned identity needs permissions on three resources.
Important: The Container App has two identities — a user-assigned (mcp-toolkit-app-identity) and a system-assigned one Azure creates automatically. Always assign roles to the user-assigned identity. Since AZURE_CLIENT_ID points to the user-assigned identity, DefaultAzureCredential ignores the system-assigned one entirely — roles on it have no effect.
First, retrieve the identity IDs:

3A — Cosmos DB: Control Plane (optional)#

Portal: Cosmos DB → Access control (IAM) → Add role assignment → Cosmos DB Account Reader → mcp-toolkit-app-identity

3B — Cosmos DB: Data Plane (required)#

The portal IAM blade is control-plane only. Without this step you'll get 403 readMetadata errors even if 3B is done. Data-plane roles are invisible in the portal — use the CLI.
Verify:
Role propagation can take 1–2 minutes.

3C — Azure OpenAI: Cognitive Services User#

Portal: Azure OpenAI → Access control (IAM) → Add role assignment → Cognitive Services User → mcp-toolkit-app-identity

4. Configure the Container App#

Open mcp-toolkit-app in the Azure Portal.

Registry#

In the Container App, set the image source to Azure Container Registry and authentication to Secrets — Azure will automatically retrieve the ACR username and password.
FieldValue
Image sourceAzure Container Registry
AuthenticationSecrets
Registry<acr-name>.azurecr.io
Imagecosmos-mcp
Image taglatest

Environment Variables#

NameValue
COSMOS_ENDPOINThttps://<cosmos-account>.documents.azure.com:443/
OPENAI_ENDPOINThttps://<openai-resource>.openai.azure.com/
OPENAI_EMBEDDING_DEPLOYMENTYour embedding model name
OPENAI_EMBEDDING_DIMENSIONS0 for ada-002, or model dimension (e.g. 1536)
ASPNETCORE_ENVIRONMENTProduction
ASPNETCORE_URLShttp://+:8080
AZURE_CLIENT_IDManaged identity client ID ← see note below
AzureAd__TenantIdEntra app registration tenant ID
AzureAd__AudienceEntra app registration client ID
AzureAd__ClientIdEntra app registration client ID
AZURE_CLIENT_ID = the managed identity's client ID (from az identity show --query clientId).
AzureAd__ClientId = the Entra app registration client ID.
These are different objects — mixing them up causes auth failures.
After saving, create a new revision to apply changes.

5. Entra ID App Registration#

Step 1 — Authentication & Redirect URIs#

1.
Entra ID → App registrations → open your app registration
2.
Authentication → Add a platform
3.
Add redirect URIs:
https://<container-app-url>/ → Single-page application
https://<container-app-url>/signin-oidc → Single-page application
https://<apim-ejento-url>/auth-service/api/v2/mcp-sso/azure/callback
4.
Leave implicit grant flows unchecked
5.
Save
application1.png

Step 2 — Expose an API#

1.
Expose an API → Add Application ID URI: api://<client-id>
2.
Add a scope:
FieldValue
Scope nameaccess_as_user
Who can consentAdmins only
Admin consent display nameAccess Azure Cosmos DB MCP Toolkit API as user
Admin consent descriptionAllows the app to access the API on behalf of the signed-in user
StateEnabled
3.
Under Authorized client applications, add the app registration's own Client ID
exposeapi.png

Step 3 — Create the App Role#

App roles → Create app role:
FieldValue
Display nameMCP Tool Executor
Allowed member typesUsers/Groups
ValueMcp.Tool.Executor
DescriptionGrants permission to execute MCP tools
Enable✅
The MCP server checks for the exact value Mcp.Tool.Executor — it must match exactly.
approles.png

Step 4 — API Permissions#

1.
API permissions → Add a permission → My APIs → select this app
2.
Delegated → access_as_user → Add
3.
Add Microsoft Graph → Delegated → User.Read
4.
Grant admin consent
apipermissions.png

Step 5 — Container App Env Vars#

Add these and create a new revision:
NameValue
AzureAd__TenantId<tenant-id>
AzureAd__ClientId<app-registration-client-id>
AzureAd__Audience<client-id> or api://<client-id>

Step 6 — Assign Users#

Enterprise Applications → find your app → Users and groups → assign users to the MCP Tool Executor role.
enterprise1.jpg
enterprise2.jpg
From the App Registration Overview, record:
Application (Client) ID
Directory (Tenant) ID
overview.png

6. Enable CORS (if using the test UI)#


7. Verify#

CheckHow
HealthGET https://<container-app-url>/health → should return healthy
Test UIOpen https://<container-app-url>/ in a browser
MCP endpointPOST /mcp with a bearer token
Get a test token:

Checklist#

#StepNotes
1Deploy Bicep templateCreates identity, env, container app
2Build & push imageTo your ACR
3aCosmos: Account ReaderOptional, portal IAM
3bCosmos: Data-plane RBACRequired — CLI only. Role 00000000-0000-0000-0000-000000000001, scope /
3cOpenAI: Cognitive Services UserPortal IAM
4Container App configRegistry (Secrets auth) + env vars + new revision
5Entra ID authOptional — SPA platform, redirect URIs, app role, permissions, user assignment
6CORS--allowed-origins "*"
7Test/health healthy, test UI loads, MCP endpoint accepts token

Troubleshooting#

403 readMetadata (Substatus 5301)
→ Missing data-plane RBAC. Run the CLI command in Step 3C. Portal IAM alone is not enough.
403 errors after assigning roles
→ Roles were assigned to the system-assigned identity. Re-run all assignments targeting the user-assigned identity's principal ID.
Container won't start / image pull error
→ Confirm the ACR admin user is enabled (ACR → Access keys) and the Container App registry is set to Secrets auth. Create a new revision after any changes.
AADSTS50011 — redirect URI mismatch
→ Confirm the redirect URI in the App Registration exactly matches the Container App URL, and is listed under Single-page application (not Web).
DefaultAzureCredential failure
→ AZURE_CLIENT_ID is wrong or missing. Retrieve it: az identity show --query clientId and set it in the Container App env vars, then create a new revision.
Previous
Snowflake
Next
Azure Resources