1- using ModelContextProtocol . Protocol . Messages ;
2- using ModelContextProtocol . Protocol . Types ;
1+ using ModelContextProtocol . Protocol . Types ;
32
43namespace ModelContextProtocol . Server ;
54
65/// <summary>
76/// Represents a server that can communicate with a client using the MCP protocol.
87/// </summary>
9- public interface IMcpServer : IAsyncDisposable
8+ public interface IMcpServer : IMcpEndpoint
109{
1110 /// <summary>
1211 /// Gets the capabilities supported by the client.
@@ -26,42 +25,8 @@ public interface IMcpServer : IAsyncDisposable
2625 /// </summary>
2726 IServiceProvider ? Services { get ; }
2827
29- /// <summary>
30- /// Adds a handler for client notifications of a specific method.
31- /// </summary>
32- /// <param name="method">The notification method to handle.</param>
33- /// <param name="handler">The async handler function to process notifications.</param>
34- /// <remarks>
35- /// <para>
36- /// Each method may have multiple handlers. Adding a handler for a method that already has one
37- /// will not replace the existing handler.
38- /// </para>
39- /// <para>
40- /// <see cref="NotificationMethods"> provides constants for common notification methods.</see>
41- /// </para>
42- /// </remarks>
43- void AddNotificationHandler ( string method , Func < JsonRpcNotification , Task > handler ) ;
44-
4528 /// <summary>
4629 /// Runs the server, listening for and handling client requests.
4730 /// </summary>
4831 Task RunAsync ( CancellationToken cancellationToken = default ) ;
49-
50- /// <summary>
51- /// Sends a generic JSON-RPC request to the client.
52- /// NB! This is a temporary method that is available to send not yet implemented feature messages.
53- /// Once all MCP features are implemented this will be made private, as it is purely a convenience for those who wish to implement features ahead of the library.
54- /// </summary>
55- /// <typeparam name="TResult">The expected response type.</typeparam>
56- /// <param name="request">The JSON-RPC request to send.</param>
57- /// <param name="cancellationToken">A token to cancel the operation.</param>
58- /// <returns>A task containing the client's response.</returns>
59- Task < TResult > SendRequestAsync < TResult > ( JsonRpcRequest request , CancellationToken cancellationToken = default ) where TResult : class ;
60-
61- /// <summary>
62- /// Sends a message to the client.
63- /// </summary>
64- /// <param name="message">The message.</param>
65- /// <param name="cancellationToken">A token to cancel the operation.</param>
66- Task SendMessageAsync ( IJsonRpcMessage message , CancellationToken cancellationToken = default ) ;
6732}
0 commit comments