Skip to content

Commit a90f31d

Browse files
committed
fix: code cleanup
1 parent 0eab3e5 commit a90f31d

File tree

1 file changed

+14
-9
lines changed
  • apify-docs-theme/src/theme/LLMButtons

1 file changed

+14
-9
lines changed

apify-docs-theme/src/theme/LLMButtons/index.jsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ const DROPDOWN_OPTIONS = [
7575
},
7676
];
7777

78+
const MCP_SERVER_URL = 'https://mcp.apify.com/?tools=docs';
79+
7880
const MCP_CONFIG_JSON = `{
7981
"mcpServers": {
8082
"apify": {
81-
"url": "https://mcp.apify.com/?tools=docs"
83+
"url": "${MCP_SERVER_URL}"
8284
}
8385
}
8486
}`;
@@ -214,14 +216,14 @@ const openApifyMcpConfigurator = (integration) => {
214216
}
215217
};
216218

217-
const openMcpIntegration = async (integration, mcpUrl) => {
219+
const openMcpIntegration = async (integration) => {
218220
// Try to open the app directly using URL scheme
219221
let appUrl;
220222
if (integration === 'cursor') {
221223
// Cursor deeplink format:
222224
// cursor://anysphere.cursor-deeplink/mcp/install?name=$NAME&config=$BASE64_JSON
223225
const cursorConfig = {
224-
url: mcpUrl,
226+
url: MCP_SERVER_URL,
225227
};
226228
const encodedConfig = btoa(JSON.stringify(cursorConfig));
227229
appUrl = `cursor://anysphere.cursor-deeplink/mcp/install?name=apify&config=${encodeURIComponent(encodedConfig)}`;
@@ -230,17 +232,20 @@ const openMcpIntegration = async (integration, mcpUrl) => {
230232
const mcpConfig = {
231233
name: 'Apify',
232234
type: 'http',
233-
url: mcpUrl,
235+
url: MCP_SERVER_URL,
234236
};
235237
const encodedConfig = encodeURIComponent(JSON.stringify(mcpConfig));
236238
appUrl = `vscode:mcp/install?${encodedConfig}`;
237239
}
238240

239241
if (appUrl) {
240-
window.open(appUrl, '_blank');
241-
return;
242+
const openedWindow = window.open(appUrl, '_blank');
243+
244+
if (openedWindow) {
245+
return;
246+
}
242247
}
243-
// Fallback to web configurator
248+
// Fallback to web configurator if appUrl doesn't exist or window.open failed
244249
openApifyMcpConfigurator(integration);
245250
};
246251

@@ -253,7 +258,7 @@ const onConnectCursorClick = () => {
253258
});
254259
}
255260

256-
openMcpIntegration('cursor', 'https://mcp.apify.com/?tools=docs');
261+
openMcpIntegration('cursor');
257262
};
258263

259264
const onConnectVsCodeClick = () => {
@@ -265,7 +270,7 @@ const onConnectVsCodeClick = () => {
265270
});
266271
}
267272

268-
openMcpIntegration('vscode', 'https://mcp.apify.com/?tools=docs');
273+
openMcpIntegration('vscode');
269274
};
270275

271276
const onViewAsMarkdownClick = () => {

0 commit comments

Comments
 (0)