Verificando acesso...

MÓDULO 3.3

🌐 Cloudflare Tunnel — Mac vira API pública

Arquitetura definitiva: CLI local, MCP server na máquina, tunnel HTTPS, qualquer agente cloud conecta.

1

🏛️ Por que tunnel vence cookie inline

Antes: embedavam cookie em skill. Google rotacionava token → quebra. Agora: CLI fica na sua máquina, tunnel expõe via HTTPS. Credenciais nunca saem do Mac. Estado da arte.

2

📐 Arquitetura ponta a ponta

Cloud agent (Cowork/Claude)
        ↓ MCP via SSE HTTPS
Cloudflare Tunnel (mcp-x.yourdomain.com)
        ↓
Mac local — localhost:8484
        ↓
FastMCP Python server
        ↓
notebooklm CLI → Google NotebookLM
3

🐍 FastMCP server em 50 linhas

Python script com @mcp.tool() por comando. Stdio local, SSE remoto. Smoke test rápido.

from mcp.server.fastmcp import FastMCP
mcp = FastMCP("notebooklm", host="0.0.0.0", port=8484)

@mcp.tool()
def notebooklm_ask(question: str) -> str:
    """RAG query no notebook atual."""
    return run_cli("ask", question, timeout=120)

if __name__ == "__main__":
    mcp.run(transport="sse")
4

🌥️ Cloudflared setup

brew install cloudflared
cloudflared tunnel login
cloudflared tunnel create notebooklm-mcp
cloudflared tunnel route dns notebooklm-mcp mcp.yourdomain.com
5

♻️ Launch Agents — auto-start

Dois plists em ~/Library/LaunchAgents/: server + tunnel. KeepAlive=true. Mac reinicia, tudo volta sozinho.

6

🩺 Troubleshooting

SintomaFix
Auth expirounotebooklm login local (sem restart)
Server não respondelsof -i :8484 + launchctl kickstart
Tunnel downcloudflared tunnel info notebooklm-mcp
Cliente sem conectarcurl https://mcp.dom/sse | head -3

✅ Resumo

Tunnel substitui cookie inline
Cloud → tunnel → Mac → CLI → Google
FastMCP em 50 linhas
cloudflared sem abrir porta no router
Launch Agents = boot automático
Troubleshooting estruturado