Skip to content

Commit 77709e5

Browse files
committed
Revert "Remove unused properties from ProtectedResourceMetadata"
This reverts commit f18c391.
1 parent f18c391 commit 77709e5

3 files changed

Lines changed: 144 additions & 0 deletions

File tree

samples/ProtectedMcpServer/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
{
5757
options.ResourceMetadata = new()
5858
{
59+
ResourceDocumentation = "https://docs.example.com/api/weather",
5960
AuthorizationServers = { inMemoryOAuthServerUrl },
6061
ScopesSupported = ["mcp:tools"],
6162
};

src/ModelContextProtocol.Core/Authentication/ProtectedResourceMetadata.cs

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ public sealed class ProtectedResourceMetadata
3535
[JsonPropertyName("authorization_servers")]
3636
public List<string> AuthorizationServers { get; set; } = [];
3737

38+
/// <summary>
39+
/// Gets or sets the supported bearer token methods.
40+
/// </summary>
41+
/// <value>
42+
/// A JSON array containing a list of the supported methods of sending an OAuth 2.0 bearer token
43+
/// to the protected resource. Defined values are ["header", "body", "query"].
44+
/// </value>
45+
/// <remarks>
46+
/// OPTIONAL.
47+
/// </remarks>
48+
[JsonPropertyName("bearer_methods_supported")]
49+
public List<string> BearerMethodsSupported { get; set; } = ["header"];
50+
3851
/// <summary>
3952
/// Gets or sets the supported scopes.
4053
/// </summary>
@@ -48,6 +61,123 @@ public sealed class ProtectedResourceMetadata
4861
[JsonPropertyName("scopes_supported")]
4962
public List<string> ScopesSupported { get; set; } = [];
5063

64+
/// <summary>
65+
/// Gets or sets the URL of the protected resource's JSON Web Key (JWK) Set document.
66+
/// </summary>
67+
/// <remarks>
68+
/// OPTIONAL. This document contains public keys belonging to the protected resource, such as signing keys
69+
/// that the resource server uses to sign resource responses. This URL MUST use the HTTPS scheme.
70+
/// </remarks>
71+
[JsonPropertyName("jwks_uri")]
72+
public string? JwksUri { get; set; }
73+
74+
/// <summary>
75+
/// Gets or sets the list of the JWS signing algorithms supported by the protected resource for signing resource responses.
76+
/// </summary>
77+
/// <value>
78+
/// A JSON array containing a list of the JWS signing algorithms (alg values) supported by the protected resource
79+
/// for signing resource responses.
80+
/// </value>
81+
/// <remarks>
82+
/// OPTIONAL. No default algorithms are implied if this entry is omitted. The value "none" MUST NOT be used.
83+
/// </remarks>
84+
[JsonPropertyName("resource_signing_alg_values_supported")]
85+
public List<string>? ResourceSigningAlgValuesSupported { get; set; }
86+
87+
/// <summary>
88+
/// Gets or sets the human-readable name of the protected resource intended for display to the end user.
89+
/// </summary>
90+
/// <remarks>
91+
/// RECOMMENDED. It is recommended that protected resource metadata include this field.
92+
/// The value of this field MAY be internationalized.
93+
/// </remarks>
94+
[JsonPropertyName("resource_name")]
95+
public string? ResourceName { get; set; }
96+
97+
/// <summary>
98+
/// Gets or sets the URI to the resource documentation.
99+
/// </summary>
100+
/// <value>
101+
/// The URL of a page containing human-readable information that developers might want or need to know
102+
/// when using the protected resource.
103+
/// </value>
104+
/// <remarks>
105+
/// OPTIONAL.
106+
/// </remarks>
107+
[JsonPropertyName("resource_documentation")]
108+
public string? ResourceDocumentation { get; set; }
109+
110+
/// <summary>
111+
/// Gets or sets the URL of a page containing human-readable information about the protected resource's requirements.
112+
/// </summary>
113+
/// <value>
114+
/// The URL of a page that contains information about how the client can use the data provided by the protected resource.
115+
/// </value>
116+
/// <remarks>
117+
/// OPTIONAL.
118+
/// </remarks>
119+
[JsonPropertyName("resource_policy_uri")]
120+
public string? ResourcePolicyUri { get; set; }
121+
122+
/// <summary>
123+
/// Gets or sets the URL of a page containing human-readable information about the protected resource's terms of service.
124+
/// </summary>
125+
/// <remarks>
126+
/// OPTIONAL. The value of this field MAY be internationalized.
127+
/// </remarks>
128+
[JsonPropertyName("resource_tos_uri")]
129+
public string? ResourceTosUri { get; set; }
130+
131+
/// <summary>
132+
/// Gets or sets a value indicating whether there is protected resource support for mutual-TLS client certificate-bound access tokens.
133+
/// </summary>
134+
/// <value>
135+
/// <see langword="true"/> if there's protected resource support for mutual-TLS client certificate-bound access tokens; otherwise, <see langword="false"/>. The default is <see langword="false"/>.
136+
/// </value>
137+
/// <remarks>
138+
/// OPTIONAL.
139+
/// </remarks>
140+
[JsonPropertyName("tls_client_certificate_bound_access_tokens")]
141+
public bool? TlsClientCertificateBoundAccessTokens { get; set; }
142+
143+
/// <summary>
144+
/// Gets or sets the list of the authorization details type values supported by the resource server.
145+
/// </summary>
146+
/// <value>
147+
/// A JSON array containing a list of the authorization details type values supported by the resource server
148+
/// when the authorization_details request parameter is used.
149+
/// </value>
150+
/// <remarks>
151+
/// OPTIONAL.
152+
/// </remarks>
153+
[JsonPropertyName("authorization_details_types_supported")]
154+
public List<string>? AuthorizationDetailsTypesSupported { get; set; }
155+
156+
/// <summary>
157+
/// Gets or sets the list of the JWS algorithm values supported by the resource server for validating DPoP proof JWTs.
158+
/// </summary>
159+
/// <value>
160+
/// A JSON array containing a list of the JWS alg values supported by the resource server
161+
/// for validating Demonstrating Proof of Possession (DPoP) proof JWTs.
162+
/// </value>
163+
/// <remarks>
164+
/// OPTIONAL.
165+
/// </remarks>
166+
[JsonPropertyName("dpop_signing_alg_values_supported")]
167+
public List<string>? DpopSigningAlgValuesSupported { get; set; }
168+
169+
/// <summary>
170+
/// Gets or sets a value indicating whether the protected resource always requires the use of DPoP-bound access tokens.
171+
/// </summary>
172+
/// <value>
173+
/// <see langword="true"/> if the protected resource always requires the use of DPoP-bound access tokens; otherwise, <see langword="false"/>. The default is <see langword="false"/>.
174+
/// </value>
175+
/// <remarks>
176+
/// OPTIONAL.
177+
/// </remarks>
178+
[JsonPropertyName("dpop_bound_access_tokens_required")]
179+
public bool? DpopBoundAccessTokensRequired { get; set; }
180+
51181
/// <summary>
52182
/// Used internally by the client to get or set the scope specified as a WWW-Authenticate header parameter.
53183
/// This should be preferred over using the ScopesSupported property.
@@ -73,7 +203,18 @@ public ProtectedResourceMetadata Clone(Uri? derivedResourceUri = null)
73203
{
74204
Resource = Resource ?? derivedResourceUri?.ToString(),
75205
AuthorizationServers = [.. AuthorizationServers],
206+
BearerMethodsSupported = [.. BearerMethodsSupported],
76207
ScopesSupported = [.. ScopesSupported],
208+
JwksUri = JwksUri,
209+
ResourceSigningAlgValuesSupported = ResourceSigningAlgValuesSupported is not null ? [.. ResourceSigningAlgValuesSupported] : null,
210+
ResourceName = ResourceName,
211+
ResourceDocumentation = ResourceDocumentation,
212+
ResourcePolicyUri = ResourcePolicyUri,
213+
ResourceTosUri = ResourceTosUri,
214+
TlsClientCertificateBoundAccessTokens = TlsClientCertificateBoundAccessTokens,
215+
AuthorizationDetailsTypesSupported = AuthorizationDetailsTypesSupported is not null ? [.. AuthorizationDetailsTypesSupported] : null,
216+
DpopSigningAlgValuesSupported = DpopSigningAlgValuesSupported is not null ? [.. DpopSigningAlgValuesSupported] : null,
217+
DpopBoundAccessTokensRequired = DpopBoundAccessTokensRequired
77218
};
78219
}
79220
}

tests/ModelContextProtocol.AspNetCore.Tests/OAuth/AuthEventTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public async Task ResourceMetadataEndpoint_CanModifyExistingMetadata_InEvent()
152152
if (context.ResourceMetadata != null)
153153
{
154154
context.ResourceMetadata.ScopesSupported.Add("mcp:tools");
155+
context.ResourceMetadata.ResourceName = "Dynamic Test Resource";
155156
}
156157
await Task.CompletedTask;
157158
};
@@ -178,6 +179,7 @@ public async Task ResourceMetadataEndpoint_CanModifyExistingMetadata_InEvent()
178179
Assert.Contains(OAuthServerUrl, metadata.AuthorizationServers);
179180
Assert.Contains("mcp:basic", metadata.ScopesSupported);
180181
Assert.Contains("mcp:tools", metadata.ScopesSupported);
182+
Assert.Equal("Dynamic Test Resource", metadata.ResourceName);
181183
}
182184

183185
[Fact]

0 commit comments

Comments
 (0)