Telemetry: emit per-tool identifier via CosmosClient ApplicationName
Problem
DailyUserAgentSummary.UserAgent is the only field our downstream dashboards can bucket by, and today it cannot break down MCP Toolkit calls by tool. Every one of the 8 [McpServerTool] methods in [McpServerToolType] CosmosDbTools (in src/AzureCosmosDB.MCP.Toolkit/Program.cs) constructs its CosmosClient with the same hardcoded value:
using var client = new CosmosClient(endpoint, credential, new CosmosClientOptions
{
ApplicationName = "AzureCosmosDBMCP"
});
The tool name currently only lives in ILogger messages (e.g. "Listing databases from Cosmos DB", "Received MCP tool call: {ToolName}"). Those logs flow to stdout / Container Apps / App Insights — not into the Cosmos SDK UserAgent that surfaces in DailyUserAgentSummary.UserAgent. So the per-tool signal simply isn't in the telemetry the dashboard reads.
Fix
Encode the tool name into ApplicationName using the format:
AzureCosmosDBMCP-<kebab-tool-name>
Separator - (dash) avoids collision with / and , which the Cosmos SDK already uses in its own UA segments, giving an unambiguous regex.
Mapping
| Method |
ApplicationName |
ListDatabases |
AzureCosmosDBMCP-list-databases |
ListCollections |
AzureCosmosDBMCP-list-collections |
GetRecentDocuments |
AzureCosmosDBMCP-get-recent-documents |
TextSearch |
AzureCosmosDBMCP-text-search |
FindDocumentByID |
AzureCosmosDBMCP-find-document-by-id |
GetApproximateSchema |
AzureCosmosDBMCP-get-approximate-schema |
VectorSearch |
AzureCosmosDBMCP-vector-search |
HybridSearch |
AzureCosmosDBMCP-hybrid-search |
KQL (dashboard tile)
DailyUserAgentSummary
| where UserAgent has "AzureCosmosDBMCP-"
| extend Tool = extract(@"AzureCosmosDBMCP-([a-z][a-z0-9-]*)", 1, UserAgent)
| where isnotempty(Tool)
| summarize Requests = sum(Count) by Tool, bin(Date, 1d)
| render columnchart
Scope
- Change 8
ApplicationName string literals in src/AzureCosmosDB.MCP.Toolkit/Program.cs.
- Add a short comment near the first modified site documenting the convention for future
[McpServerTool] additions.
- Not changing the singleton
CosmosClient built in CosmosClientFactory.BuildClientOptions — it feeds CosmosDbToolsService, which is not on the MCP tool path today, and a singleton fundamentally cannot carry a per-tool suffix. Documented as a known limitation.
Spec
Full spec: docs/specs/tool-name-in-useragent.md
Acceptance criteria
Telemetry: emit per-tool identifier via CosmosClient
ApplicationNameProblem
DailyUserAgentSummary.UserAgentis the only field our downstream dashboards can bucket by, and today it cannot break down MCP Toolkit calls by tool. Every one of the 8[McpServerTool]methods in[McpServerToolType] CosmosDbTools(insrc/AzureCosmosDB.MCP.Toolkit/Program.cs) constructs itsCosmosClientwith the same hardcoded value:The tool name currently only lives in
ILoggermessages (e.g."Listing databases from Cosmos DB","Received MCP tool call: {ToolName}"). Those logs flow to stdout / Container Apps / App Insights — not into the Cosmos SDK UserAgent that surfaces inDailyUserAgentSummary.UserAgent. So the per-tool signal simply isn't in the telemetry the dashboard reads.Fix
Encode the tool name into
ApplicationNameusing the format:AzureCosmosDBMCP-<kebab-tool-name>Separator
-(dash) avoids collision with/and,which the Cosmos SDK already uses in its own UA segments, giving an unambiguous regex.Mapping
ApplicationNameListDatabasesAzureCosmosDBMCP-list-databasesListCollectionsAzureCosmosDBMCP-list-collectionsGetRecentDocumentsAzureCosmosDBMCP-get-recent-documentsTextSearchAzureCosmosDBMCP-text-searchFindDocumentByIDAzureCosmosDBMCP-find-document-by-idGetApproximateSchemaAzureCosmosDBMCP-get-approximate-schemaVectorSearchAzureCosmosDBMCP-vector-searchHybridSearchAzureCosmosDBMCP-hybrid-searchKQL (dashboard tile)
Scope
ApplicationNamestring literals insrc/AzureCosmosDB.MCP.Toolkit/Program.cs.[McpServerTool]additions.CosmosClientbuilt inCosmosClientFactory.BuildClientOptions— it feedsCosmosDbToolsService, which is not on the MCP tool path today, and a singleton fundamentally cannot carry a per-tool suffix. Documented as a known limitation.Spec
Full spec:
docs/specs/tool-name-in-useragent.mdAcceptance criteria
[McpServerTool]methods emits a distinctApplicationNamematching the table above.dotnet build).docs/specs/tool-name-in-useragent.mdmerged alongside code change.