McCain said he is guardedly optimistic that officials can agree on a government within weeks .