Class McpSkillsClientExtensions
- Namespace
- ModelContextProtocol.Extensions.Skills
- Assembly
- ModelContextProtocol.Extensions.Skills.dll
Extension methods for McpClient and ServerCapabilities to discover skills and verify their file manifests under the MCP Skills extension (SEP-2640).
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static class McpSkillsClientExtensions
- Inheritance
-
McpSkillsClientExtensions
- Inherited Members
Remarks
These methods validate entries and verify file content against manifests. They do not verify a skill's frontmatter, which a host must still do before loading it; see SkillVerifier.
Methods
GetSkillAsync(McpClient, GetSkillRequestParams, CancellationToken)
Retrieves the entry for a single skill using explicit request parameters.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static ValueTask<GetSkillResult> GetSkillAsync(this McpClient client, GetSkillRequestParams requestParams, CancellationToken cancellationToken = default)
Parameters
clientMcpClientThe client.
requestParamsGetSkillRequestParamsThe request parameters.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<GetSkillResult>
The result with its entry structurally validated, but not compared with the skill's files.
Exceptions
- ArgumentNullException
clientorrequestParamsis null.- InvalidOperationException
The server did not declare the MCP Skills extension.
- McpException
The request failed or the server returned an error response.
- InvalidDataException
The entry is invalid or has a different URI than the one requested.
GetSkillAsync(McpClient, string, RequestOptions?, CancellationToken)
Retrieves the entry for a single skill by the URI of its SKILL.md.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static ValueTask<Skill> GetSkillAsync(this McpClient client, string uri, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
clientMcpClientThe client.
uristringThe URI of the skill's
SKILL.md.optionsRequestOptionsOptional metadata and progress token for the request.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<Skill>
The structurally validated skill entry, not a verification of the file's frontmatter.
Remarks
A server answers for every skill it serves, whether or not the skill appears in its listing. Use this to confirm a URI referenced from server instructions or another skill, and to refresh one skill's manifest without re-enumerating the catalog.
Exceptions
- ArgumentNullException
clientoruriis null.- InvalidOperationException
The server did not declare the MCP Skills extension.
- McpException
The request failed or the server returned an error response, including InvalidParams when the server serves no skill at
uri.- InvalidDataException
The entry is invalid or has a different URI than the one requested.
ListSkillsAsync(McpClient, ListSkillsRequestParams, CancellationToken)
Retrieves one page of the skills the server lists.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static ValueTask<ListSkillsResult> ListSkillsAsync(this McpClient client, ListSkillsRequestParams requestParams, CancellationToken cancellationToken = default)
Parameters
clientMcpClientThe client.
requestParamsListSkillsRequestParamsThe request parameters, including the cursor of the page to retrieve.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<ListSkillsResult>
The page with every entry structurally validated, but not compared with the skill's files.
Remarks
This method sends one request and preserves its page's cursor and cache hints. Use ListSkillsAsync(McpClient, RequestOptions?, CancellationToken) to retrieve all listing pages. An empty page does not establish that the server serves no skills; a skill can also be retrieved directly by URI.
Exceptions
- ArgumentNullException
clientorrequestParamsis null.- InvalidOperationException
The server did not declare the MCP Skills extension.
- InvalidDataException
The server returned an invalid skill entry.
- McpException
The request failed or the server returned an error response.
ListSkillsAsync(McpClient, RequestOptions?, CancellationToken)
Retrieves the listed skills by automatically handling pagination.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static ValueTask<IList<Skill>> ListSkillsAsync(this McpClient client, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
clientMcpClientThe client.
optionsRequestOptionsOptional metadata and progress token for each request.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<IList<Skill>>
The listed skills, with every entry structurally validated but not compared with its files.
Remarks
A server may list fewer skills than it serves. An empty listing does not prevent direct retrieval by URI with GetSkillAsync(McpClient, string, RequestOptions?, CancellationToken).
Every call fetches all listing pages without caching. Per-page cache hints are not returned; use ListSkillsAsync(McpClient, ListSkillsRequestParams, CancellationToken) to read them or to enforce application-owned pagination budgets.
Exceptions
- ArgumentNullException
clientis null.- InvalidOperationException
The server did not declare the MCP Skills extension.
- InvalidDataException
The server returned an invalid skill entry.
- McpException
The request failed or the server returned an error response.
ReadSkillResourceAsync(McpClient, Skill, string, RequestOptions?, CancellationToken)
Reads one of a skill's files through resources/read and verifies its URI, digest and size against the manifest.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static ValueTask<ReadResourceResult> ReadSkillResourceAsync(this McpClient client, Skill skill, string uri, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
clientMcpClientThe client.
skillSkillThe skill entry being acted on.
uristringThe URI of the file to read. It must be listed in
skill's manifest.optionsRequestOptionsOptional metadata and progress token, forwarded to the resource read.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<ReadResourceResult>
The manifest-verified contents. Frontmatter verification remains the host's responsibility.
Remarks
An unlisted file is treated as a verification failure before any request is sent, because the manifest is complete and an unlisted file is a change to the skill. To read it, refresh the entry with GetSkillAsync(McpClient, string, RequestOptions?, CancellationToken) and proceed from the new manifest.
For SKILL.md, the host must also parse the fetched frontmatter and compare it with
Frontmatter before loading. A digest match does not perform or replace that check.
Exceptions
- ArgumentNullException
An argument is null.
- InvalidOperationException
skill's manifest is Dynamic. Such a skill offers no content integrity; read its files with ReadResourceAsync(string, RequestOptions?, CancellationToken) only if the host permits content without digest verification. Frontmatter verification is still required.- InvalidDataException
uriis not listed in the manifest, the server's response does not contain contents foruri, or any returned content's size or digest does not match its manifest entry.- McpException
The request failed or the server returned an error response.
SupportsSkills(ServerCapabilities)
Gets whether the server declared the MCP Skills extension in its capabilities.
[Experimental("MCPEXP005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp005")]
public static bool SupportsSkills(this ServerCapabilities capabilities)
Parameters
capabilitiesServerCapabilitiesThe server's advertised capabilities.
Returns
Remarks
Clients must issue skills/list and skills/get only after observing the server's declaration.
The list and get methods in this class throw InvalidOperationException when it is absent.
Exceptions
- ArgumentNullException
capabilitiesis null.