-
Notifications
You must be signed in to change notification settings - Fork 546
Add server "completions" capability #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stephentoub
merged 2 commits into
modelcontextprotocol:main
from
stephentoub:completioncapability
Apr 7, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
207 changes: 0 additions & 207 deletions
207
src/ModelContextProtocol/Protocol/Types/Capabilities.cs
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/ModelContextProtocol/Protocol/Types/ClientCapabilities.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
19
src/ModelContextProtocol/Protocol/Types/CompletionsCapability.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
21
src/ModelContextProtocol/Protocol/Types/LoggingCapability.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
42
src/ModelContextProtocol/Protocol/Types/PromptsCapability.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.