Servidor MCP (Model Context Protocol) con transporte Streamable HTTP que expone la API de GoHighLevel (LeadConnector) como herramientas para clientes MCP (Claude, Cursor, etc.).
POST https://LUFI--4f1d57546b8911f1bdc51607ee4eb77e.web.val.run/mcp
Conecta cualquier cliente MCP a esa URL /mcp. El servidor funciona en modo
stateless (un servidor MCP nuevo por petición), ideal para entornos serverless.
El PIT de GHL vive solo aquí. Los demás sistemas (GitHub Actions, scripts) lo piden en tiempo de ejecución en vez de guardar su propia copia, así rotarlo en este val arregla todo de una vez.
GET /salud
Público, no revela el token: dice si cada PIT sigue vivo.
200 si ambos responden, 503 si alguno falla.
GET /token?loc=ladys -H "x-torre-key: $TORRE_KEY"
GET /token?loc=topkreativa -H "x-torre-key: $TORRE_KEY"
Devuelve { locationId, token }. Requiere la variable de entorno TORRE_KEY;
sin ella la ruta responde 503 y queda cerrada.
👉 Add TORRE_KEY here: https://www.val.town/x/LUFI/ghl-mcp/environment-variables?key=TORRE_KEY
Ejemplo en un workflow de GitHub Actions:
- name: Obtener PIT de GHL desde el val run: | TOKEN=$(curl -sf -H "x-torre-key: ${{ secrets.TORRE_KEY }}" \ "https://LUFI--4f1d57546b8911f1bdc51607ee4eb77e.web.val.run/token?loc=ladys" \ | python3 -c "import sys,json;print(json.load(sys.stdin)['token'])") echo "::add-mask::$TOKEN" echo "GHL_PIT_TOKEN=$TOKEN" >> "$GITHUB_ENV"
| Herramienta | Descripción |
|---|---|
search_contacts | Busca contactos por texto libre (query, locationId, limit). |
get_contact | Obtiene un contacto por contactId. |
create_contact | Crea un contacto (firstName, lastName, email, phone, tags…). |
send_whatsapp_message | Envía un WhatsApp a un contacto (contactId, message, templateId?). |
list_whatsapp_templates | Lista las plantillas de WhatsApp de una location. |
El locationId por defecto es o1V9sCKjH5Ywd9PRURj0 y puede sobrescribirse en
cada llamada.
Requiere la variable de entorno GHL_API_KEY — una clave de Private
Integrations de GoHighLevel (Settings → Integrations → Private Integrations),
no una API key normal.
👉 Add GHL_API_KEY here: https://www.val.town/x/LUFI/ghl-mcp/environment-variables?key=GHL_API_KEY
Rendering mermaid diagram...
main.ts— servidor HTTP + transporte Streamable HTTP del MCP.tools.ts— definición de las 5 herramientas MCP con esquemas Zod.ghl.ts— cliente de la API de GoHighLevel.
# Listar herramientas curl -X POST https://LUFI--4f1d57546b8911f1bdc51607ee4eb77e.web.val.run/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' # Buscar contactos curl -X POST https://LUFI--4f1d57546b8911f1bdc51607ee4eb77e.web.val.run/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_contacts","arguments":{"query":"juan","limit":5}}}'