[Cosmos] Onboard CosmosService.GetCosmosBaseUri into EndpointValidator.ValidateAzureServiceEndpoint

Open
#4,062 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
azure, csharp
Domain
backend, security

Research direction

Read CosmosService.GetCosmosBaseUri in tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs and the suffix allow lists in core/Microsoft.Mcp.Core/src/Helpers/EndpointValidator.AllowLists.cs. Follow the existing service validation patterns and add tests for valid and invalid Cosmos endpoints across the listed clouds. Done when the endpoint is validated and the tests cover those cases.

Written by the indexing model from the issue text.

Description

needs-team-triage server-Azure.Mcp tools-CosmosDB
Area / Tool

Azure.Mcp.Tools.Cosmos (CosmosService)

Describe the improvement

Most service tools in microsoft/mcp validate constructed data-plane endpoint URIs using AzureService.ValidateAzureServiceEndpoint(endpoint, serviceType) with domain suffixes registered in EndpointValidator.AllowLists.cs (for example, AcrService.CreateValidatedAcrEndpoint, PostgresService, SearchService, StorageService, etc., following microsoft/mcp#3603).

Currently, CosmosService.GetCosmosBaseUri constructs the Cosmos DB endpoint URI (https://{accountName}.documents.azure.com:443/ or its sovereign cloud equivalent) without calling AzureService.ValidateAzureServiceEndpoint, and "cosmos" is not yet included in s_allowedDomainSuffixes in EndpointValidator.AllowLists.cs.

Expected behavior

CosmosService.GetCosmosBaseUri should validate the constructed endpoint URI using AzureService.ValidateAzureServiceEndpoint(endpoint, "cosmos"), consistent with the other service tools in the repository.

Proposed Changes
  1. Add a "cosmos" entry to s_allowedDomainSuffixes in EndpointValidator.AllowLists.cs:
    • Public: [".documents.azure.com"]
    • China: [".documents.azure.cn"]
    • UsGov: [".documents.azure.us"]
    • Germany: []
  2. Call AzureService.ValidateAzureServiceEndpoint(baseUri, "cosmos") in CosmosService.GetCosmosBaseUri before returning the endpoint URI.
  3. Add unit tests covering valid and invalid Cosmos endpoint/account inputs across clouds.
Dominant language
C#
Stars
3.9k
Forks
689
Avg merge
2d 11h
Merged PRs (30d)
143

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/mcp

All issues in microsoft/mcp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.