Docs: Revamp extensions site (#1260)
Co-authored-by: Nahiyan Khan <nahiyan@squareup.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import type { MCPServer } from "../types/server";
|
||||
|
||||
export function getGooseInstallLink(server: MCPServer): string {
|
||||
return `goose://install/${encodeURIComponent(server.command)}`;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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}`;
|
||||
}
|
||||
const parts = server.command.split(" ");
|
||||
const baseCmd = parts[0]; // 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}`;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { MCPServer } from "../types/server";
|
||||
|
||||
const SERVERS_URL = "/goose/servers.json";
|
||||
|
||||
export async function fetchMCPServers(): Promise<MCPServer[]> {
|
||||
try {
|
||||
const response = await fetch(SERVERS_URL);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log('Fetched MCP servers data:', data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching MCP servers:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchMCPServers(query: string): Promise<MCPServer[]> {
|
||||
const servers = await fetchMCPServers();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
return servers.filter((server) => {
|
||||
const normalizedName = server.name.toLowerCase();
|
||||
const normalizedDescription = server.description.toLowerCase();
|
||||
|
||||
return (
|
||||
normalizedName.includes(normalizedQuery) ||
|
||||
normalizedDescription.includes(normalizedQuery)
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user