(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestExtractMCPServers(t *testing.T) { |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | input string |
| 29 | want []MCPServer |
| 30 | wantErr bool |
| 31 | }{ |
| 32 | { |
| 33 | name: "stdio server with command, args, and env", |
| 34 | input: `{ |
| 35 | "mcpServers": { |
| 36 | "filesystem": { |
| 37 | "command": "npx", |
| 38 | "args": ["-y", "@modelcontextprotocol/server-filesystem"], |
| 39 | "env": {"HOME": "/home/user", "API_KEY": "sk-secret-123"} |
| 40 | } |
| 41 | } |
| 42 | }`, |
| 43 | want: []MCPServer{ |
| 44 | { |
| 45 | Name: "filesystem", |
| 46 | Command: "npx", |
| 47 | Args: []string{"-y", "@modelcontextprotocol/server-filesystem"}, |
| 48 | EnvKeys: []string{"API_KEY", "HOME"}, |
| 49 | }, |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | name: "remote URL server", |
| 54 | input: `{ |
| 55 | "mcpServers": { |
| 56 | "remote": { |
| 57 | "url": "https://example.com/mcp" |
| 58 | } |
| 59 | } |
| 60 | }`, |
| 61 | want: []MCPServer{ |
| 62 | {Name: "remote", URL: "https://example.com/mcp"}, |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | name: "disabled server", |
| 67 | input: `{ |
| 68 | "mcpServers": { |
| 69 | "disabled-server": { |
| 70 | "command": "node", |
| 71 | "args": ["server.js"], |
| 72 | "disabled": true |
| 73 | } |
| 74 | } |
| 75 | }`, |
| 76 | want: []MCPServer{ |
| 77 | { |
| 78 | Name: "disabled-server", |
| 79 | Command: "node", |
| 80 | Args: []string{"server.js"}, |
| 81 | Disabled: true, |
| 82 | }, |
nothing calls this directly
no test coverage detected