|
| 1 | +using ModelContextProtocol.Protocol; |
| 2 | + |
| 3 | +namespace ModelContextProtocol.Server; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// Provides grouped request-specific filter collections. |
| 7 | +/// </summary> |
| 8 | +public sealed class McpRequestFilters |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Gets the filters for the list-tools handler pipeline. |
| 12 | + /// </summary> |
| 13 | + /// <remarks> |
| 14 | + /// <para> |
| 15 | + /// These filters wrap handlers that return a list of available tools when requested by a client. |
| 16 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 17 | + /// <see cref="RequestMethods.ToolsList"/> requests. It supports pagination through the cursor mechanism, |
| 18 | + /// where the client can make repeated calls with the cursor returned by the previous call to retrieve more tools. |
| 19 | + /// </para> |
| 20 | + /// <para> |
| 21 | + /// These filters work alongside any tools defined in the <see cref="McpServerTool"/> collection. |
| 22 | + /// Tools from both sources will be combined when returning results to clients. |
| 23 | + /// </para> |
| 24 | + /// </remarks> |
| 25 | + public IList<McpRequestFilter<ListToolsRequestParams, ListToolsResult>> ListToolsFilters { get; } = []; |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Gets the filters for the call-tool handler pipeline. |
| 29 | + /// </summary> |
| 30 | + /// <remarks> |
| 31 | + /// These filters wrap handlers that are invoked when a client makes a call to a tool that isn't found in the <see cref="McpServerTool"/> collection. |
| 32 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 33 | + /// <see cref="RequestMethods.ToolsCall"/> requests. The handler should implement logic to execute the requested tool and return appropriate results. |
| 34 | + /// </remarks> |
| 35 | + public IList<McpRequestFilter<CallToolRequestParams, CallToolResult>> CallToolFilters { get; } = []; |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Gets the filters for the list-prompts handler pipeline. |
| 39 | + /// </summary> |
| 40 | + /// <remarks> |
| 41 | + /// <para> |
| 42 | + /// These filters wrap handlers that return a list of available prompts when requested by a client. |
| 43 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 44 | + /// <see cref="RequestMethods.PromptsList"/> requests. It supports pagination through the cursor mechanism, |
| 45 | + /// where the client can make repeated calls with the cursor returned by the previous call to retrieve more prompts. |
| 46 | + /// </para> |
| 47 | + /// <para> |
| 48 | + /// These filters work alongside any prompts defined in the <see cref="McpServerPrompt"/> collection. |
| 49 | + /// Prompts from both sources will be combined when returning results to clients. |
| 50 | + /// </para> |
| 51 | + /// </remarks> |
| 52 | + public IList<McpRequestFilter<ListPromptsRequestParams, ListPromptsResult>> ListPromptsFilters { get; } = []; |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Gets the filters for the get-prompt handler pipeline. |
| 56 | + /// </summary> |
| 57 | + /// <remarks> |
| 58 | + /// These filters wrap handlers that are invoked when a client requests details for a specific prompt that isn't found in the <see cref="McpServerPrompt"/> collection. |
| 59 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 60 | + /// <see cref="RequestMethods.PromptsGet"/> requests. The handler should implement logic to fetch or generate the requested prompt and return appropriate results. |
| 61 | + /// </remarks> |
| 62 | + public IList<McpRequestFilter<GetPromptRequestParams, GetPromptResult>> GetPromptFilters { get; } = []; |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Gets the filters for the list-resource-templates handler pipeline. |
| 66 | + /// </summary> |
| 67 | + /// <remarks> |
| 68 | + /// These filters wrap handlers that return a list of available resource templates when requested by a client. |
| 69 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 70 | + /// <see cref="RequestMethods.ResourcesTemplatesList"/> requests. It supports pagination through the cursor mechanism, |
| 71 | + /// where the client can make repeated calls with the cursor returned by the previous call to retrieve more resource templates. |
| 72 | + /// </remarks> |
| 73 | + public IList<McpRequestFilter<ListResourceTemplatesRequestParams, ListResourceTemplatesResult>> ListResourceTemplatesFilters { get; } = []; |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// Gets the filters for the list-resources handler pipeline. |
| 77 | + /// </summary> |
| 78 | + /// <remarks> |
| 79 | + /// These filters wrap handlers that return a list of available resources when requested by a client. |
| 80 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 81 | + /// <see cref="RequestMethods.ResourcesList"/> requests. It supports pagination through the cursor mechanism, |
| 82 | + /// where the client can make repeated calls with the cursor returned by the previous call to retrieve more resources. |
| 83 | + /// </remarks> |
| 84 | + public IList<McpRequestFilter<ListResourcesRequestParams, ListResourcesResult>> ListResourcesFilters { get; } = []; |
| 85 | + |
| 86 | + /// <summary> |
| 87 | + /// Gets the filters for the read-resource handler pipeline. |
| 88 | + /// </summary> |
| 89 | + /// <remarks> |
| 90 | + /// These filters wrap handlers that are invoked when a client requests the content of a specific resource identified by its URI. |
| 91 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 92 | + /// <see cref="RequestMethods.ResourcesRead"/> requests. The handler should implement logic to locate and retrieve the requested resource. |
| 93 | + /// </remarks> |
| 94 | + public IList<McpRequestFilter<ReadResourceRequestParams, ReadResourceResult>> ReadResourceFilters { get; } = []; |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Gets the filters for the complete-handler pipeline. |
| 98 | + /// </summary> |
| 99 | + /// <remarks> |
| 100 | + /// These filters wrap handlers that provide auto-completion suggestions for prompt arguments or resource references in the Model Context Protocol. |
| 101 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 102 | + /// <see cref="RequestMethods.CompletionComplete"/> requests. The handler processes auto-completion requests, returning a list of suggestions based on the |
| 103 | + /// reference type and current argument value. |
| 104 | + /// </remarks> |
| 105 | + public IList<McpRequestFilter<CompleteRequestParams, CompleteResult>> CompleteFilters { get; } = []; |
| 106 | + |
| 107 | + /// <summary> |
| 108 | + /// Gets the filters for the subscribe-to-resources handler pipeline. |
| 109 | + /// </summary> |
| 110 | + /// <remarks> |
| 111 | + /// <para> |
| 112 | + /// These filters wrap handlers that are invoked when a client wants to receive notifications about changes to specific resources or resource patterns. |
| 113 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 114 | + /// <see cref="RequestMethods.ResourcesSubscribe"/> requests. The handler should implement logic to register the client's interest in the specified resources |
| 115 | + /// and set up the necessary infrastructure to send notifications when those resources change. |
| 116 | + /// </para> |
| 117 | + /// <para> |
| 118 | + /// After a successful subscription, the server should send resource change notifications to the client |
| 119 | + /// whenever a relevant resource is created, updated, or deleted. |
| 120 | + /// </para> |
| 121 | + /// </remarks> |
| 122 | + public IList<McpRequestFilter<SubscribeRequestParams, EmptyResult>> SubscribeToResourcesFilters { get; } = []; |
| 123 | + |
| 124 | + /// <summary> |
| 125 | + /// Gets the filters for the unsubscribe-from-resources handler pipeline. |
| 126 | + /// </summary> |
| 127 | + /// <remarks> |
| 128 | + /// <para> |
| 129 | + /// These filters wrap handlers that are invoked when a client wants to stop receiving notifications about previously subscribed resources. |
| 130 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 131 | + /// <see cref="RequestMethods.ResourcesUnsubscribe"/> requests. The handler should implement logic to remove the client's subscriptions to the specified resources |
| 132 | + /// and clean up any associated resources. |
| 133 | + /// </para> |
| 134 | + /// <para> |
| 135 | + /// After a successful unsubscription, the server should no longer send resource change notifications |
| 136 | + /// to the client for the specified resources. |
| 137 | + /// </para> |
| 138 | + /// </remarks> |
| 139 | + public IList<McpRequestFilter<UnsubscribeRequestParams, EmptyResult>> UnsubscribeFromResourcesFilters { get; } = []; |
| 140 | + |
| 141 | + /// <summary> |
| 142 | + /// Gets the filters for the set-logging-level handler pipeline. |
| 143 | + /// </summary> |
| 144 | + /// <remarks> |
| 145 | + /// <para> |
| 146 | + /// These filters wrap handlers that process <see cref="RequestMethods.LoggingSetLevel"/> requests from clients. When set, it enables |
| 147 | + /// clients to control which log messages they receive by specifying a minimum severity threshold. |
| 148 | + /// The filters can modify, log, or perform additional operations on requests and responses for |
| 149 | + /// <see cref="RequestMethods.LoggingSetLevel"/> requests. |
| 150 | + /// </para> |
| 151 | + /// <para> |
| 152 | + /// After handling a level change request, the server typically begins sending log messages |
| 153 | + /// at or above the specified level to the client as notifications/message notifications. |
| 154 | + /// </para> |
| 155 | + /// </remarks> |
| 156 | + public IList<McpRequestFilter<SetLevelRequestParams, EmptyResult>> SetLoggingLevelFilters { get; } = []; |
| 157 | +} |
0 commit comments