Skip to content

.NET: Add TTL caching for MCP-listed skills - #9558

Merged
SergeyMenshykh merged 3 commits into
feature-mcp-skills-nextfrom
sergeymenshykh-mcp-skill-caching
Oct 21, 2026
Merged

SergeyMenshykh merged 3 commits into
feature-mcp-skills-nextfrom
sergeymenshykh-mcp-skill-caching

Conversation

@SergeyMenshykh

@SergeyMenshykh SergeyMenshykh commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation & Context

Honor server-provided TTLs for MCP-listed skills, avoiding repeated discovery while refreshing expired catalogs on demand.

Description & Review Guide

  • Read ttlMs from skills/list responses and cache skills while every discovery page remains fresh.
  • Refresh the complete catalog after expiration, preserving previously returned manifests and avoiding failed, canceled, or partial cache replacements.
  • Document disabling additional caching layers with DisableCaching() and add deterministic TTL, pagination, concurrency, cancellation, and disposal tests.

Related Issue

N/A - no linked issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 43a35206-f8c3-448c-a778-8cf9eaf19ecc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues remain, and focused tests cover freshness, refresh failures, synchronization, cancellation, and disposal.

No open issues 🎉

What changed in this PR

Adds server-directed TTL caching to .NET MCP skill discovery, reducing repeated requests while refreshing expired catalogs on demand.

Changes:

  • Parses per-page TTLs and synchronizes complete catalog refreshes.
  • Integrates loader disposal and documents disabling outer caching layers.
  • Adds deterministic coverage for expiration, pagination, concurrency, cancellation, and failed refreshes.
File Description
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​Listed/​AgentMcpListedSkillsTests.Ttl.cs Adds TTL and lifecycle tests.
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​Listed/​AgentMcpListedSkillsTests.cs Makes tests partial and disposes loaders.
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​Listed/​AgentMcpListedSkillsSerializationTests.cs Tests TTL deserialization and validation.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​Listed/​McpSkillsListResult.cs Maps ttlMs to a nullable duration.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​Listed/​McpListedSkillsLoader.cs Implements synchronized, TTL-aware catalog caching.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentSkillsProviderBuilderMcpExtensions.cs Documents disabling builder caching.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentMcpSkillsSource.cs Documents TTL behavior and disposes the loader.

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): c29de4e2c6b0
Model: gpt-5.6-sol

Overview

The loader measures each page's TTL from response receipt, refreshes complete catalogs under a single-flight gate, and publishes replacements only after all pages and manifests validate. The tests cover expiry boundaries, pagination, cancellation, failed refreshes, and preservation of previously returned manifests. However, the default builder cache prevents the new TTL behavior from running at all unless every caller opts out, and the new disposal path can race active discovery.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 2 files. Details are attached to the affected lines below.

Affected areas: dotnet/src/Microsoft.Agents.AI.Mcp/Skills/AgentSkillsProviderBuilderMcpExtensions.cs, dotnet/src/Microsoft.Agents.AI.Mcp/Skills/Listed/McpListedSkillsLoader.cs

Comment thread dotnet/src/Microsoft.Agents.AI.Mcp/Skills/Listed/McpListedSkillsLoader.cs Outdated
@github-code-quality

github-code-quality Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

feature-mcp-skills-n... 08851e6 sergeymenshykh-mcp-s... 834cc51 +/-
86% 85% -1%
View coverage of the 10 most impacted files.
File feature-mcp-skills-n... 08851e6 sergeymenshykh-mcp-s... 834cc51 +/-
/home/runner/wo...toryProvider.cs 95% 31% -64%
/home/runner/wo...SessionStore.cs 100% 53% -47%
/home/runner/wo...hellExecutor.cs 90% 73% -17%
/home/runner/wo...SkillsSource.cs 89% 83% -6%
/home/runner/wo...ctionVisitor.cs 81% 75% -6%
/home/runner/wo...CopilotAgent.cs 72% 76% +4%
/home/runner/wo...pListedSkill.cs 0% 93% +93%
/home/runner/wo...SkillsLoader.cs 0% 100% +100%
/home/runner/wo...dSkillsCache.cs 0% 100% +100%
/home/runner/wo...ueExtensions.cs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 21, 2026 10:48 UTC

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 43a35206-f8c3-448c-a778-8cf9eaf19ecc
Comment thread dotnet/src/Microsoft.Agents.AI.Mcp/Skills/Listed/McpListedSkillsLoader.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI.Mcp/Skills/Listed/McpListedSkillsLoader.cs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 43a35206-f8c3-448c-a778-8cf9eaf19ecc
@SergeyMenshykh
SergeyMenshykh deployed to github-app-auth October 21, 2026 10:39 — with GitHub Actions Active
@SergeyMenshykh
SergeyMenshykh merged commit 597101b into feature-mcp-skills-next Oct 21, 2026
15 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-mcp-skill-caching branch October 21, 2026 11:02

This branch was successfully deployed

2 active deployments
github-app-auth — 834cc518 Deployed Oct 21, 2026 by SergeyMenshykh via add_label #25849
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants