-
Notifications
You must be signed in to change notification settings - Fork 330
Add initial support for Resource Templates #18
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 19 commits into
modelcontextprotocol:main
from
Redth:dev/redth/template-resources
Mar 21, 2025
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c36924b
Add initial support for Resource Templates
Redth f568e01
Make ListResourceTemplatesHandler not required
Redth a1a9d3c
Remove extra line
Redth 1256a3a
Fix spaces
Redth 62e0eb9
Fix spaces
Redth d5ec9f6
Add and use a default ListResourceTemplatesHandler
Redth 775e467
Fix spaces
Redth 95b90de
Spaces
Redth b6b5b3b
Add Client extensions for ListResourceTemplates
Redth 8ffc231
Integration Test for Client ListResourceTemplates
Redth 22a64c7
Fix comment
Redth 9053ab2
Make Defaults internal
Redth 20f21fc
Simplify test call
Redth 62e9531
Make delegate static
Redth 4e1b925
Fix test comment
Redth c66d09c
Spaces
Redth 58b27df
Fix xml doc
Redth 5585540
Make default handler inline
Redth 296b0e3
Spaces
Redth 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
15 changes: 15 additions & 0 deletions
15
src/ModelContextProtocol/Protocol/Types/ListResourceTemplatesRequestParams.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,15 @@ | ||
namespace ModelContextProtocol.Protocol.Types; | ||
|
||
/// <summary> | ||
/// Sent from the client to request a list of resource templates the server has. | ||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see> | ||
/// </summary> | ||
public class ListResourceTemplatesRequestParams | ||
{ | ||
/// <summary> | ||
/// An opaque token representing the current pagination position. | ||
/// If provided, the server should return results starting after this cursor. | ||
/// </summary> | ||
[System.Text.Json.Serialization.JsonPropertyName("cursor")] | ||
public string? Cursor { get; init; } | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ModelContextProtocol/Protocol/Types/ListResourceTemplatesResult.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,16 @@ | ||
using ModelContextProtocol.Protocol.Messages; | ||
|
||
namespace ModelContextProtocol.Protocol.Types; | ||
|
||
/// <summary> | ||
/// The server's response to a resources/templates/list request from the client. | ||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see> | ||
/// </summary> | ||
public class ListResourceTemplatesResult : PaginatedResult | ||
{ | ||
/// <summary> | ||
/// A list of resource templates that the server offers. | ||
/// </summary> | ||
[System.Text.Json.Serialization.JsonPropertyName("resourceTemplates")] | ||
public List<ResourceTemplate> ResourceTemplates { get; set; } = []; | ||
} |
42 changes: 42 additions & 0 deletions
42
src/ModelContextProtocol/Protocol/Types/ResourceTemplate.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.Types; | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace ModelContextProtocol.Protocol.Types; | ||
|
||
/// <summary> | ||
/// Represents a known resource template that the server is capable of reading. | ||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see> | ||
/// </summary> | ||
public record ResourceTemplate | ||
{ | ||
/// <summary> | ||
/// The URI template (according to RFC 6570) that can be used to construct resource URIs. | ||
/// </summary> | ||
[JsonPropertyName("uriTemplate")] | ||
public required string UriTemplate { get; init; } | ||
|
||
/// <summary> | ||
/// A human-readable name for this resource template. | ||
/// </summary> | ||
[JsonPropertyName("name")] | ||
public required string Name { get; init; } | ||
|
||
/// <summary> | ||
/// A description of what this resource template represents. | ||
/// </summary> | ||
[JsonPropertyName("description")] | ||
public string? Description { get; init; } | ||
|
||
/// <summary> | ||
/// The MIME type of this resource template, if known. | ||
/// </summary> | ||
[JsonPropertyName("mimeType")] | ||
public string? MimeType { get; init; } | ||
|
||
/// <summary> | ||
/// Optional annotations for the resource template. | ||
/// </summary> | ||
[JsonPropertyName("annotations")] | ||
public Annotations? Annotations { get; init; } | ||
} |
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
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
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
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.