-
-
Notifications
You must be signed in to change notification settings - Fork 508
Align MCP server with the 2026-07-28 specification #2454
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
base: feature/exie-assistant
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,12 +28,10 @@ public class OAuthService(OAuthServerOptions options, ICacheClient cacheClient, | |
| AuthorizationRoles.ProjectsRead, | ||
| AuthorizationRoles.StacksRead, | ||
| AuthorizationRoles.StacksWrite, | ||
| AuthorizationRoles.EventsRead, | ||
| AuthorizationRoles.OfflineAccess | ||
| AuthorizationRoles.EventsRead | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
BLOCKER: Existing clients that construct authorization requests from the MCP protected-resource metadata will stop requesting AGENTS.md reference: AGENTS.md:L67-L67 Useful? React with 👍 / 👎. |
||
| ], | ||
| [ | ||
| AuthorizationRoles.McpRead, | ||
| AuthorizationRoles.OfflineAccess | ||
| AuthorizationRoles.McpRead | ||
| ]); | ||
|
|
||
| public static readonly OAuthResourceDefinition RestApiResource = new("/api/v2", | ||
|
|
@@ -242,6 +240,9 @@ private bool TryCreateObservedApplication(string clientId, OAuthClientMetadataDo | |
| if (!String.Equals(metadata.ClientId, clientId, StringComparison.Ordinal)) | ||
| return false; | ||
|
|
||
| if (String.IsNullOrWhiteSpace(metadata.ClientName)) | ||
| return false; | ||
|
|
||
| if (metadata.GrantTypes is { Length: > 0 } && !metadata.GrantTypes.Contains(OAuthGrantTypes.AuthorizationCode, StringComparer.Ordinal)) | ||
| return false; | ||
|
|
||
|
|
@@ -251,15 +252,12 @@ private bool TryCreateObservedApplication(string clientId, OAuthClientMetadataDo | |
| if (!String.IsNullOrWhiteSpace(metadata.TokenEndpointAuthMethod) && !String.Equals(metadata.TokenEndpointAuthMethod, "none", StringComparison.Ordinal)) | ||
| return false; | ||
|
|
||
| string[] redirectUris = metadata.RedirectUris? | ||
| .Where(OAuthApplication.IsValidRedirectUri) | ||
| .Distinct(StringComparer.Ordinal) | ||
| .Take(20) | ||
| .ToArray() ?? []; | ||
|
|
||
| if (redirectUris.Length == 0) | ||
| if (metadata.RedirectUris is not { Length: > 0 and <= 20 } | ||
| || metadata.RedirectUris.Any(uri => !OAuthApplication.IsValidRedirectUri(uri))) | ||
| return false; | ||
|
|
||
| string[] redirectUris = metadata.RedirectUris.Distinct(StringComparer.Ordinal).ToArray(); | ||
|
|
||
| var metadataScopes = NormalizeScopes(metadata.Scope); | ||
| string[] scopes = metadataScopes.Count > 0 | ||
| ? metadataScopes.Where(s => SupportedScopes.Contains(s, StringComparer.Ordinal)).Distinct(StringComparer.Ordinal).ToArray() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using Exceptionless.Core; | ||
| using Exceptionless.Core.Services; | ||
| using Microsoft.Net.Http.Headers; | ||
|
|
||
| namespace Exceptionless.Web.Mcp; | ||
|
|
||
| public sealed class McpOriginValidationMiddleware(RequestDelegate next, AppOptions appOptions) | ||
| { | ||
| private readonly string _canonicalOrigin = new Uri(appOptions.BaseURL).GetLeftPart(UriPartial.Authority); | ||
|
|
||
| public async Task InvokeAsync(HttpContext context) | ||
| { | ||
| if (!context.Request.Path.StartsWithSegments(new PathString(OAuthService.McpResource.Path), StringComparison.OrdinalIgnoreCase) | ||
| || !context.Request.Headers.TryGetValue(HeaderNames.Origin, out var origins)) | ||
| { | ||
| await next(context); | ||
| return; | ||
| } | ||
|
|
||
| if (origins.Count != 1 || !IsAllowedOrigin(origins[0], _canonicalOrigin)) | ||
| { | ||
| context.Response.StatusCode = StatusCodes.Status403Forbidden; | ||
| return; | ||
| } | ||
|
|
||
| await next(context); | ||
| } | ||
|
|
||
| internal static bool IsAllowedOrigin(string? origin, string canonicalOrigin) | ||
| { | ||
| if (String.IsNullOrWhiteSpace(origin) | ||
| || !Uri.TryCreate(origin, UriKind.Absolute, out var originUri) | ||
| || !String.IsNullOrEmpty(originUri.UserInfo) | ||
| || !String.IsNullOrEmpty(originUri.Query) | ||
| || !String.IsNullOrEmpty(originUri.Fragment) | ||
| || !String.Equals(originUri.AbsolutePath, "/", StringComparison.Ordinal)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return String.Equals(originUri.GetLeftPart(UriPartial.Authority), canonicalOrigin, StringComparison.OrdinalIgnoreCase); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a metadata server returns a shared-cache directive such as
Cache-Control: s-maxage=0, max-age=3600, thisICacheClientcache usesmax-ageand retains the document for an hour even thoughs-maxageforbids shared reuse; if onlys-maxageis present, it instead falls back to the configured lifetime. Because production can back this cache with Redis, stale redirect URIs and scopes can be reused across requests and instances beyond the client's requested freshness window; preferSharedMaxAgewhen it is present.Useful? React with 👍 / 👎.