Skip to content

Commit fe7ecba

Browse files
committed
Add support for missed CORS headers and update tests
1 parent c9573f2 commit fe7ecba

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

pkg/http/handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,15 @@ func SetCorsHeaders(h http.Handler) http.Handler {
427427
w.Header().Set("Access-Control-Max-Age", "86400")
428428
w.Header().Set("Access-Control-Expose-Headers", "Mcp-Session-Id")
429429
w.Header().Set("Access-Control-Allow-Headers", fmt.Sprintf(
430-
"Content-Type, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID, %s, %s, %s, %s, %s, %s",
430+
"Content-Type, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID, %s, %s, %s, %s, %s, %s, %s, %s",
431431
headers.AuthorizationHeader,
432432
headers.MCPReadOnlyHeader,
433433
headers.MCPToolsetsHeader,
434434
headers.MCPToolsHeader,
435435
headers.MCPExcludeToolsHeader,
436436
headers.MCPFeaturesHeader,
437+
headers.MCPLockdownHeader,
438+
headers.MCPInsidersHeader,
437439
))
438440

439441
if r.Method == http.MethodOptions {

pkg/http/handler_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ func TestSetCorsHeaders(t *testing.T) {
680680
assert.Contains(t, rr.Header().Get("Access-Control-Allow-Headers"), "Authorization")
681681
assert.Contains(t, rr.Header().Get("Access-Control-Allow-Headers"), "Content-Type")
682682
assert.Contains(t, rr.Header().Get("Access-Control-Allow-Headers"), "Mcp-Session-Id")
683+
assert.Contains(t, rr.Header().Get("Access-Control-Allow-Headers"), "X-MCP-Lockdown")
684+
assert.Contains(t, rr.Header().Get("Access-Control-Allow-Headers"), "X-MCP-Insiders")
683685
assert.Contains(t, rr.Header().Get("Access-Control-Expose-Headers"), "Mcp-Session-Id")
684686
})
685687

@@ -782,17 +784,6 @@ func TestCrossOriginProtection(t *testing.T) {
782784
secFetchSite: "",
783785
expectedStatusCode: http.StatusOK,
784786
},
785-
{
786-
name: "bypass allows cross-site request (same pattern RunHTTPServer applies for nil config)",
787-
crossOriginProtection: func() *http.CrossOriginProtection {
788-
p := http.NewCrossOriginProtection()
789-
p.AddInsecureBypassPattern("/")
790-
return p
791-
}(),
792-
secFetchSite: "cross-site",
793-
origin: "https://example.com",
794-
expectedStatusCode: http.StatusOK,
795-
},
796787
}
797788

798789
for _, tt := range tests {

0 commit comments

Comments
 (0)