-
Notifications
You must be signed in to change notification settings - Fork 715
chore: fix MCP endpoint routing and add OpenAPI documentation #8865
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Greptile Overview
Summary
Fixes MCP endpoint routing consistency and adds proper OpenAPI documentation.
Key Changes:
- Updated OAuth authorization server metadata endpoint path from
/{org_id}/.well-known/oauth-authorization-serverto/{org_id}/mcp/.well-known/oauth-authorization-serverto align with the/mcpprefix used by other MCP endpoints - Added rate limiting configuration to all MCP endpoints (both enterprise and non-enterprise versions) with
x-o2-ratelimitextension using module namemcp - Added three MCP endpoints to OpenAPI specification:
handle_mcp_post,handle_mcp_get, andoauth_authorization_server_metadata
Impact:
- Ensures consistent URL structure for all MCP endpoints under the
/mcpnamespace - Enables proper API documentation generation for MCP endpoints
- Applies rate limiting policy uniformly across MCP operations
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are straightforward and consist of: (1) a simple URL path update to add
/mcpprefix for consistency, (2) adding rate limiting configuration to all MCP endpoints, and (3) registering endpoints in OpenAPI specification. All changes are configuration-level with no logic modifications. The path change aligns the OAuth discovery endpoint with the existing MCP endpoint namespace, improving API consistency. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/handler/http/request/mcp/mod.rs | 5/5 | Fixed OAuth endpoint path from /{org_id}/.well-known/oauth-authorization-server to /{org_id}/mcp/.well-known/oauth-authorization-server and added rate limiting configuration with module name 'mcp' |
| src/handler/http/router/openapi.rs | 5/5 | Added MCP endpoints (handle_mcp_post, handle_mcp_get, oauth_authorization_server_metadata) to OpenAPI specification for documentation generation |
Sequence Diagram
sequenceDiagram
participant Client as MCP Client
participant API as API Gateway
participant Handler as MCP Handler
participant OAuth as OAuth Service
participant RateLimit as Rate Limiter
Note over Client,OAuth: OAuth Discovery
Client->>API: GET OAuth metadata endpoint
API->>RateLimit: Check rate limits (module: mcp)
RateLimit-->>API: Allowed
API->>OAuth: Get metadata
OAuth-->>API: OAuth configuration
API-->>Client: 200 OK
Note over Client,Handler: MCP POST Request
Client->>API: POST to MCP endpoint
API->>RateLimit: Check rate limits (module: mcp, operation: post)
RateLimit-->>API: Allowed
API->>Handler: handle_mcp_post()
Handler->>Handler: Validate auth token
Handler->>Handler: Process request
Handler-->>API: Response
API-->>Client: 200 OK
Note over Client,Handler: MCP GET Request
Client->>API: GET to MCP endpoint with JSON body
API->>RateLimit: Check rate limits (module: mcp, operation: get)
RateLimit-->>API: Allowed
API->>Handler: handle_mcp_get()
Handler->>Handler: Validate auth token
Handler->>Handler: Parse JSON and stream
Handler-->>API: SSE stream
API-->>Client: 200 OK (streaming)
2 files reviewed, no comments
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 342 | 0 | 19 | 4 | 94% | 5m 13s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 343 | 0 | 19 | 3 | 94% | 5m 13s |
- Fix .well-known/oauth-authorization-server endpoint to use /mcp prefix - Add MCP endpoints to OpenAPI spec - Add rate limiting configuration for all MCP endpoints with module name 'mcp'
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 343 | 0 | 19 | 3 | 94% | 5m 14s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 344 | 0 | 19 | 2 | 94% | 5m 23s |
User description
Summary
.well-known/oauth-authorization-serverendpoint to use/mcpprefixChanges
/{org_id}/.well-known/oauth-authorization-serverto/{org_id}/mcp/.well-known/oauth-authorization-serverhandle_mcp_post,handle_mcp_get, andoauth_authorization_server_metadatato OpenAPI pathsx-o2-ratelimitextensions to all MCP endpoint definitions (both enterprise and non-enterprise versions)PR Type
Enhancement, Documentation
Description
Add MCP rate limit OpenAPI extensions
Expose MCP handlers in OpenAPI router
Fix OAuth metadata endpoint path under MCP
Diagram Walkthrough
File Walkthrough
mod.rs
Rate limit annotations and MCP OAuth path fixsrc/handler/http/request/mcp/mod.rs
x-o2-ratelimitextensions to MCP endpoints./mcp/.well-known/....openapi.rs
Register MCP endpoints in OpenAPI routersrc/handler/http/router/openapi.rs
handle_mcp_post,handle_mcp_get, and OAuth metadata intoOpenAPI.