Skip to content

Align and consolidate the expiration settings across the CacheService #590

@ArthurMa1978

Description

@ArthurMa1978

Proposal

Currently, the expiration settings for each tool are inconsistent. Some tools have no expiration configured at all, resulting in caches that never expire. While others have expiration times set excessively long, which can lead to confusion for users. To address this, I’m proposing a standardized set of expiration settings:

  1. Tenant – 12 hours
    Tenant information rarely changes for users, so a 12-hour cache duration provides a good balance between performance and data freshness.
  2. Subscription – 2 hours
    Subscriptions are also relatively stable for most users. A 2-hour expiration helps reduce unnecessary refreshes while keeping the data reasonably up to date.
  3. Authenticated Clients – 15 minutes
    These are more dynamic and may change frequently, so a shorter cache duration of 15 minutes ensures better performance.
  4. Service Data – No cache or 5 minutes
    This data is critical for user interactions with the MCP tool. Ideally, it should not be cached to avoid latency or stale data issues. However, if caching is necessary to reduce service load, a 5-minute expiration is a reasonable compromise.

The tool should clearly indicate when data is being served from cache. If users suspect the data is outdated, it should also provide guidance on how to manually refresh the cache.

Details

Here is the CacheService Usage Summary Across Azure MCP Tools:

  1. Azure.Mcp.Tools.Search
    • Cache Groups: "search"
    • What's Cached:
      • Search services list (1 hour TTL)
      • Search index clients (15 minutes TTL)
    • Cache Keys: Subscription-based and tenant-based keys
    • Usage Pattern: Cache expensive service discovery and client initialization
  2. Azure.Mcp.Tools.Kusto
    • Cache Groups: "kusto"
    • What's Cached:
      • KustoClient instances for ARM and Data Explorer providers
    • Cache Duration: Uses s_providerCacheDuration
    • Usage Pattern: Cache authenticated client connections to avoid repeated auth
  3. Azure.Mcp.Tools.FunctionApp
    • Cache Groups: "functionapp"
    • What's Cached:
      • Function app information lists
    • Cache Duration: s_cacheDuration (not specified in excerpt)
    • Usage Pattern: Cache resource listings by subscription/resource group
  4. Azure.Mcp.Tools.Cosmos
    • Cache Groups: "cosmos"
    • What's Cached:
      • CosmosClient instances
      • Database lists
      • Container lists
    • Cache Duration: s_cacheDurationResources
    • Special Features:
      • Implements cache cleanup via GetGroupKeysAsync()
      • Disposes cached clients properly in cleanup logic
    • Usage Pattern: Most comprehensive caching - clients, metadata, and cleanup
  5. Azure.Mcp.Tools.Aks
    • Cache Groups: "aks"
    • What's Cached:
      • AKS cluster lists
      • Individual cluster details
      • Node pool lists
      • Individual node pool details
    • Cache Duration: s_cacheDuration
    • Usage Pattern: Multi-level resource hierarchy caching
  6. Azure.Mcp.Tools.Storage
    • Cache Groups: Not actively using (has constructor injection but no actual cache calls found)
    • Status: Prepared for caching but not implemented
  7. Core Services Using CacheService
    • TenantService
      • Cache Groups: "tenant"
      • Cache Duration: 12 hours
      • What's Cached: Tenant resource lists
    • SubscriptionService
      • Cache Groups: "subscription"
      • Cache Duration: 12 hours
      • What's Cached: Subscription data and individual subscriptions
    • ResourceGroupService
      • Cache Groups: "resourcegroup"
      • Cache Duration: Not specified in excerpt
      • What's Cached: Resource group information by subscription

Metadata

Metadata

Assignees

Labels

server-Azure.McpAzure.Mcp.Servertools-CoreAZMCP Core functionality that all other tools build on top of

Type

No type

Projects

Status

Not Started

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions