(t *testing.T)
| 467 | } |
| 468 | |
| 469 | func TestParseMCPConfig(t *testing.T) { |
| 470 | tests := []struct { |
| 471 | name string |
| 472 | toolName string |
| 473 | mcpSection any |
| 474 | toolConfig map[string]any |
| 475 | expected RegistryMCPServerConfig |
| 476 | expectError bool |
| 477 | }{ |
| 478 | { |
| 479 | name: "Stdio with command and args", |
| 480 | toolName: "test-server", |
| 481 | mcpSection: map[string]any{ |
| 482 | "type": "stdio", |
| 483 | "command": "/usr/bin/server", |
| 484 | "args": []any{"--verbose", "--config=/etc/config.yml"}, |
| 485 | }, |
| 486 | toolConfig: map[string]any{}, |
| 487 | expected: RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "stdio", |
| 488 | Command: "/usr/bin/server", |
| 489 | Args: []string{"--verbose", "--config=/etc/config.yml"}, |
| 490 | Env: map[string]string{}, |
| 491 | Headers: map[string]string{}}, Name: "test-server", |
| 492 | |
| 493 | Allowed: []string{}, |
| 494 | }, |
| 495 | }, |
| 496 | { |
| 497 | name: "Stdio with container", |
| 498 | toolName: "docker-server", |
| 499 | mcpSection: map[string]any{ |
| 500 | "type": "stdio", |
| 501 | "container": "myregistry/server:latest", |
| 502 | "env": map[string]any{ |
| 503 | "DEBUG": "1", |
| 504 | "API_URL": "https://api.example.com", |
| 505 | }, |
| 506 | }, |
| 507 | toolConfig: map[string]any{}, |
| 508 | expected: RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "stdio", |
| 509 | Container: "myregistry/server:latest", |
| 510 | Command: "docker", |
| 511 | Args: []string{"run", "--rm", "-i", "-e", "DEBUG", "-e", "API_URL", "myregistry/server:latest"}, |
| 512 | Env: map[string]string{ |
| 513 | "DEBUG": "1", |
| 514 | "API_URL": "https://api.example.com", |
| 515 | }, |
| 516 | Headers: map[string]string{}}, Name: "docker-server", |
| 517 | |
| 518 | Allowed: []string{}, |
| 519 | }, |
| 520 | }, |
| 521 | { |
| 522 | name: "HTTP server", |
| 523 | toolName: "http-server", |
| 524 | mcpSection: map[string]any{ |
| 525 | "type": "http", |
| 526 | "url": "https://mcp.example.com/api", |
nothing calls this directly
no test coverage detected