AI seeded comments from robch and then edited by stephentoub (#238)
* AI generated `///` comment updates * Fix compilation issues * Fix incorrect XML comment structure * Update all Client comments * Update all Configuration comments * Update all Messages comments * Update all Transport comments * Update all Types comments * Update all Server comments * Undo some commenting --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
07300389ee
commit
77871c5aac
1 changed files with 4017 additions and 1066 deletions
|
|
@ -1,9 +1,23 @@
|
|||
using ModelContextProtocol.Protocol.Types;
|
||||
using ModelContextProtocol.Protocol.Types;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModelContextProtocol.Client;
|
||||
|
||||
/// <summary>Provides an invocable prompt.</summary>
|
||||
/// <summary>
|
||||
/// Represents a named prompt that can be retrieved from an MCP server and invoked with arguments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This class provides a client-side wrapper around a prompt defined on an MCP server. It allows
|
||||
/// retrieving the prompt's content by sending a request to the server with optional arguments.
|
||||
/// Instances of this class are typically obtained by calling <see cref="McpClientExtensions.ListPromptsAsync"/>
|
||||
/// or <see cref="McpClientExtensions.EnumeratePromptsAsync"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Each prompt has a name and optionally a description, and it can be invoked with arguments
|
||||
/// to produce customized prompt content from the server.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class McpClientPrompt
|
||||
{
|
||||
private readonly IMcpClient _client;
|
||||
|
|
@ -14,16 +28,42 @@ public sealed class McpClientPrompt
|
|||
ProtocolPrompt = prompt;
|
||||
}
|
||||
|
||||
/// <summary>Gets the protocol <see cref="Prompt"/> type for this instance.</summary>
|
||||
/// <summary>Gets the underlying protocol <see cref="Prompt"/> type for this instance.</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This property provides direct access to the underlying protocol representation of the prompt,
|
||||
/// which can be useful for advanced scenarios or when implementing custom MCP client extensions.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// For most common use cases, you can use the more convenient <see cref="Name"/> and
|
||||
/// <see cref="Description"/> properties instead of accessing the <see cref="ProtocolPrompt"/> directly.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public Prompt ProtocolPrompt { get; }
|
||||
|
||||
/// <summary>Gets the name of the prompt.</summary>
|
||||
public string Name => ProtocolPrompt.Name;
|
||||
|
||||
/// <summary>Gets a description of the prompt.</summary>
|
||||
public string? Description => ProtocolPrompt.Description;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a specific prompt with optional arguments.
|
||||
/// Gets this prompt's content by sending a request to the server with optional arguments.
|
||||
/// </summary>
|
||||
/// <param name="arguments">Optional arguments for the prompt</param>
|
||||
/// <param name="arguments">Optional arguments to pass to the prompt. Keys are parameter names, and values are the argument values.</param>
|
||||
/// <param name="serializerOptions">The serialization options governing argument serialization.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
|
||||
/// <returns>A task containing the prompt's content and messages.</returns>
|
||||
/// <returns>A <see cref="ValueTask"/> containing the prompt's result with content and messages.</returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method sends a request to the MCP server to execute this prompt with the provided arguments.
|
||||
/// The server will process the request and return a result containing messages or other content.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This is a convenience method that internally calls <see cref="McpClientExtensions.GetPromptAsync"/>
|
||||
/// with this prompt's name and arguments.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public async ValueTask<GetPromptResult> GetAsync(
|
||||
IEnumerable<KeyValuePair<string, object?>>? arguments = null,
|
||||
JsonSerializerOptions? serializerOptions = null,
|
||||
|
|
@ -35,10 +75,4 @@ public sealed class McpClientPrompt
|
|||
|
||||
return await _client.GetPromptAsync(ProtocolPrompt.Name, argDict, serializerOptions, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>Gets the name of the prompt.</summary>
|
||||
public string Name => ProtocolPrompt.Name;
|
||||
|
||||
/// <summary>Gets a description of the prompt.</summary>
|
||||
public string? Description => ProtocolPrompt.Description;
|
||||
}
|
||||
Loading…
Reference in a new issue