From 9d97c4743e83de087829205d40f9d41a4b73affd Mon Sep 17 00:00:00 2001 From: Miki Palet <64255955+mikipalet@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:09:30 +0000 Subject: [PATCH 1/3] feat(mcp): ChatGPT plugin wave 2, the next 70 most used reads The next 70 reads by the same 30-day ranking (REST plus /mcp calls), keeping to the seven scopes /chatgpt already advertises, so a link that re-linked for wave 1 needs nothing new: leads, ads detail and creatives, mentions, inbox search, email and call history, queue, logs, LinkedIn, YouTube, Instagram and Google Business analytics. Skipped for scope: the Google review batch read (a POST, which a read scope does not reach) and calendar events (calendar has no read scope). 123 tools in all. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kx4ZnYRCwTShnKwf5bar5Y --- src/late/mcp/chatgpt_tools.py | 77 ++++++++++++++++++++++++++- tests/test_chatgpt_generated_tools.py | 8 ++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/late/mcp/chatgpt_tools.py b/src/late/mcp/chatgpt_tools.py index 88e02d29..3e62169b 100644 --- a/src/late/mcp/chatgpt_tools.py +++ b/src/late/mcp/chatgpt_tools.py @@ -68,7 +68,82 @@ "contacts_list_contacts", ) -CHATGPT_GENERATED_TOOLS = WAVE_1 +# The next 70 reads by the same ranking, keeping to the scopes wave 1 already +# asks for (so a link that re-linked for wave 1 needs nothing new). +WAVE_2 = ( + "lead_gen_list_leads", + "broadcasts_get_broadcast", + "lead_gen_count_leads", + "workflows_get_workflow", + "ad_campaigns_get_ad_campaign_details", + "instagram_list_instagram_stories", + "analytics_get_facebook_page_insights", + "ad_campaigns_get_ads_timeline", + "analytics_get_instagram_follower_history", + "profiles_get_profile", + "instagram_get_instagram_publishing_limit", + "analytics_get_you_tube_video_retention", + "mentions_list_inbox_mentions", + "accounts_get_tik_tok_creator_info", + "analytics_get_you_tube_channel_insights", + "queue_list_queue_slots", + "ad_creatives_get_ad_creative", + "phone_numbers_list_phone_numbers", + "ad_accounts_get_ad_account_live_entities", + "lead_gen_list_lead_forms", + "ad_accounts_get_ad_account_finance", + "ad_insights_get_campaign_analytics", + "analytics_get_you_tube_demographics", + "instagram_get_instagram_business_discovery", + "ad_targeting_search_ad_targeting", + "analytics_get_content_decay", + "analytics_get_post_samples", + "whatsapp_phone_numbers_get_whats_app_phone_numbers", + "analytics_get_posting_frequency", + "ad_creatives_list_ad_creatives", + "reddit_get_reddit_feed", + "email_list_email_messages", + "messages_search_inbox_conversations", + "workflows_list_workflows", + "ad_campaigns_list_ad_sets", + "analytics_get_analytics_dashboard", + "analytics_get_linked_in_org_aggregate_analytics", + "ad_insights_get_ad_insights_report", + "contacts_get_contact", + "voice_list_voice_calls", + "ad_accounts_get_ads_activity_log", + "logs_list_logs", + "analytics_get_linked_in_post_reactions", + "ad_audiences_list_ad_audiences", + "analytics_get_linked_in_aggregate_analytics", + "ad_accounts_list_ads_instagram_accounts", + "inbox_analytics_get_inbox_volume", + "tracking_tags_list_tracking_tags", + "broadcasts_list_broadcasts", + "ad_campaigns_list_ad_keywords", + "ad_accounts_list_ads_instagram_posts", + "analytics_get_google_business_search_keywords", + "ad_creatives_list_ad_videos", + "whatsapp_get_whats_app_template_by_id", + "inbox_analytics_get_inbox_response_time", + "accounts_get_account", + "twitter_engagement_search_tweets", + "ad_campaigns_get_ad_review", + "tracking_tags_get_tracking_tag_stats", + "account_groups_list_account_groups", + "ad_creatives_list_ad_images", + "lead_gen_get_lead_form", + "whatsapp_get_whats_app_business_profile", + "email_get_email_thread", + "inbox_analytics_get_inbox_source_breakdown", + "tracking_tags_get_tracking_tag", + "tracking_tags_get_ad_tracking_tags", + "gmb_verifications_get_google_business_verifications", + "whatsapp_list_whats_app_account_events", + "instagram_get_instagram_mentioned_comment", +) + +CHATGPT_GENERATED_TOOLS = WAVE_1 + WAVE_2 _SUMMARY_MAX = 400 diff --git a/tests/test_chatgpt_generated_tools.py b/tests/test_chatgpt_generated_tools.py index 0ea2fa77..0cc453ef 100644 --- a/tests/test_chatgpt_generated_tools.py +++ b/tests/test_chatgpt_generated_tools.py @@ -27,6 +27,11 @@ LIVE_INSTRUCTIONS = (FIXTURES / "chatgpt_live_instructions.txt").read_text() CONVERSATIONS = "https://api.test.com/v1/inbox/conversations" LINK_SCOPES = {"posts:read", "posts:write", "accounts:read", "analytics:read"} +OPEN_WORLD_READS = { + "reddit_get_reddit_feed", + "instagram_get_instagram_business_discovery", + "twitter_engagement_search_tweets", +} GROUP_DENIED = { "error": "This connector token has the 'messages' resource group disabled.", "code": "insufficient_permissions", @@ -76,7 +81,8 @@ async def test_every_generated_tool_has_explicit_hints_and_its_oauth_scope(): hints = listed[name]["annotations"] assert hints["readOnlyHint"] is True, name assert hints["destructiveHint"] is False, name - assert hints["openWorldHint"] is False, name + # Reads of public content (Reddit, other Instagram accounts) are open-world. + assert hints["openWorldHint"] is (name in OPEN_WORLD_READS), name assert listed[name]["_meta"]["securitySchemes"] == [ {"type": "oauth2", "scopes": [TOOL_OAUTH_SCOPES[name][0]]} ], name From 9eb3f2bd78f592250fda958c51a12fc9b558f5c1 Mon Sep 17 00:00:00 2001 From: Miki Palet <64255955+mikipalet@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:20:02 +0000 Subject: [PATCH 2/3] fix(mcp): wave 2 review: drop billed, broken, deprecated and admin reads; public catalog searches are open-world Out: X search (bills per tweet read), the Reddit feed (the platform is disabled, so every call fails), the deprecated WhatsApp numbers alias, legacy analytics replaced by /v1/metrics, raw request logs, an ad report reader whose creator is a write, and LinkedIn reactors (third-party personal data). In, next by usage: Ad Library search, Google Business services, high-demand periods, inbox heatmap, a WhatsApp template, TikTok commercial music, Instagram audio search, one email message, WhatsApp group chats. Ad targeting and interest search, Instagram audio search and TikTok commercial music read public catalogs, so openWorldHint is true. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kx4ZnYRCwTShnKwf5bar5Y --- scripts/generate_mcp_tools.py | 4 ++++ src/late/mcp/chatgpt_tools.py | 24 ++++++++++++++---------- src/late/mcp/generated_tools.py | 8 ++++---- tests/test_chatgpt_generated_tools.py | 8 +++++--- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/scripts/generate_mcp_tools.py b/scripts/generate_mcp_tools.py index f8597a58..67fda26d 100644 --- a/scripts/generate_mcp_tools.py +++ b/scripts/generate_mcp_tools.py @@ -135,6 +135,10 @@ "getTweet", "getInstagramBusinessDiscovery", "searchAdLibrary", + "searchAdTargeting", + "searchAdInterests", + "searchInstagramAudio", + "listTikTokCommercialMusic", } # Operations to SKIP (not useful for MCP) diff --git a/src/late/mcp/chatgpt_tools.py b/src/late/mcp/chatgpt_tools.py index 3e62169b..309b6bdf 100644 --- a/src/late/mcp/chatgpt_tools.py +++ b/src/late/mcp/chatgpt_tools.py @@ -69,7 +69,11 @@ ) # The next 70 reads by the same ranking, keeping to the scopes wave 1 already -# asks for (so a link that re-linked for wave 1 needs nothing new). +# asks for (so a link that re-linked for wave 1 needs nothing new). Left out +# on review: X search (bills per tweet read), the Reddit feed (disabled +# platform), deprecated aliases and legacy analytics replaced by metrics, +# the raw request logs, a report reader whose creator is a write, and +# LinkedIn reactors (third-party personal data). WAVE_2 = ( "lead_gen_list_leads", "broadcasts_get_broadcast", @@ -96,24 +100,16 @@ "analytics_get_you_tube_demographics", "instagram_get_instagram_business_discovery", "ad_targeting_search_ad_targeting", - "analytics_get_content_decay", - "analytics_get_post_samples", - "whatsapp_phone_numbers_get_whats_app_phone_numbers", - "analytics_get_posting_frequency", "ad_creatives_list_ad_creatives", - "reddit_get_reddit_feed", "email_list_email_messages", "messages_search_inbox_conversations", "workflows_list_workflows", "ad_campaigns_list_ad_sets", "analytics_get_analytics_dashboard", "analytics_get_linked_in_org_aggregate_analytics", - "ad_insights_get_ad_insights_report", "contacts_get_contact", "voice_list_voice_calls", "ad_accounts_get_ads_activity_log", - "logs_list_logs", - "analytics_get_linked_in_post_reactions", "ad_audiences_list_ad_audiences", "analytics_get_linked_in_aggregate_analytics", "ad_accounts_list_ads_instagram_accounts", @@ -127,7 +123,6 @@ "whatsapp_get_whats_app_template_by_id", "inbox_analytics_get_inbox_response_time", "accounts_get_account", - "twitter_engagement_search_tweets", "ad_campaigns_get_ad_review", "tracking_tags_get_tracking_tag_stats", "account_groups_list_account_groups", @@ -141,6 +136,15 @@ "gmb_verifications_get_google_business_verifications", "whatsapp_list_whats_app_account_events", "instagram_get_instagram_mentioned_comment", + "ad_accounts_list_high_demand_periods", + "gmb_services_get_google_business_services", + "ad_library_search_ad_library", + "inbox_analytics_get_inbox_heatmap", + "whatsapp_get_whats_app_template", + "accounts_list_tik_tok_commercial_music", + "instagram_search_instagram_audio", + "email_get_email_message", + "whatsapp_list_whats_app_group_chats", ) CHATGPT_GENERATED_TOOLS = WAVE_1 + WAVE_2 diff --git a/src/late/mcp/generated_tools.py b/src/late/mcp/generated_tools.py index 3ddcb9b8..df314461 100644 --- a/src/late/mcp/generated_tools.py +++ b/src/late/mcp/generated_tools.py @@ -1301,7 +1301,7 @@ def accounts_get_instagram_follow_status( title="List trending commercial music", readOnlyHint=True, destructiveHint=False, - openWorldHint=False, + openWorldHint=True, ) ) def accounts_list_tik_tok_commercial_music( @@ -14855,7 +14855,7 @@ def ad_rules_list_ad_rule_runs(rule_id: str, limit: int = 20, skip: int = 0) -> title="Search targeting interests", readOnlyHint=True, destructiveHint=False, - openWorldHint=False, + openWorldHint=True, ) ) def ad_targeting_search_ad_interests(q: str, account_id: str) -> str: @@ -14885,7 +14885,7 @@ def ad_targeting_search_ad_interests(q: str, account_id: str) -> str: title="Search targeting options", readOnlyHint=True, destructiveHint=False, - openWorldHint=False, + openWorldHint=True, ) ) def ad_targeting_search_ad_targeting( @@ -41355,7 +41355,7 @@ def instagram_get_instagram_publishing_limit(account_id: str) -> str: title="Search Instagram audio", readOnlyHint=True, destructiveHint=False, - openWorldHint=False, + openWorldHint=True, ) ) def instagram_search_instagram_audio( diff --git a/tests/test_chatgpt_generated_tools.py b/tests/test_chatgpt_generated_tools.py index 0cc453ef..f12aca33 100644 --- a/tests/test_chatgpt_generated_tools.py +++ b/tests/test_chatgpt_generated_tools.py @@ -28,9 +28,11 @@ CONVERSATIONS = "https://api.test.com/v1/inbox/conversations" LINK_SCOPES = {"posts:read", "posts:write", "accounts:read", "analytics:read"} OPEN_WORLD_READS = { - "reddit_get_reddit_feed", + "accounts_list_tik_tok_commercial_music", + "ad_library_search_ad_library", + "ad_targeting_search_ad_targeting", "instagram_get_instagram_business_discovery", - "twitter_engagement_search_tweets", + "instagram_search_instagram_audio", } GROUP_DENIED = { "error": "This connector token has the 'messages' resource group disabled.", @@ -81,7 +83,7 @@ async def test_every_generated_tool_has_explicit_hints_and_its_oauth_scope(): hints = listed[name]["annotations"] assert hints["readOnlyHint"] is True, name assert hints["destructiveHint"] is False, name - # Reads of public content (Reddit, other Instagram accounts) are open-world. + # Reads of public catalogs and other accounts' content are open-world. assert hints["openWorldHint"] is (name in OPEN_WORLD_READS), name assert listed[name]["_meta"]["securitySchemes"] == [ {"type": "oauth2", "scopes": [TOOL_OAUTH_SCOPES[name][0]]} From 840bc37773c4be4bd8e5357ea249dc4e758cf303 Mon Sep 17 00:00:00 2001 From: Miki Palet <64255955+mikipalet@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:08:51 +0000 Subject: [PATCH 3/3] feat(mcp): a scope refusal tells the user how to reconnect Zernio in ChatGPT 12 of wave 1's first 41 calls were 403s from links made before the read scopes, and none re-linked within the hour. Next to the insufficient_scope challenge, the tool result now says what the permission is for and where to reconnect (Settings > Plugins > Zernio > Reconnect, per OpenAI's help center), so the model can walk the user through it when ChatGPT shows no prompt. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kx4ZnYRCwTShnKwf5bar5Y --- src/late/mcp/middleware/missing_scope.py | 27 ++++++++++++++++-------- tests/test_chatgpt_generated_tools.py | 4 +++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/late/mcp/middleware/missing_scope.py b/src/late/mcp/middleware/missing_scope.py index a060647e..cf0f42ab 100644 --- a/src/late/mcp/middleware/missing_scope.py +++ b/src/late/mcp/middleware/missing_scope.py @@ -25,6 +25,23 @@ _INSUFFICIENT_PERMISSIONS = "insufficient_permissions" +_SCOPE_PURPOSE = { + "messaging:read": "read your inbox, comments and messages", + "ads:read": "read your ad accounts, campaigns and results", + "contacts:read": "read your contacts and leads", +} + + +def relink_instructions(needed: str) -> str: + """What the model tells the user when ChatGPT does not show its re-link prompt.""" + purpose = _SCOPE_PURPOSE.get(needed, f"use this ({needed})") + return ( + f"Zernio needs a new permission to {purpose}, which this ChatGPT connection " + f"has not granted yet ('{needed}'). Tell the user to reconnect Zernio in ChatGPT: " + "Settings > Plugins (called Apps in some versions) > Zernio > Reconnect, then " + "approve the new permission and ask again. Nothing was changed in their account." + ) + def _granted_scopes() -> set[str] | None: """The OAuth scope of the calling token, or None for an API key.""" @@ -83,15 +100,7 @@ async def on_call_tool( raise needed = reaching[0] return ToolResult( - content=[ - TextContent( - type="text", - text=( - f"Zernio needs the '{needed}' permission for this, which this " - "ChatGPT connection was not granted. Reconnect Zernio to grant it." - ), - ) - ], + content=[TextContent(type="text", text=relink_instructions(needed))], meta={"mcp/www_authenticate": [self._challenge]}, is_error=True, ) diff --git a/tests/test_chatgpt_generated_tools.py b/tests/test_chatgpt_generated_tools.py index f12aca33..cc12502d 100644 --- a/tests/test_chatgpt_generated_tools.py +++ b/tests/test_chatgpt_generated_tools.py @@ -177,7 +177,9 @@ async def test_a_link_without_the_tools_scope_is_asked_to_relink(monkeypatch): ) assert 'error="insufficient_scope"' in challenge assert "messaging:read" in challenge - assert "messaging:read" in result.content[0].text + text = result.content[0].text + assert "read your inbox" in text + assert "Settings > Plugins" in text and "Reconnect" in text async def test_each_group_refusal_logs_whether_it_asked_to_relink(monkeypatch, caplog):