Repository navigation
.NET: Add pagination to MCP-listed skill discovery - #9464
Conversation
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
There was a problem hiding this comment.
🟡 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.
There was a problem hiding this comment.
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
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |

Motivation & Context
MCP servers can split
skills/listdiscovery 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
nextCursoruntil the server finishes the listing, including across empty pages.Related Issue
Follow-up to pagination and bounded-discovery feedback in #9217.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.