diff --git a/documentation/static/install-link-generator/index.html b/documentation/static/install-link-generator/index.html
index 44806ee9..f448bd37 100644
--- a/documentation/static/install-link-generator/index.html
+++ b/documentation/static/install-link-generator/index.html
@@ -5,6 +5,22 @@
diff --git a/documentation/static/install-link-generator/script.js b/documentation/static/install-link-generator/script.js
index 6f4147b0..ee750049 100644
--- a/documentation/static/install-link-generator/script.js
+++ b/documentation/static/install-link-generator/script.js
@@ -1,4 +1,92 @@
document.addEventListener('DOMContentLoaded', () => {
+ // Function to show error message
+ function showError(message) {
+ const resultDiv = document.getElementById('generatedLink');
+ resultDiv.innerHTML = `
${message}
`;
+ resultDiv.parentElement.style.display = 'block';
+ }
+
+ // Function to handle generated link (display or redirect)
+ function handleGeneratedLink(link, shouldRedirect = false) {
+ if (shouldRedirect) {
+ window.location.href = link;
+ } else {
+ displayGeneratedLink(link);
+ }
+ }
+
+ // Process URL parameters if present
+ const urlParams = new URLSearchParams(window.location.search);
+ if (urlParams.toString()) {
+ try {
+ // Check if this is a built-in extension request
+ if (urlParams.get('cmd') === 'goosed' && urlParams.getAll('arg').includes('mcp')) {
+ const args = urlParams.getAll('arg');
+ const extensionId = args[args.indexOf('mcp') + 1];
+ if (!extensionId) {
+ throw new Error('Missing extension ID in args');
+ }
+
+ const server = {
+ is_builtin: true,
+ id: extensionId
+ };
+ const link = generateInstallLink(server);
+ handleGeneratedLink(link, true);
+ return;
+ }
+
+ // Handle custom extension
+ const cmd = urlParams.get('cmd');
+ if (!cmd) {
+ throw new Error('Missing required parameter: cmd');
+ }
+
+ const args = urlParams.getAll('arg') || [];
+ const command = [cmd, ...args].join(' ');
+ const id = urlParams.get('id');
+ const name = urlParams.get('name');
+ const description = urlParams.get('description');
+
+ if (!id || !name || !description) {
+ throw new Error('Missing required parameters. Need: id, name, and description');
+ }
+
+ const server = {
+ is_builtin: false,
+ id,
+ name,
+ description,
+ command,
+ environmentVariables: []
+ };
+
+ // Handle environment variables if present
+ const envVars = urlParams.getAll('env');
+ if (envVars.length > 0) {
+ envVars.forEach(env => {
+ const [name, description] = env.split('=');
+ if (name && description) {
+ server.environmentVariables.push({
+ name,
+ description,
+ required: true
+ });
+ }
+ });
+ }
+
+ const link = generateInstallLink(server);
+ handleGeneratedLink(link, true);
+ } catch (error) {
+ showError(error.message);
+ document.querySelector('.container').style.display = 'block';
+ }
+ } else {
+ // Show the form if no parameters
+ document.querySelector('.container').style.display = 'block';
+ }
+
// Tab switching
const tabs = document.querySelectorAll('.tab-btn');
tabs.forEach(tab => {
@@ -82,7 +170,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
const link = generateInstallLink(server);
- displayGeneratedLink(link);
+ handleGeneratedLink(link);
});
// Generate link from JSON
@@ -91,9 +179,9 @@ document.addEventListener('DOMContentLoaded', () => {
const jsonInput = document.getElementById('jsonInput').value;
const server = JSON.parse(jsonInput);
const link = generateInstallLink(server);
- displayGeneratedLink(link);
+ handleGeneratedLink(link);
} catch (error) {
- alert('Invalid JSON: ' + error.message);
+ showError('Invalid JSON: ' + error.message);
}
});
@@ -131,6 +219,7 @@ document.addEventListener('DOMContentLoaded', () => {
function displayGeneratedLink(link) {
const linkElement = document.getElementById('generatedLink');
linkElement.textContent = link;
+ linkElement.parentElement.style.display = 'block';
}
// Add sample JSON to the textarea