Skip to content

feat: add CORS support for HTTP transport mode#78

Open
heroyin wants to merge 1 commit intoapache:masterfrom
heroyin:feature/add-cors-support
Open

feat: add CORS support for HTTP transport mode#78
heroyin wants to merge 1 commit intoapache:masterfrom
heroyin:feature/add-cors-support

Conversation

@heroyin
Copy link

@heroyin heroyin commented Mar 24, 2026

Summary

  • Add CORS middleware to both main.py (DorisServer HTTP mode) and multiworker_app.py to enable cross-origin requests from browser-based MCP clients
  • Handle CORS preflight OPTIONS requests with proper headers
  • Inject CORS headers (Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Expose-Headers) into all responses via a custom send_with_cors wrapper

Motivation

Browser-based MCP clients (e.g., web dashboards, Dify integration) cannot directly communicate with the Doris MCP Server due to CORS restrictions. This change enables cross-origin access for the HTTP transport mode, making it possible to use the server from any web origin.

Changes

  • doris_mcp_server/main.py: Added CORSMiddleware to the Starlette app, OPTIONS preflight handling, and CORS header injection via send wrapper
  • doris_mcp_server/multiworker_app.py: Added CORSMiddleware to the multi-worker basic_app

Test plan

  • Verify CORS preflight OPTIONS requests return proper headers
  • Verify cross-origin POST/GET requests succeed from a browser
  • Verify existing MCP client functionality is not affected
  • Verify stdio transport mode is not affected

🤖 Generated with Claude Code

Add CORS middleware to both main.py (DorisServer) and multiworker_app.py
to allow cross-origin requests from browser-based MCP clients. Handles
preflight OPTIONS requests and injects CORS headers into all responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant