import os import sys from importlib.metadata import version from pathlib import Path if os.name == "posix": os.umask(0o077) root = Path.home() / ".config" / "mcp-gsc" root.mkdir(mode=0o700, parents=True, exist_ok=True) if os.name == "posix": root.chmod(0o700) os.environ["GSC_CONFIG_DIR"] = str(root) os.environ["GSC_OAUTH_CLIENT_SECRETS_FILE"] = str( root / "oauth_client.json" ) os.environ["GSC_ALLOW_DESTRUCTIVE"] = "false" os.environ["GSC_DATA_STATE"] = "final" os.environ["MCP_TRANSPORT"] = "stdio" if version("mcp-search-console") != "0.4.1": raise RuntimeError("This launcher requires mcp-search-console==0.4.1") import gsc_server gsc_server.SCOPES = [ "https://www.googleapis.com/auth/webmasters.readonly" ] # This guide uses the explicitly configured OAuth account only. gsc_server.get_gsc_service = gsc_server.get_gsc_service_oauth for name in ( "add_site", "delete_site", "submit_sitemap", "delete_sitemap", "manage_sitemaps", ): gsc_server.mcp.remove_tool(name) # Upstream's static help text may advertise the removed mutation tools. if hasattr(gsc_server, "get_capabilities"): gsc_server.mcp.remove_tool("get_capabilities") if __name__ == "__main__": if "--login" in sys.argv: gsc_server.get_gsc_service() print("Credentials loaded. Next, verify property access and a report.") else: gsc_server.main()