Add McpServerPrompt / McpClientPrompt and friends (#126)

This commit is contained in:
Stephen Toub 2025-03-31 09:54:40 -04:00 • committed by GitHub
commit 5d3fb65b11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1950 additions and 550 deletions

View file

@ -13,7 +13,7 @@ public static class NotificationMethods
/// <summary>
/// Sent by the server when the list of prompts changes.
/// </summary>
public const string PromptsListChanged = "notifications/prompts/list_changed";
public const string PromptListChangedNotification = "notifications/prompts/list_changed";
/// <summary>
/// Sent by the server when the list of resources changes.

View file

@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using ModelContextProtocol.Configuration;
using ModelContextProtocol.Logging;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Utils;

View file

@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Configuration;
using ModelContextProtocol.Utils;
namespace ModelContextProtocol.Protocol.Transport;

View file

@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using ModelContextProtocol.Configuration;
using ModelContextProtocol.Logging;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Utils;

View file

@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Configuration;
using ModelContextProtocol.Utils;
namespace ModelContextProtocol.Protocol.Transport;

View file

@ -97,6 +97,18 @@ public class PromptsCapability
/// </summary>
[JsonIgnore]
public Func<RequestContext<GetPromptRequestParams>, CancellationToken, Task<GetPromptResult>>? GetPromptHandler { get; set; }
/// <summary>Gets or sets a collection of prompts served by the server.</summary>
/// <remarks>
/// Prompts will specified via <see cref="PromptCollection"/> augment the <see cref="ListPromptsHandler"/> and
/// <see cref="GetPromptHandler"/>, if provided. ListPrompts requests will output information about every prompt
/// in <see cref="PromptCollection"/> and then also any tools output by <see cref="ListPromptsHandler"/>, if it's
/// non-<see langword="null"/>. GetPrompt requests will first check <see cref="PromptCollection"/> for the prompt
/// being requested, and if the tool is not found in the <see cref="PromptCollection"/>, any specified <see cref="GetPromptHandler"/>
/// will be invoked as a fallback.
/// </remarks>
[JsonIgnore]
public McpServerPrimitiveCollection<McpServerPrompt>? PromptCollection { get; set; }
}
/// <summary>
@ -182,5 +194,5 @@ public class ToolsCapability
/// will be invoked as a fallback.
/// </remarks>
[JsonIgnore]
public McpServerToolCollection? ToolCollection { get; set; }
public McpServerPrimitiveCollection<McpServerTool>? ToolCollection { get; set; }
}