export type GetApiMcpArgs = {'mcp-session-id': string}; export type GetApiMcpOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Handle MCP server notifications * * GET /mcp */ export const getApiMcp = async (args: GetApiMcpArgs, options?: GetApiMcpOptions) => { const {baseUrl = "http://localhost:3001", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['mcp-session-id'] != null) headers.set("mcp-session-id", String(args['mcp-session-id'])) const url = `${baseUrl.replace(/\/+$/, '')}/mcp${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };