130 lines
6.1 KiB
Markdown
130 lines
6.1 KiB
Markdown
# Hermes-MCP Auth & Email Relay Fix — 2026-05-19
|
|
|
|
## Session Overview
|
|
Fixed multiple critical infrastructure issues affecting SquareMCP authentication and email delivery.
|
|
|
|
---
|
|
|
|
## Problems Found & Fixed
|
|
|
|
### 1. Claude.ai / ChatGPT.com OAuth Failed
|
|
**Root cause:** Host Redis at `127.0.0.1:6379` accepted TCP connections but never responded to commands. Every `await redis.get()` hung forever, blocking Bearer token auth in `getTokenCustomer()`.
|
|
|
|
**Fixes deployed (commit `da40584`):**
|
|
- `src/redis.ts` — switched to K8s Redis (`redis://:redis_secure_2024@10.152.183.80:6379`) with 3s connect timeout + 5s socket timeout
|
|
- `src/index.ts` — added `https://claude.ai`, `https://chatgpt.com`, `https://chat.openai.com` to CORS allowed origins
|
|
- `hermes-k8s.yaml` — updated image SHA and Redis URL env var
|
|
|
|
**Result:** OAuth PKCE flow now works end-to-end. Bearer token auth to `/mcp` returns 200.
|
|
|
|
### 2. Alex Ferrari Demo Email Never Sent
|
|
**Root cause:** Previous session marked email as "sent" but it never actually went out. Sent folder on mail server had only 1 test email.
|
|
|
|
**Fix:** Resent demo invite via Azure ACS SMTP directly. Email delivered to Gmail with SPF=PASS, DKIM=PASS, DMARC=PASS.
|
|
|
|
### 3. Poste.io Webmail Not Delivering
|
|
**Root causes:**
|
|
1. Hosting provider blocks outbound port 25 (common on cloud VPS)
|
|
2. Poste.io smarthost relay configured in UI but pod never restarted — config never took effect
|
|
3. **nftables nat PREROUTING was redirecting ALL port 587 traffic back to localhost**, regardless of destination IP. This was from a NodePort/Docker port mapping rule that was too broad:
|
|
```
|
|
tcp dport 587 counter redirect to :30587
|
|
```
|
|
Outbound mail from the pod to `smtp.azurecomm.net:587` was being hijacked and redirected to the local Poste.io service, creating a loop.
|
|
|
|
**Fixes applied:**
|
|
- Configured Poste.io smarthost relay in `/opt/email-data/server.ini`:
|
|
- Host: `smtp.azurecomm.net`
|
|
- Port: `587`
|
|
- Auth: `fetcherpay-comm-prod.628d0126-984a-436a-8920-fcc877f5481a.57af0299-f395-4cf7-8fc5-3017211b2879` / `5SH8Q~aPvVVvFeSoXAfPB0MhDqNny_AwmjeQLbXf`
|
|
- Restarted Poste.io pod to pick up config
|
|
- Fixed nftables nat PREROUTING to only redirect when destination is local:
|
|
```
|
|
nft replace rule ip nat PREROUTING handle 7 tcp dport 587 fib daddr type local counter redirect to :30587
|
|
nft replace rule ip nat PREROUTING handle 8 tcp dport 465 fib daddr type local counter redirect to :30465
|
|
```
|
|
- Saved rules: `iptables-legacy-save > /etc/iptables/rules.v4`, `nft list ruleset > /etc/nftables.conf`
|
|
|
|
### 4. Hermes-MCP App Email Path Updated
|
|
**Fix:** Updated `src/smtp.ts` and `hermes-k8s.yaml` to send directly through Azure ACS SMTP instead of local Poste.io.
|
|
|
|
**Commit:** `7ddb6d4`
|
|
|
|
---
|
|
|
|
## Azure ACS Email Configuration
|
|
|
|
### DNS Records (GoDaddy — squaremcp.com)
|
|
| Record | Type | Name | Value |
|
|
|--------|------|------|-------|
|
|
| Domain verification | TXT | `@` | `ms-domain-verification=3f22bbde-af8b-43c5-9724-6755363a1ee3` |
|
|
| SPF | TXT | `@` | `v=spf1 include:spf.protection.outlook.com -all` |
|
|
| DKIM 1 | CNAME | `selector1-azurecomm-prod-net._domainkey` | `selector1-azurecomm-prod-net._domainkey.azurecomm.net` |
|
|
| DKIM 2 | CNAME | `selector2-azurecomm-prod-net._domainkey` | `selector2-azurecomm-prod-net._domainkey.azurecomm.net` |
|
|
|
|
### Authorized Senders (MailFrom addresses)
|
|
- `garfield@squaremcp.com`
|
|
- `info@squaremcp.com`
|
|
- `noreply@squaremcp.com`
|
|
- `sales@squaremcp.com`
|
|
- `contact@squaremcp.com`
|
|
- `DoNotReply@squaremcp.com` (pre-existing)
|
|
|
|
### Azure ACS SMTP Credentials
|
|
- **Host:** `smtp.azurecomm.net`
|
|
- **Port:** `587`
|
|
- **Username:** `fetcherpay-comm-prod.628d0126-984a-436a-8920-fcc877f5481a.57af0299-f395-4cf7-8fc5-3017211b2879`
|
|
- **Password:** `5SH8Q~aPvVVvFeSoXAfPB0MhDqNny_AwmjeQLbXf`
|
|
- **Resource:** `fetcherpay-comm-prod` (Communication Services)
|
|
- **Email Service:** `fetcherpay-email-prod`
|
|
|
|
---
|
|
|
|
## Remaining Tasks
|
|
|
|
1. **✅ DONE — Verify Poste.io webmail delivery**
|
|
- Send test email from Poste.io webmail
|
|
- Check Gmail headers for `dkim=pass`, `spf=pass`
|
|
- Queued emails will auto-retry within ~17 minutes of the fix
|
|
|
|
2. **Confirm hermes-mcp app email works**
|
|
- Trigger password reset or demo invite from app
|
|
- Verify delivery via Azure ACS relay
|
|
|
|
3. **Rules are persisted**
|
|
- `iptables-legacy-save > /etc/iptables/rules.v4`
|
|
- `nft list ruleset > /etc/nftables.conf`
|
|
- `iptables-persistent` package already installed
|
|
|
|
---
|
|
|
|
## Key Learnings
|
|
|
|
- `hostNetwork: true` on K8s pods bypasses CNI but causes port conflicts (can't use on Poste.io which needs 25/80/443)
|
|
- **nftables and iptables-legacy can coexist** — always check BOTH when debugging packet drops. In this case, nftables nat PREROUTING was the actual culprit, not Calico/iptables-legacy
|
|
- NodePort/port-mapping redirect rules must include `fib daddr type local` or they will hijack ALL outbound traffic on that port
|
|
- Azure ACS requires domain verification → DNS records → linked Communication Service → authorized senders
|
|
- Poste.io requires container restart after changing `server.ini` smarthost settings
|
|
- Port 25 blocked on VPS is extremely common; smart relay (Azure ACS/SendGrid) is the standard fix
|
|
|
|
## Alex Ferrari Email — Confirmed Sent (2026-05-19)
|
|
- Demo email sent from `info@squaremcp.com` to `info@ferrarilending.com`
|
|
- CC: `garfield@squaremcp.com` noted in email footer (send tool has no native CC field)
|
|
- Message ID: `e73deb8c-de7a-b933-71ad-57144b895413@squaremcp.com`
|
|
- Test copy sent to `garfield.heron@gmail.com` — confirmed delivered
|
|
- Email links to demo video: `https://squaremcp.com/squaremcp-broker-demo.mp4`
|
|
- No pricing language — Lodge Brothers rule applied
|
|
- Awaiting reply from Alex Ferrari
|
|
|
|
---
|
|
|
|
## Alex Ferrari Reply Received + Response Sent (2026-05-19 ~22:00)
|
|
|
|
**Incoming:** Alex Ferrari replied to the demo email at 21:54 UTC:
|
|
> "Hi Garfield, This is the first email I got from your company, I don't believe I have a login, were you able to find the email sent?"
|
|
|
|
**Outgoing:** Responded via `info@squaremcp.com` explaining the AT&T routing issue from yesterday, confirmed it was resolved, noted he doesn't have an account yet, and offered a 20-minute live walkthrough to create one.
|
|
|
|
**Message ID:** `60122761-8b48-d2e0-2e50-ba59e6ca9152@squaremcp.com`
|
|
|