MCPcopy
hub / github.com/github/github-mcp-server / routesForPattern

Method routesForPattern

pkg/http/oauth/oauth.go:151–166  ·  view source on GitHub ↗

routesForPattern generates route variants for a given pattern. GitHub strips the /mcp prefix before forwarding, so we register both variants: - With /mcp prefix: for direct access or when GitHub doesn't strip - Without /mcp prefix: for when GitHub has stripped the prefix

(pattern string)

Source from the content-addressed store, hash-verified

149// - With /mcp prefix: for direct access or when GitHub doesn't strip
150// - Without /mcp prefix: for when GitHub has stripped the prefix
151func (h *AuthHandler) routesForPattern(pattern string) []string {
152 basePaths := []string{""}
153 if basePath := normalizeBasePath(h.cfg.ResourcePath); basePath != "" {
154 basePaths = append(basePaths, basePath)
155 } else {
156 basePaths = append(basePaths, "/mcp")
157 }
158
159 routes := make([]string, 0, len(basePaths)*2)
160 for _, basePath := range basePaths {
161 routes = append(routes, joinRoute(basePath, pattern))
162 routes = append(routes, joinRoute(basePath, pattern)+"/")
163 }
164
165 return routes
166}
167
168// resolveResourcePath returns the externally visible resource path,
169// restoring the configured base path when proxies strip it before forwarding.

Callers 1

RegisterRoutesMethod · 0.95

Calls 2

normalizeBasePathFunction · 0.85
joinRouteFunction · 0.85

Tested by

no test coverage detected