(t *testing.T)
| 419 | } |
| 420 | |
| 421 | func TestStaticConfigEnforcement(t *testing.T) { |
| 422 | // Use default toolsets to match real-world behavior where repos/issues/pull_requests are defaults |
| 423 | tools := []inventory.ServerTool{ |
| 424 | mockToolFull("get_file_contents", "repos", true, true), |
| 425 | mockToolFull("create_repository", "repos", false, true), |
| 426 | mockToolFull("list_issues", "issues", true, true), |
| 427 | mockToolFull("create_issue", "issues", false, true), |
| 428 | mockToolFull("list_pull_requests", "pull_requests", true, true), |
| 429 | mockToolFull("create_pull_request", "pull_requests", false, true), |
| 430 | mockToolWithFeatureFlag("hidden_by_holdback", "repos", true, "", "mcp_holdback_consolidated_projects"), |
| 431 | } |
| 432 | |
| 433 | tests := []struct { |
| 434 | name string |
| 435 | config *ServerConfig |
| 436 | path string |
| 437 | headers map[string]string |
| 438 | expectedTools []string |
| 439 | }{ |
| 440 | { |
| 441 | name: "no static config preserves existing behavior", |
| 442 | config: &ServerConfig{Version: "test"}, |
| 443 | path: "/", |
| 444 | expectedTools: []string{"get_file_contents", "create_repository", "list_issues", "create_issue", "list_pull_requests", "create_pull_request", "hidden_by_holdback"}, |
| 445 | }, |
| 446 | { |
| 447 | name: "static read-only filters write tools", |
| 448 | config: &ServerConfig{Version: "test", ReadOnly: true}, |
| 449 | path: "/", |
| 450 | expectedTools: []string{"get_file_contents", "list_issues", "list_pull_requests", "hidden_by_holdback"}, |
| 451 | }, |
| 452 | { |
| 453 | name: "static read-only cannot be overridden by header", |
| 454 | config: &ServerConfig{Version: "test", ReadOnly: true}, |
| 455 | path: "/", |
| 456 | headers: map[string]string{ |
| 457 | headers.MCPReadOnlyHeader: "false", |
| 458 | }, |
| 459 | expectedTools: []string{"get_file_contents", "list_issues", "list_pull_requests", "hidden_by_holdback"}, |
| 460 | }, |
| 461 | { |
| 462 | name: "static toolsets restricts available tools", |
| 463 | config: &ServerConfig{Version: "test", EnabledToolsets: []string{"repos"}}, |
| 464 | path: "/", |
| 465 | expectedTools: []string{"get_file_contents", "create_repository", "hidden_by_holdback"}, |
| 466 | }, |
| 467 | { |
| 468 | name: "static toolsets cannot be expanded by header", |
| 469 | config: &ServerConfig{Version: "test", EnabledToolsets: []string{"repos"}}, |
| 470 | path: "/", |
| 471 | headers: map[string]string{ |
| 472 | headers.MCPToolsetsHeader: "issues", |
| 473 | }, |
| 474 | // Header asks for "issues" but only "repos" tools exist in the static universe |
| 475 | expectedTools: []string{}, |
| 476 | }, |
| 477 | { |
| 478 | name: "per-request header can narrow within static toolset bounds", |
nothing calls this directly
no test coverage detected