Skip to content

Commit f18c391

Browse files
Copilothalter73
andcommitted
Remove unused properties from ProtectedResourceMetadata
Per feedback, removed properties that are not used for client OAuth authentication: - BearerMethodsSupported - JwksUri - ResourceSigningAlgValuesSupported - ResourceName - ResourceDocumentation - ResourcePolicyUri - ResourceTosUri - TlsClientCertificateBoundAccessTokens - AuthorizationDetailsTypesSupported - DpopSigningAlgValuesSupported - DpopBoundAccessTokensRequired Kept only the properties necessary for OAuth client authentication: - Resource - AuthorizationServers - ScopesSupported - WwwAuthenticateScope (internal) Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
1 parent afb1ca7 commit f18c391

3 files changed

Lines changed: 0 additions & 144 deletions

File tree

samples/ProtectedMcpServer/Program.cs

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

src/ModelContextProtocol.Core/Authentication/ProtectedResourceMetadata.cs

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ 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-
5138
/// <summary>
5239
/// Gets or sets the supported scopes.
5340
/// </summary>
@@ -61,123 +48,6 @@ public sealed class ProtectedResourceMetadata
6148
[JsonPropertyName("scopes_supported")]
6249
public List<string> ScopesSupported { get; set; } = [];
6350

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-
18151
/// <summary>
18252
/// Used internally by the client to get or set the scope specified as a WWW-Authenticate header parameter.
18353
/// This should be preferred over using the ScopesSupported property.
@@ -203,18 +73,7 @@ public ProtectedResourceMetadata Clone(Uri? derivedResourceUri = null)
20373
{
20474
Resource = Resource ?? derivedResourceUri?.ToString(),
20575
AuthorizationServers = [.. AuthorizationServers],
206-
BearerMethodsSupported = [.. BearerMethodsSupported],
20776
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
21877
};
21978
}
22079
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ 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";
156155
}
157156
await Task.CompletedTask;
158157
};
@@ -179,7 +178,6 @@ public async Task ResourceMetadataEndpoint_CanModifyExistingMetadata_InEvent()
179178
Assert.Contains(OAuthServerUrl, metadata.AuthorizationServers);
180179
Assert.Contains("mcp:basic", metadata.ScopesSupported);
181180
Assert.Contains("mcp:tools", metadata.ScopesSupported);
182-
Assert.Equal("Dynamic Test Resource", metadata.ResourceName);
183181
}
184182

185183
[Fact]

0 commit comments

Comments
 (0)