writeMCPConfig writes a .mcp.json file with the given server entries. Each entry maps a server name to its config.
(t *testing.T, dir string, servers map[string]mcpServerEntry)
| 22 | // writeMCPConfig writes a .mcp.json file with the given server |
| 23 | // entries. Each entry maps a server name to its config. |
| 24 | func writeMCPConfig(t *testing.T, dir string, servers map[string]mcpServerEntry) string { |
| 25 | t.Helper() |
| 26 | path := filepath.Join(dir, ".mcp.json") |
| 27 | cfg := mcpConfigFile{MCPServers: make(map[string]json.RawMessage)} |
| 28 | for name, entry := range servers { |
| 29 | raw, err := json.Marshal(entry) |
| 30 | require.NoError(t, err) |
| 31 | cfg.MCPServers[name] = raw |
| 32 | } |
| 33 | data, err := json.Marshal(cfg) |
| 34 | require.NoError(t, err) |
| 35 | err = os.WriteFile(path, data, 0o600) |
| 36 | require.NoError(t, err) |
| 37 | return path |
| 38 | } |
| 39 | |
| 40 | // fakeMCPServerConfig returns a ServerConfig that launches a fake |
| 41 | // MCP server using the test binary re-exec pattern. |
no test coverage detected