The man was seen taking a picture of a window in Kerry's home by the diplomatic security guard for the top US diplomat, spokesman Glen Johnson said in a statement.
Kerry was out at the time visiting his wife, Teresa Heinz Kerry, who is undergoing treatment at the Spaulding Rehabilitation Hospital after suffering a seizure a week ago.
The diplomatic security staff called in the Boston police, who questioned the man and discovered the pellet gun in his car.