Ah, now this is really a dodgy one. According to UNCLOS (the UN Law of the Sea Convention) you have the right to free passage through another states territorial (but not inner) waters. There are special rules for archipelagic states.
What free passage gives you is the right to do is steam / sail / motor through another states waters without stopping, conducting any form of activity other than taking the ship through the waters (i.e. no fishing, surveying, dredging etc.). It does not give you the right to anchor in their waters, although this sometimes happens and, in most cases, there is no great fuss made about it if the reason for anchoring is force majeure. This includes essential engine repairs, sheltering from heavy weather etc. but the condition always is that there is no contact with the shore whatsoever. You are not allowed to put a boat in the water and you are not allowed to receive visitors or pass gifts, parcels or mails to anyone.
If you are not forced to anchor but simply want to do so then you should contact the coastal states authorities and explain that to them. DO NOT USE THE Q FLAG! The signal indicates not only that your vessel is healthy but that you are requesting free pratique which means that you want to enter port and conduct your business.
If you are entering inner waters then the normal rules for entering the country apply. Inner waters are usually defined as waters inside the base line, a base line being an imaginary line lining the coastal states outermost rocks, islands and skerries not continuously awash. I assume that you do want to enter the islands inner waters to have a little relaxation in a sheltered bay. In that case, contact the authorities, tell them you wish to anchor there but will have no contact with the shore and request them to give you permission to do so without clearing the vessel into the country.
Good luck with your voyage // Stephen