From 56b477edc07bfa64846a4ed4e60bda33b9966f46 Mon Sep 17 00:00:00 2001 From: Miki Palet <64255955+mikipalet@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:10:37 +0000 Subject: [PATCH 1/2] fix(mcp): ChatGPT scope refusals link the plugin page and say not to retry Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018nKtAcUGmQHuQ9JdjGxsJ3 --- src/late/mcp/middleware/missing_scope.py | 12 ++++++++---- tests/test_chatgpt_generated_tools.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/late/mcp/middleware/missing_scope.py b/src/late/mcp/middleware/missing_scope.py index 2ae4b0ab..75f114c3 100644 --- a/src/late/mcp/middleware/missing_scope.py +++ b/src/late/mcp/middleware/missing_scope.py @@ -27,6 +27,11 @@ _INSUFFICIENT_PERMISSIONS = "insufficient_permissions" +# The plugin's public page. ChatGPT documents no link that opens its Reconnect. +_PLUGIN_URL = ( + "https://chatgpt.com/plugins/plugin_asdk_app_6aad5ef1fadc81919260bddebb06a407" +) + _SCOPE_PURPOSE = { "messaging:read": "read your inbox, comments and messages", "ads:read": "read your ad accounts, campaigns and results", @@ -41,10 +46,9 @@ def relink_instructions(needed: str) -> str: purpose = _SCOPE_PURPOSE.get(needed, f"use this ({needed})") return ( f"Zernio needs one more permission to {purpose} ('{needed}'); this ChatGPT " - "connection was set up before Zernio asked for it. Nothing was sent or changed. " - "Tell the user, in these steps: open ChatGPT Settings > Plugins (Apps in some " - "versions) > Zernio, click ... next to the connected Zernio account, choose " - "Reconnect, approve the new permission, then ask again." + "connection was set up before Zernio asked for it. Do not retry. Nothing " + f"changed. Tell the user: open {_PLUGIN_URL}, Settings, ... by your account, " + "Reconnect, approve, ask again." ) diff --git a/tests/test_chatgpt_generated_tools.py b/tests/test_chatgpt_generated_tools.py index e6eb5202..e3818810 100644 --- a/tests/test_chatgpt_generated_tools.py +++ b/tests/test_chatgpt_generated_tools.py @@ -249,6 +249,13 @@ async def _list_conversations(response: httpx.Response): ) +RELINK_STEPS = ( + "Do not retry. Nothing changed. Tell the user: open " + "https://chatgpt.com/plugins/plugin_asdk_app_6aad5ef1fadc81919260bddebb06a407, " + "Settings, ... by your account, Reconnect, approve, ask again." +) + + async def test_a_link_without_the_tools_scope_is_asked_to_relink(monkeypatch): monkeypatch.setattr( "late.mcp.middleware.missing_scope._granted_scopes", lambda: LINK_SCOPES @@ -259,7 +266,7 @@ async def test_a_link_without_the_tools_scope_is_asked_to_relink(monkeypatch): assert result.is_error text = result.content[0].text assert "read your inbox" in text and "'messaging:read'" in text - assert "Settings > Plugins" in text and "Reconnect" in text + assert RELINK_STEPS in text async def test_the_relink_steps_carry_no_auth_challenge_chatgpt_would_hide_them_behind( @@ -340,7 +347,7 @@ async def test_a_link_that_only_reads_accounts_is_asked_to_relink_before_a_write assert result.is_error text = result.content[0].text assert "'accounts:write'" in text - assert "Settings > Plugins" in text and "Reconnect" in text + assert RELINK_STEPS in text @pytest.mark.parametrize( From 78cf8459b275b975605454f30293c9b24ed32b2b Mon Sep 17 00:00:00 2001 From: Miki Palet <64255955+mikipalet@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:13:32 +0000 Subject: [PATCH 2/2] test(mcp): the kept 403 is checked against the new relink text Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018nKtAcUGmQHuQ9JdjGxsJ3 --- tests/test_chatgpt_generated_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_chatgpt_generated_tools.py b/tests/test_chatgpt_generated_tools.py index e3818810..095db6a2 100644 --- a/tests/test_chatgpt_generated_tools.py +++ b/tests/test_chatgpt_generated_tools.py @@ -369,7 +369,7 @@ async def test_a_write_refused_despite_its_scope_keeps_the_apis_own_error( result = await _create_profile(httpx.Response(403, json=ACCOUNTS_READ_ONLY)) assert result.is_error - assert "Settings > Plugins" not in result.content[0].text + assert "Do not retry" not in result.content[0].text assert "can only read the 'accounts' resource group" in result.content[0].text