Skip to content

Commit b4b7e96

Browse files
authored
Merge pull request #168 from WolframResearch/bugfix/155-appearance-elements-failure
Bugfix: Fall back when AppearanceElements option is unsupported
2 parents 1d741c6 + 8fee5cf commit b4b7e96

3 files changed

Lines changed: 56 additions & 10 deletions

File tree

Kernel/UIResources.wl

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ $toolUIAssociations = <|
1919
"WolframAlpha" :> If[ $deployCloudNotebooks, "ui://wolfram/wolframalpha-viewer", None ]
2020
|>;
2121

22-
$deployedNotebookRoot = "AgentTools/Notebooks";
23-
$deployCloudNotebooks := $deployCloudNotebooks = $CloudConnected; (* must be connected to deploy notebooks *)
22+
$includeAppearanceElements = False;
23+
$deployedNotebookRoot = "AgentTools/Notebooks";
24+
$deployCloudNotebooks := $deployCloudNotebooks = $CloudConnected; (* must be connected to deploy notebooks *)
2425

2526
(* ::**************************************************************************************************************:: *)
2627
(* ::Section::Closed:: *)
@@ -48,13 +49,10 @@ deployCloudNotebookForMCPApp[ nb_Notebook, identifier_ ] := Enclose[
4849
"Target"
4950
];
5051

51-
deployed = CloudDeploy[
52-
nb,
53-
target,
54-
AppearanceElements -> None,
55-
AutoRemove -> True,
56-
IconRules -> { },
57-
Permissions -> { "All" -> { "Read", "Interact" } }
52+
deployed = ConfirmMatch[
53+
cloudDeployTryAppearanceElements[ nb, target ],
54+
_CloudObject | _? FailureQ,
55+
"Deployed"
5856
];
5957

6058
If[ MatchQ[ deployed, _CloudObject ],
@@ -69,6 +67,52 @@ deployCloudNotebookForMCPApp[ nb_Notebook, identifier_ ] := Enclose[
6967

7068
deployCloudNotebookForMCPApp // endDefinition;
7169

70+
(* ::**************************************************************************************************************:: *)
71+
(* ::Subsubsection::Closed:: *)
72+
(*cloudDeployTryAppearanceElements*)
73+
cloudDeployTryAppearanceElements // beginDefinition;
74+
75+
cloudDeployTryAppearanceElements[ expr_, target_ ] /; $includeAppearanceElements :=
76+
cloudDeployWithAppearanceElements[ expr, target ];
77+
78+
(* This tries to CloudDeploy with AppearanceElements -> None, since the footer links will not be clickable in the app.
79+
However, some cloud accounts do not support this option, which causes CloudDeploy to fail with a message.
80+
In that case, we retry without the AppearanceElements option. *)
81+
cloudDeployTryAppearanceElements[ expr_, target_ ] := Quiet[
82+
Check[
83+
CloudDeploy[
84+
expr,
85+
target,
86+
AppearanceElements -> None,
87+
AutoRemove -> True,
88+
IconRules -> { },
89+
Permissions -> { "All" -> { "Read", "Interact" } }
90+
],
91+
(* Disable this check for the remainder of the session: *)
92+
$includeAppearanceElements = True;
93+
cloudDeployWithAppearanceElements[ expr, target ],
94+
{ CloudDeploy::appearancenotsup }
95+
],
96+
{ CloudDeploy::appearancenotsup }
97+
];
98+
99+
cloudDeployTryAppearanceElements // endDefinition;
100+
101+
(* ::**************************************************************************************************************:: *)
102+
(* ::Subsubsection::Closed:: *)
103+
(*cloudDeployWithAppearanceElements*)
104+
cloudDeployWithAppearanceElements // beginDefinition;
105+
106+
cloudDeployWithAppearanceElements[ expr_, target_ ] := CloudDeploy[
107+
expr,
108+
target,
109+
AutoRemove -> True,
110+
IconRules -> { },
111+
Permissions -> { "All" -> { "Read", "Interact" } }
112+
];
113+
114+
cloudDeployWithAppearanceElements // endDefinition;
115+
72116
(* ::**************************************************************************************************************:: *)
73117
(* ::Section::Closed:: *)
74118
(*MCP Integration Helpers*)

PacletInfo.wl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PacletObject[ <|
22
"Name" -> "Wolfram/AgentTools",
33
"Description" -> "Provides tools and integrations for connecting Wolfram Language to AI agents and LLMs",
44
"Creator" -> "Richard Hennigan (Wolfram Research)",
5-
"Version" -> "2.1.0",
5+
"Version" -> "2.1.1",
66
"WolframVersion" -> "14.3+",
77
"PublisherID" -> "Wolfram",
88
"License" -> "MIT",

docs/mcp-apps.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Tools with UI-enhanced behavior:
7575

7676
These enhancements require both MCP Apps support and an active Wolfram Cloud connection. The session flag `$deployCloudNotebooks` (initialized from `$CloudConnected`) gates deployment: if a `CloudDeploy` call fails at runtime, the helper `deployCloudNotebookForMCPApp` sets the flag to `False` and the tools fall back to their standard (non-UI) results for the rest of the session rather than surfacing an internal failure.
7777

78+
Cloud notebooks are deployed with `AppearanceElements -> None` by default, which hides the footer links that would not be clickable inside the MCP App iframe. Some cloud accounts reject this option with `CloudDeploy::appearancenotsup`; in that case the deployment is transparently retried without `AppearanceElements`, and the unsupported status is cached in a session flag (`$includeAppearanceElements`) so subsequent deployments skip the failing attempt.
79+
7880
The fallback is per-tool:
7981

8082
- `WolframLanguageEvaluator` always has a text/image result it can return, so it degrades in place.

0 commit comments

Comments
 (0)