From 68a98771bc0265a95097f3b17b9657e2cbabf08f Mon Sep 17 00:00:00 2001 From: "Daniel Gonell (local patch)" Date: Fri, 1 May 2026 07:31:01 -0400 Subject: [PATCH] [local patch] getSocialAccounts: read results.accounts (GHL API shape) Upstream code reads response.data?.accounts which is always undefined because GHL's /social-media-posting/{loc}/accounts returns: { success, statusCode, message, results: { accounts, groups }, traceId } Defensive fallback (?? chain) also handles the legacy/typed shape if upstream ever changes back. Mirrors the same fix on the VPS agent's copy at /opt/danielgonell/agents/ghl-mcp/src/tools/social-media-tools.ts. DO NOT discard. If git pull from upstream conflicts here, accept BOTH sides if upstream finally merged a fix; otherwise keep the local change. Patch saved at: /vps-setup/mcp-patches/ghl-mcp-results-accounts.patch --- src/tools/social-media-tools.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tools/social-media-tools.ts b/src/tools/social-media-tools.ts index 5623a450..410c2a87 100644 --- a/src/tools/social-media-tools.ts +++ b/src/tools/social-media-tools.ts @@ -454,12 +454,17 @@ export class SocialMediaTools { private async getSocialAccounts(params: MCPGetAccountsParams) { const response = await this.ghlClient.getSocialAccounts(); - + // GHL API returns { results: { accounts, groups }, ... }; defensive fallback + // also handles the legacy/typed shape { accounts, groups } at root. + const data: any = response.data; + const accounts = data?.results?.accounts ?? data?.accounts ?? []; + const groups = data?.results?.groups ?? data?.groups ?? []; + return { success: true, - accounts: response.data?.accounts || [], - groups: response.data?.groups || [], - message: `Retrieved ${response.data?.accounts?.length || 0} social media accounts and ${response.data?.groups?.length || 0} groups` + accounts, + groups, + message: `Retrieved ${accounts.length} social media accounts and ${groups.length} groups` }; }