Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/EverythingServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ await ctx.Server.RequestSamplingAsync([
}
return Task.FromResult(new EmptyResult());
})
.WithGetCompletionHandler((ctx, ct) =>
.WithCompleteHandler((ctx, ct) =>
{
var exampleCompletions = new Dictionary<string, IEnumerable<string>>
{
Expand Down
2 changes: 1 addition & 1 deletion src/ModelContextProtocol/Client/McpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static Task<ReadResourceResult> ReadResourceAsync(
/// <param name="argumentName">Name of argument. Must be non-null and non-empty.</param>
/// <param name="argumentValue">Value of argument. Must be non-null.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
public static Task<CompleteResult> GetCompletionAsync(this IMcpClient client, Reference reference, string argumentName, string argumentValue, CancellationToken cancellationToken = default)
public static Task<CompleteResult> CompleteAsync(this IMcpClient client, Reference reference, string argumentName, string argumentValue, CancellationToken cancellationToken = default)
{
Throw.IfNull(client);
Throw.IfNull(reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,15 @@ public static IMcpServerBuilder WithReadResourceHandler(this IMcpServerBuilder b
}

/// <summary>
/// Sets the handler for get completion requests.
/// Sets the handler for completion complete requests.
/// </summary>
/// <param name="builder">The builder instance.</param>
/// <param name="handler">The handler.</param>
public static IMcpServerBuilder WithGetCompletionHandler(this IMcpServerBuilder builder, Func<RequestContext<CompleteRequestParams>, CancellationToken, Task<CompleteResult>> handler)
public static IMcpServerBuilder WithCompleteHandler(this IMcpServerBuilder builder, Func<RequestContext<CompleteRequestParams>, CancellationToken, Task<CompleteResult>> handler)
{
Throw.IfNull(builder);

builder.Services.Configure<McpServerHandlers>(s => s.GetCompletionHandler = handler);
builder.Services.Configure<McpServerHandlers>(s => s.CompleteHandler = handler);
return builder;
}

Expand Down
207 changes: 0 additions & 207 deletions src/ModelContextProtocol/Protocol/Types/Capabilities.cs

This file was deleted.

38 changes: 38 additions & 0 deletions src/ModelContextProtocol/Protocol/Types/ClientCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Server;
using System.Text.Json.Serialization;

namespace ModelContextProtocol.Protocol.Types;

/// <summary>
/// Represents the capabilities that a client may support.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ClientCapabilities
{
/// <summary>
/// Experimental, non-standard capabilities that the client supports.
/// </summary>
[JsonPropertyName("experimental")]
public Dictionary<string, object>? Experimental { get; set; }

/// <summary>
/// Present if the client supports listing roots.
/// </summary>
[JsonPropertyName("roots")]
public RootsCapability? Roots { get; set; }

/// <summary>
/// Present if the client supports sampling from an LLM.
/// </summary>
[JsonPropertyName("sampling")]
public SamplingCapability? Sampling { get; set; }

/// <summary>Gets or sets notification handlers to register with the client.</summary>
/// <remarks>
/// When constructed, the client will enumerate these handlers, which may contain multiple handlers per key.
/// The client will not re-enumerate the sequence.
/// </remarks>
[JsonIgnore]
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, Task>>>? NotificationHandlers { get; set; }
}
19 changes: 19 additions & 0 deletions src/ModelContextProtocol/Protocol/Types/CompletionsCapability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using ModelContextProtocol.Server;
using System.Text.Json.Serialization;

namespace ModelContextProtocol.Protocol.Types;

/// <summary>
/// Represents the completions capability configuration.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class CompletionsCapability
{
// Currently empty in the spec, but may be extended in the future.

/// <summary>
/// Gets or sets the handler for get completion requests.
/// </summary>
[JsonIgnore]
public Func<RequestContext<CompleteRequestParams>, CancellationToken, Task<CompleteResult>>? CompleteHandler { get; set; }
}
21 changes: 21 additions & 0 deletions src/ModelContextProtocol/Protocol/Types/LoggingCapability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Server;
using System.Text.Json.Serialization;

namespace ModelContextProtocol.Protocol.Types;

/// <summary>
/// Represents the logging capability configuration.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class LoggingCapability
{
// Currently empty in the spec, but may be extended in the future


/// <summary>
/// Gets or sets the handler for set logging level requests.
/// </summary>
[JsonIgnore]
public Func<RequestContext<SetLevelRequestParams>, CancellationToken, Task<EmptyResult>>? SetLoggingLevelHandler { get; set; }
}
42 changes: 42 additions & 0 deletions src/ModelContextProtocol/Protocol/Types/PromptsCapability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Server;
using System.Text.Json.Serialization;

namespace ModelContextProtocol.Protocol.Types;

/// <summary>
/// Represents the prompts capability configuration.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class PromptsCapability
{
/// <summary>
/// Whether this server supports notifications for changes to the prompt list.
/// </summary>
[JsonPropertyName("listChanged")]
public bool? ListChanged { get; set; }

/// <summary>
/// Gets or sets the handler for list prompts requests.
/// </summary>
[JsonIgnore]
public Func<RequestContext<ListPromptsRequestParams>, CancellationToken, Task<ListPromptsResult>>? ListPromptsHandler { get; set; }

/// <summary>
/// Gets or sets the handler for get prompt requests.
/// </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; }
}
Loading