From b2bd2e30dd7a11ccf3a7283b13a93e054edab027 Mon Sep 17 00:00:00 2001 From: riverLethe <865192079@qq.com> Date: Wed, 22 Oct 2025 19:59:49 +0800 Subject: [PATCH] feat/ui:The server configuration allows switching between Streamable HTTP and SSE. --- frontend/public/locales/en/translation.json | 3 +- .../public/locales/zh-CN/translation.json | 3 +- .../src/components/theme/classic/Detail.tsx | 40 ++---------- .../src/components/theme/creative/Detail.tsx | 40 ++---------- .../src/components/theme/modern/Detail.tsx | 40 ++---------- frontend/src/components/theme/temu/Detail.tsx | 40 ++---------- .../components/marketplace/ServerConfig.tsx | 63 ++++++++++++++++--- 7 files changed, 82 insertions(+), 147 deletions(-) diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 1f8d294..aabc4ab 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -876,5 +876,6 @@ "Password must be at least 6 characters": "Password must be at least 6 characters", "Email is required": "Email is required", "No servers available": "No servers available", - "(Deleted)": "(Deleted)" + "(Deleted)": "(Deleted)", + "Transport Type": "Transport Type" } diff --git a/frontend/public/locales/zh-CN/translation.json b/frontend/public/locales/zh-CN/translation.json index e3abc59..aa984c2 100644 --- a/frontend/public/locales/zh-CN/translation.json +++ b/frontend/public/locales/zh-CN/translation.json @@ -878,5 +878,6 @@ "Password must be at least 6 characters": "密码必须至少6个字符", "Email is required": "邮箱为必填项", "No servers available": "没有可用服务", - "(Deleted)": "(已删除)" + "(Deleted)": "(已删除)", + "Transport Type": "传输方式" } diff --git a/frontend/src/components/theme/classic/Detail.tsx b/frontend/src/components/theme/classic/Detail.tsx index ceff6f7..2bb5e7c 100644 --- a/frontend/src/components/theme/classic/Detail.tsx +++ b/frontend/src/components/theme/classic/Detail.tsx @@ -13,6 +13,7 @@ import Link from "next/link"; import { Price } from "@/shared/components/marketplace/Price"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { NavigationItem } from "@/shared/components/Navigation"; +import { ServerConfig } from "@/shared/components/marketplace/ServerConfig"; interface DetailProps { product: ServiceData; @@ -214,40 +215,11 @@ export const Detail: React.FC = ({ {/* Code Snippet */} - -
-
- - {platformConfig?.name} MCP - - -
-
-                        
-                          {`{
-  "mcpServers": {
-    "${mcpName}": {
-      "type": "sse",
-      "autoApprove":"all",
-      "url": "${url}?authkey=`}
-                          {`{Your-${platformConfig?.name}-Auth-Key}`}
-                          {`"
-    }
-  }
-}`}
-                        
-                      
-
-
+ diff --git a/frontend/src/components/theme/creative/Detail.tsx b/frontend/src/components/theme/creative/Detail.tsx index 86406ac..778c328 100644 --- a/frontend/src/components/theme/creative/Detail.tsx +++ b/frontend/src/components/theme/creative/Detail.tsx @@ -12,6 +12,7 @@ import { Navigation } from "./Navigation"; import { Footer } from "./Footer"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { NavigationItem } from "@/shared/components/Navigation"; +import { ServerConfig } from "@/shared/components/marketplace/ServerConfig"; interface DetailProps { product: ServiceData; @@ -174,40 +175,11 @@ export const Detail: React.FC = ({ {/* Code Snippet */} - -
-
- - {platformConfig?.name} MCP - - -
-
-                          
-                            {`{
-  "mcpServers": {
-    "${mcpName}": {
-      "type": "sse",
-      "autoApprove":"all",
-      "url": "${url}?authkey=`}
-                            {`{Your-${platformConfig?.name}-Auth-Key}`}
-                            {`"
-    }
-  }
-}`}
-                          
-                        
-
-
+ diff --git a/frontend/src/components/theme/modern/Detail.tsx b/frontend/src/components/theme/modern/Detail.tsx index f450045..115559f 100644 --- a/frontend/src/components/theme/modern/Detail.tsx +++ b/frontend/src/components/theme/modern/Detail.tsx @@ -13,6 +13,7 @@ import { Navigation } from "./Navigation"; import { Footer } from "./Footer"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { NavigationItem } from "@/shared/components/Navigation"; +import { ServerConfig } from "@/shared/components/marketplace/ServerConfig"; interface DetailProps { product: ServiceData; @@ -141,40 +142,11 @@ export const Detail: React.FC = ({ {/* Code Snippet */} - -
-
- - {platformConfig?.name} MCP - - -
-
-                          
-                            {`{
-  "mcpServers": {
-    "${mcpName}": {
-      "type": "sse",
-      "autoApprove":"all",
-      "url": "${url}?authkey=`}
-                            {`{Your-${platformConfig?.name}-Auth-Key}`}
-                            {`"
-    }
-  }
-}`}
-                          
-                        
-
-
+ diff --git a/frontend/src/components/theme/temu/Detail.tsx b/frontend/src/components/theme/temu/Detail.tsx index 1cf18aa..1cf3064 100644 --- a/frontend/src/components/theme/temu/Detail.tsx +++ b/frontend/src/components/theme/temu/Detail.tsx @@ -12,6 +12,7 @@ import { Navigation } from "./Navigation"; import { Footer } from "./Footer"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { NavigationItem } from "@/shared/components/Navigation"; +import { ServerConfig } from "@/shared/components/marketplace/ServerConfig"; interface DetailProps { product: ServiceData; @@ -161,40 +162,11 @@ export const Detail: React.FC = ({ >
{/* Code Snippet */} - -
-
- - {platformConfig?.name} MCP - - -
-
-                          
-                            {`{
-  "mcpServers": {
-    "${mcpName}": {
-      "type": "sse",
-      "autoApprove":"all",
-      "url": "${url}?authkey=`}
-                            {`{Your-${platformConfig?.name}-Auth-Key}`}
-                            {`"
-    }
-  }
-}`}
-                          
-                        
-
-
+
diff --git a/frontend/src/shared/components/marketplace/ServerConfig.tsx b/frontend/src/shared/components/marketplace/ServerConfig.tsx index ac378ff..306661e 100644 --- a/frontend/src/shared/components/marketplace/ServerConfig.tsx +++ b/frontend/src/shared/components/marketplace/ServerConfig.tsx @@ -1,7 +1,7 @@ "use client"; -import React from "react"; -import { Card, Chip, Button } from "@nextui-org/react"; +import React, { useState } from "react"; +import { Card, Chip, Button, Select, SelectItem } from "@nextui-org/react"; import { FlipButton } from "@/shared/components/FlipButton"; import { useAuth } from "@/shared/lib/useAuth"; import { useTranslation } from "react-i18next"; @@ -13,23 +13,38 @@ import toast from "react-hot-toast"; interface ServerConfigProps { mcpName?: string; url?: string; + className?: string; } +type McpType = "sse" | "streamable-http"; + export const ServerConfig: React.FC = ({ mcpName, url = process.env.NEXT_PUBLIC_MCP_URL, + className = "md:min-w-[40%] w-[40%] max-w-100 mt-12", }) => { const { t } = useTranslation(); const { handleLogin } = useAuth(); const { platformConfig } = usePlatformConfig(); + const [mcpType, setMcpType] = useState("sse"); + + const mcpTypeOptions = [ + { key: "sse", label: "SSE (Server-Sent Events)" }, + { key: "streamable-http", label: "Streamable HTTP" }, + ]; const getCodeContent = () => { + const serverUrl = + mcpType === "streamable-http" + ? `${url}/streamable-http?authkey={Your-${platformConfig?.name}-Auth-Key}` + : `${url}?authkey={Your-${platformConfig?.name}-Auth-Key}`; + return `{ "mcpServers": { "${mcpName || "xpack-mcp-market"}": { - "type": "sse", + "type": "${mcpType}", "autoApprove":"all", - "url": "${url}?authkey={Your-${platformConfig?.name}-Auth-Key}" + "url": "${serverUrl}" } } }`; @@ -45,8 +60,8 @@ export const ServerConfig: React.FC = ({ }; return ( -
-
+
+
= ({ />
+ {/* MCP Type Selection */} +
+ +
+ {/* Code Snippet */} - +
@@ -77,9 +119,12 @@ export const ServerConfig: React.FC = ({ {`{ "mcpServers": { "${mcpName || "xpack-mcp-market"}": { - "type": "sse", + "type": "${mcpType}", "autoApprove":"all", - "url": "${url}?authkey=`} + "url": "`} + {mcpType === "streamable-http" + ? `${url}/streamable-http?authkey=` + : `${url}?authkey=`} {`{Your-${platformConfig?.name}-Auth-Key}`} {`" }