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

Method RegisterRoutes

pkg/http/handler.go:143–155  ·  view source on GitHub ↗

RegisterRoutes registers the routes for the MCP server URL-based values take precedence over header-based values

(r chi.Router)

Source from the content-addressed store, hash-verified

141// RegisterRoutes registers the routes for the MCP server
142// URL-based values take precedence over header-based values
143func (h *Handler) RegisterRoutes(r chi.Router) {
144 // Base routes
145 r.Mount("/", h)
146 r.With(withReadonly).Mount("/readonly", h)
147 r.With(withInsiders).Mount("/insiders", h)
148 r.With(withReadonly, withInsiders).Mount("/readonly/insiders", h)
149
150 // Toolset routes
151 r.With(withToolset).Mount("/x/{toolset}", h)
152 r.With(withToolset, withReadonly).Mount("/x/{toolset}/readonly", h)
153 r.With(withToolset, withInsiders).Mount("/x/{toolset}/insiders", h)
154 r.With(withToolset, withReadonly, withInsiders).Mount("/x/{toolset}/readonly/insiders", h)
155}
156
157// withReadonly is middleware that sets readonly mode in the request context
158func withReadonly(next http.Handler) http.Handler {

Callers 5

RunHTTPServerFunction · 0.45
TestHTTPHandlerRoutesFunction · 0.45
TestContentTypeHandlingFunction · 0.45

Calls

no outgoing calls

Tested by 4

TestHTTPHandlerRoutesFunction · 0.36
TestContentTypeHandlingFunction · 0.36