@@ -550,6 +550,48 @@ cors:
550
550
- **Development** (`debug=true`): Permissive origin validation for easy testing
551
551
- **Production** (`debug=false`): Strict origin validation with localhost fallback for debugging
552
552
553
+ # ## Browser Client Configuration
554
+
555
+ For browser-based MCP clients, configure CORS to expose necessary headers :
556
+
557
+ **Basic Browser Support:**
558
+ ` ` ` yaml
559
+ cors:
560
+ allow_origins: ["https://your-web-app.com"]
561
+ allow_credentials: true
562
+ expose_headers: [] # Empty by default
563
+ ` ` `
564
+
565
+ **Advanced Browser Configuration:**
566
+ ` ` ` yaml
567
+ cors:
568
+ allow_origins: ["https://your-web-app.com"]
569
+ allow_credentials: true
570
+ allow_methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
571
+ allow_headers: ["Authorization", "Content-Type", "MCP-Protocol-Version"]
572
+ expose_headers: # Headers browser clients can access
573
+ - "MCP-Session-ID" # For session persistence
574
+ - "X-Request-ID" # For request tracking
575
+ - "X-Rate-Limit-Remaining" # For usage display
576
+ - "X-Custom-Header" # Your custom headers
577
+ ` ` `
578
+
579
+ **What `expose_headers` Does:**
580
+ - By default, browsers can only access basic headers (Content-Type, etc.)
581
+ - ` expose_headers` allows JavaScript to read custom response headers
582
+ - Essential for MCP clients that need session IDs or request tracking
583
+
584
+ **Browser Client Example:**
585
+ ` ` ` javascript
586
+ // Without expose_headers, these return null:
587
+ const sessionId = response.headers.get('MCP-Session-ID'); // null
588
+ const requestId = response.headers.get('X-Request-ID'); // null
589
+
590
+ // With expose_headers configured, these work:
591
+ const sessionId = response.headers.get('MCP-Session-ID'); // "session-123"
592
+ const requestId = response.headers.get('X-Request-ID'); // "req-456"
593
+ ` ` `
594
+
553
595
# ## Adding New MCP Services
554
596
555
597
1. **Configure the service** in `config.yaml` :
0 commit comments