-
Notifications
You must be signed in to change notification settings - Fork 1.9k
.NET: [BREAKING] Support archive-type skills in AgentMcpSkillsSource #6631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SergeyMenshykh
wants to merge
7
commits into
microsoft:main
Choose a base branch
from
SergeyMenshykh:sergeymenshykh/mcp-archive-skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ba32a88
NET: Support archive-type skills in AgentMcpSkillsSource
semenshi ee8ea35
Fix CS0121 ambiguity in UseSource null test
semenshi 60d33d1
Address PR review: fix misleading comment and catch UnauthorizedAcces…
semenshi 163fedb
Decouple shared refresh from per-caller cancellation
semenshi 45deb9c
Fix file encoding: add UTF-8 BOM to archive tests
semenshi 0a8cdef
Fix file encoding: add UTF-8 BOM to ArchiveFormat.cs
semenshi 943527b
Clarify pruning doc: covers non-actionable entries too
semenshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
dotnet/src/Microsoft.Agents.AI.Mcp/Skills/AgentMcpSkillsSourceOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.Shared.DiagnosticIds; | ||
|
|
||
| namespace Microsoft.Agents.AI; | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for <see cref="AgentMcpSkillsSource"/>. | ||
| /// </summary> | ||
| [Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)] | ||
| public sealed class AgentMcpSkillsSourceOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the base directory that archive-type skills are extracted to and served from. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Archives are extracted beneath this directory as <c>{ArchiveSkillsDirectory}/{skill-name}/</c>. | ||
| /// When <see langword="null"/>, the source extracts to a per-instance unique location of | ||
| /// <c>{currentDirectory}/{guid}/{skill-name}/</c>, where the GUID is generated once per | ||
| /// <see cref="AgentMcpSkillsSource"/> instance so that multiple sources never overwrite one | ||
| /// another. Set this to a fixed value to get a predictable, reusable extraction location. | ||
| /// When set, each source must use its own unique directory: the source treats the directory as | ||
| /// exclusively its own and, on every discovery, prunes any sub-directory that the MCP server no | ||
| /// longer advertises or whose index entry is not actionable (e.g., missing a required field). | ||
| /// Pointing two sources at the same directory would therefore cause them to | ||
| /// delete each other's extracted skills. | ||
| /// </remarks> | ||
| public string? ArchiveSkillsDirectory { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the allowed file extensions for resources discovered in extracted archive-type skills. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When <see langword="null"/>, defaults to <c>.md</c>, <c>.json</c>, <c>.yaml</c>, <c>.yml</c>, | ||
| /// <c>.csv</c>, <c>.xml</c>, and <c>.txt</c>. | ||
| /// </remarks> | ||
| public IEnumerable<string>? ArchiveResourceExtensions { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum depth to search for resource files within each extracted archive-type | ||
| /// skill directory. A value of <c>1</c> searches only the skill root directory. A value of <c>2</c> | ||
| /// searches the root and one level of subdirectories. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When <see langword="null"/>, the source uses the default depth of <c>2</c>. | ||
| /// </remarks> | ||
| public int? ArchiveResourceSearchDepth { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum number of files that may be extracted from a single archive-type skill. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Guards against excessive-file-count denial-of-service archives. When <see langword="null"/>, the | ||
| /// source uses a default of <c>20</c>, sized for a typical well-formed skill (a handful of files). | ||
| /// Raise this for archive-type skills that legitimately bundle many files. An archive that exceeds | ||
| /// the limit is skipped. | ||
| /// </remarks> | ||
| public int? ArchiveMaxFileCount { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum size, in bytes, of a downloaded archive-type skill resource. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Guards against archive resources that are too large to materialize safely. When | ||
| /// <see langword="null"/>, the source uses a default of <c>1 MB</c>, sized for a typical | ||
| /// well-formed skill archive. Raise this for archive-type skills that legitimately require | ||
| /// larger archive payloads. An archive that exceeds the limit is skipped. | ||
| /// </remarks> | ||
| public long? ArchiveMaxSizeBytes { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum total uncompressed size, in bytes, of all files extracted from a single | ||
| /// archive-type skill. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Guards against decompression-bomb archives. When <see langword="null"/>, the source uses a default | ||
| /// of <c>1 MB</c>, sized for a typical well-formed skill (well under ~1 MB). Raise this for | ||
| /// archive-type skills that legitimately bundle larger content. An archive that exceeds the limit is | ||
| /// skipped. | ||
| /// </remarks> | ||
| public long? ArchiveMaxUncompressedSizeBytes { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the interval at which cached skills are considered fresh. When a caller invokes | ||
| /// <see cref="AgentMcpSkillsSource.GetSkillsAsync"/> and the cached result is younger than this | ||
| /// interval, the cached list is returned without contacting the MCP server. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When <see langword="null"/> (the default), caching is disabled and every call fetches from | ||
| /// the MCP server. Set to a positive <see cref="TimeSpan"/> to enable caching. Values of | ||
| /// <see cref="TimeSpan.Zero"/> or negative durations effectively disable caching because the | ||
| /// cache age will always be greater than or equal to the interval. | ||
| /// </remarks> | ||
| public TimeSpan? RefreshInterval { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.