Skip to content

Commit 97092a0

Browse files
committed
remove CAPI specific header
1 parent 37c32c5 commit 97092a0

File tree

3 files changed

+15
-36
lines changed

3 files changed

+15
-36
lines changed

pkg/http/headers/headers.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ const (
2626
// ForwardedProtoHeader is a standard HTTP Header for preserving the original protocol when proxying.
2727
ForwardedProtoHeader = "X-Forwarded-Proto"
2828

29-
// OriginalPathHeader is set to preserve the original request path
30-
// before the /mcp prefix was stripped during proxying.
31-
OriginalPathHeader = "X-GitHub-Original-Path"
32-
3329
// RequestHmacHeader is used to authenticate requests to the Raw API.
3430
RequestHmacHeader = "Request-Hmac"
3531

pkg/http/oauth/oauth.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,10 @@ func (h *AuthHandler) routesForPattern(pattern string) []string {
132132
}
133133

134134
// GetEffectiveResourcePath returns the resource path for OAuth protected resource URLs.
135-
// It checks for the X-GitHub-Original-Path header set by GitHub, which contains
136-
// the exact path the client requested before the /mcp prefix was stripped.
137-
// If the header is not present, it falls back to
138-
// restoring the /mcp prefix.
135+
// It uses the request's URL path directly. For deployments where a prefix like /mcp
136+
// is stripped by a proxy, the proxy should set the BaseURL config appropriately.
139137
func GetEffectiveResourcePath(r *http.Request) string {
140-
// Check for the original path header from GitHub (preferred method)
141-
if originalPath := r.Header.Get(headers.OriginalPathHeader); originalPath != "" {
142-
return originalPath
143-
}
144-
145-
// Fallback: GitHub strips /mcp prefix, so we need to restore it for the external URL
146-
if r.URL.Path == "/" {
147-
return "/mcp"
148-
}
149-
return "/mcp" + r.URL.Path
138+
return r.URL.Path
150139
}
151140

152141
// GetProtectedResourceData builds the OAuth protected resource data for a request.

pkg/http/oauth/oauth_test.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,38 +185,32 @@ func TestGetEffectiveResourcePath(t *testing.T) {
185185
expectedPath string
186186
}{
187187
{
188-
name: "root path without original path header",
188+
name: "root path",
189189
setupRequest: func() *http.Request {
190-
req := httptest.NewRequest(http.MethodGet, "/", nil)
191-
return req
190+
return httptest.NewRequest(http.MethodGet, "/", nil)
192191
},
193-
expectedPath: "/mcp",
192+
expectedPath: "/",
194193
},
195194
{
196-
name: "non-root path without original path header",
195+
name: "mcp path",
197196
setupRequest: func() *http.Request {
198-
req := httptest.NewRequest(http.MethodGet, "/readonly", nil)
199-
return req
197+
return httptest.NewRequest(http.MethodGet, "/mcp", nil)
200198
},
201-
expectedPath: "/mcp/readonly",
199+
expectedPath: "/mcp",
202200
},
203201
{
204-
name: "with X-GitHub-Original-Path header",
202+
name: "readonly path",
205203
setupRequest: func() *http.Request {
206-
req := httptest.NewRequest(http.MethodGet, "/readonly", nil)
207-
req.Header.Set(headers.OriginalPathHeader, "/mcp/x/repos/readonly")
208-
return req
204+
return httptest.NewRequest(http.MethodGet, "/readonly", nil)
209205
},
210-
expectedPath: "/mcp/x/repos/readonly",
206+
expectedPath: "/readonly",
211207
},
212208
{
213-
name: "original path header takes precedence",
209+
name: "nested path",
214210
setupRequest: func() *http.Request {
215-
req := httptest.NewRequest(http.MethodGet, "/something-else", nil)
216-
req.Header.Set(headers.OriginalPathHeader, "/mcp/custom/path")
217-
return req
211+
return httptest.NewRequest(http.MethodGet, "/mcp/x/repos", nil)
218212
},
219-
expectedPath: "/mcp/custom/path",
213+
expectedPath: "/mcp/x/repos",
220214
},
221215
}
222216

0 commit comments

Comments
 (0)