mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 06:34:26 +01:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type { MCPServer } from "../types/server";
|
|
|
|
export function getGooseInstallLink(server: MCPServer): string {
|
|
if (server.is_builtin) {
|
|
const queryParams = [
|
|
'cmd=goosed',
|
|
'arg=mcp',
|
|
`arg=${encodeURIComponent(server.id)}`,
|
|
`description=${encodeURIComponent(server.id)}`
|
|
].join('&');
|
|
return `goose://extension?${queryParams}`;
|
|
}
|
|
|
|
// Handle the case where the command is a URL
|
|
if (server.url) {
|
|
const queryParams = [
|
|
`url=${encodeURIComponent(server.url)}`,
|
|
`id=${encodeURIComponent(server.id)}`,
|
|
`name=${encodeURIComponent(server.name)}`,
|
|
`description=${encodeURIComponent(server.description)}`,
|
|
...server.environmentVariables
|
|
.filter((env) => env.required)
|
|
.map(
|
|
(env) => `env=${encodeURIComponent(`${env.name}=${env.description}`)}`
|
|
),
|
|
].join("&");
|
|
|
|
return `goose://extension?${queryParams}`;
|
|
}
|
|
|
|
const parts = server.command.split(" ");
|
|
const baseCmd = parts[0]; // jbang, npx or uvx
|
|
const args = parts.slice(1); // remaining arguments
|
|
|
|
const queryParams = [
|
|
`cmd=${encodeURIComponent(baseCmd)}`,
|
|
...args.map((arg) => `arg=${encodeURIComponent(arg)}`),
|
|
`id=${encodeURIComponent(server.id)}`,
|
|
`name=${encodeURIComponent(server.name)}`,
|
|
`description=${encodeURIComponent(server.description)}`,
|
|
...server.environmentVariables
|
|
.filter((env) => env.required)
|
|
.map(
|
|
(env) => `env=${encodeURIComponent(`${env.name}=${env.description}`)}`
|
|
),
|
|
].join("&");
|
|
|
|
return `goose://extension?${queryParams}`;
|
|
} |