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

Function TestHTTPHandlerRoutes

pkg/http/handler_test.go:192–419  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func TestHTTPHandlerRoutes(t *testing.T) {
193 tools := testTools()
194
195 tests := []struct {
196 name string
197 path string
198 headers map[string]string
199 expectedTools []string
200 }{
201 {
202 name: "root path returns all tools",
203 path: "/",
204 expectedTools: []string{"get_file_contents", "create_repository", "list_issues", "create_issue", "list_pull_requests", "create_pull_request", "hidden_by_holdback"},
205 },
206 {
207 name: "readonly path filters write tools",
208 path: "/readonly",
209 expectedTools: []string{"get_file_contents", "list_issues", "list_pull_requests", "hidden_by_holdback"},
210 },
211 {
212 name: "toolset path filters to toolset",
213 path: "/x/repos",
214 expectedTools: []string{"get_file_contents", "create_repository", "hidden_by_holdback"},
215 },
216 {
217 name: "toolset path with issues",
218 path: "/x/issues",
219 expectedTools: []string{"list_issues", "create_issue"},
220 },
221 {
222 name: "toolset readonly path filters to readonly tools in toolset",
223 path: "/x/repos/readonly",
224 expectedTools: []string{"get_file_contents", "hidden_by_holdback"},
225 },
226 {
227 name: "toolset readonly path with issues",
228 path: "/x/issues/readonly",
229 expectedTools: []string{"list_issues"},
230 },
231 {
232 name: "X-MCP-Tools header filters to specific tools",
233 path: "/",
234 headers: map[string]string{
235 headers.MCPToolsHeader: "list_issues",
236 },
237 expectedTools: []string{"list_issues"},
238 },
239 {
240 name: "X-MCP-Tools header with multiple tools",
241 path: "/",
242 headers: map[string]string{
243 headers.MCPToolsHeader: "list_issues,get_file_contents",
244 },
245 expectedTools: []string{"list_issues", "get_file_contents"},
246 },
247 {
248 name: "X-MCP-Tools header does not expose extra tools",
249 path: "/",

Callers

nothing calls this directly

Calls 15

NewAPIHostFunction · 0.92
NewBuilderFunction · 0.92
testToolsFunction · 0.85
NewHTTPMcpHandlerFunction · 0.85
WithInventoryFactoryFunction · 0.85
WithScopeFetcherFunction · 0.85
extractToolNamesFunction · 0.85
WithFeatureCheckerMethod · 0.80
WithToolsetsMethod · 0.80
SetToolsMethod · 0.80

Tested by

no test coverage detected