Skip to content

.NET: Add pagination to MCP-listed skill discovery - #9464

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

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

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Collaborator

Motivation & Context

MCP servers can split skills/list discovery across multiple pages. The source previously read only the first page, silently omitting skills returned after a continuation cursor. Paginated discovery also needs bounded resource usage when processing server-controlled catalogs.

Description & Review Guide

  • Follow nextCursor until the server finishes the listing, including across empty pages.
  • Add configurable defaults of 10 pages, 100 skills, and 10 MiB of combined list-result JSON per discovery.
  • Reject repeated cursors, invalid later pages, and exceeded limits instead of returning a locally truncated catalog.
  • Preserve opaque cursor values and validate pagination, limits, cancellation, and failure behavior with unit tests.

Related Issue

Follow-up to pagination and bounded-discovery feedback in #9217.

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.

Follow skills/list continuation cursors and bound paginated discovery by configurable page, skill, and combined result-size limits.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 53ae2c03-d223-4731-bc81-d3021698265c

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.

🟡 Changes recommended

The JSON-size check buffers the entire result before enforcing its limit, risking memory exhaustion.

1 open finding
What changed in this PR

Extends MCP-listed skill discovery from #9217 to support pagination with configurable discovery limits.

Changes:

  • Follows opaque continuation cursors, including across empty pages.
  • Adds page, skill-count, and combined JSON-size limits.
  • Expands tests for pagination, validation, cancellation, and failures.
File Description
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​Listed/​AgentMcpListedSkillsTests.cs Tests pagination, limits, and failure handling.
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​Listed/​AgentMcpListedSkillsSerializationTests.cs Tests cursor validation and preservation.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​Listed/​McpSkillsListResult.cs Adds the continuation cursor.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​Listed/​McpListedSkillsLoader.cs Implements pagination and discovery limits.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentSkillsProviderBuilderMcpExtensions.cs Documents expanded discovery support.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentMcpSkillsSourceOptions.cs Exposes configurable discovery limits.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentMcpSkillsSource.cs Documents pagination and failure behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@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: No findings
Scope: full PR (1 commit(s)): 8079795ddcbe
Model: gpt-5.6-sol

Overview

The PR adds fail-closed pagination for MCP-listed skill discovery with per-invocation page, skill-count, and serialized-result limits. Opaque cursor forwarding, cycle detection, cancellation, invalid later-page handling, exact limit boundaries, and preservation of lazy resource loading are covered by focused tests. No PR-introduced Critical, High, or Medium issue remained after reconciliation.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Remove ListedMaxResultSizeBytes and its counting pass. Document server trust and application-level resource-limit responsibilities, and cover large list responses.

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

Copilot-Session: 53ae2c03-d223-4731-bc81-d3021698265c
Match the dependency pin on main to address GHSA-qhrr-8q5h-9q3h and unblock PR builds.

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

Copilot-Session: 53ae2c03-d223-4731-bc81-d3021698265c
@github-code-quality

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

feature-mcp-skills-n... d12e4e9 sergeymenshykh-mcp-s... 9ea6329 +/-
86% 85% -1%
View coverage of the 10 most impacted files.
File feature-mcp-skills-n... d12e4e9 sergeymenshykh-mcp-s... 9ea6329 +/-
/home/runner/wo...toryProvider.cs 95% 31% -64%
/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...ngChatClient.cs 92% 97% +5%
/home/runner/wo...killResource.cs 0% 89% +89%
/home/runner/wo...pListedSkill.cs 0% 93% +93%
/home/runner/wo...SkillsLoader.cs 0% 100% +100%
/home/runner/wo...ueExtensions.cs 0% 100% +100%

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

@SergeyMenshykh
SergeyMenshykh merged commit 49e6b46 into feature-mcp-skills-next Oct 19, 2026
15 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-mcp-skill-pagination branch October 19, 2026 11:38
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Oct 19, 2026

This branch was previously deployed

2 inactive deployments
github-app-auth — 9ea63295 Deployed Oct 16, 2026 by SergeyMenshykh via add_label #25634
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