feat/mcp server change mcp name and fix mcp server can not set bearer token bug
This commit is contained in:
1 parent
224a209fea
commit
fdfe2c63bc
8 files changed
+54
-18
No files matched your search
@@ -66,9 +66,9 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
||||
onInputChange('auth_token', '');
|
||||
}}
|
||||
>
|
||||
<SelectItem key="none" value="none">{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value="apikey">{t('API Key')}</SelectItem>
|
||||
<SelectItem key="bearer-token" value="bearer-token">{t('Bearer Token')}</SelectItem>
|
||||
<SelectItem key="none" value={AuthMethod.None}>{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value={AuthMethod.APIKey}>{t('API Key')}</SelectItem>
|
||||
<SelectItem key="token" value={AuthMethod.BearerToken}>{t('Bearer Token')}</SelectItem>
|
||||
</Select>
|
||||
|
||||
{/* auth config input fields */}
|
||||
|
||||
@@ -27,10 +27,33 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const [url, setUrl] = useState<string>(process.env.NEXT_PUBLIC_MCP_URL || "");
|
||||
const [mcpName, setMcpName] = useState<string>("");
|
||||
useEffect(() => {
|
||||
if (url || !product.slug_name) return;
|
||||
setUrl(`${window.location.origin}/mcp/${product.slug_name}`);
|
||||
}, [product.slug_name]);
|
||||
function sanitizeMCPServerName(rawName: string | undefined): string {
|
||||
if (!rawName) return "xpack-mcp-service";
|
||||
|
||||
// Lower-case & replace invalid chars with hyphen
|
||||
let name = rawName
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-_]+/g, "-");
|
||||
|
||||
// Collapse multiple hyphens
|
||||
name = name.replace(/-+/g, "-");
|
||||
|
||||
// Trim leading/trailing hyphens
|
||||
name = name.replace(/^-+/, "").replace(/-+$/, "");
|
||||
|
||||
|
||||
return name || "mcp-service";
|
||||
}
|
||||
useEffect(() => {
|
||||
setMcpName(sanitizeMCPServerName(platformConfig.name));
|
||||
}, [platformConfig.name]);
|
||||
|
||||
|
||||
//Render the About page based on the current theme
|
||||
switch (currentTheme) {
|
||||
@@ -41,6 +64,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={NavigationItems}
|
||||
mcpName={mcpName}
|
||||
/>
|
||||
);
|
||||
case Theme.CLASSIC:
|
||||
@@ -50,6 +74,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={NavigationItems}
|
||||
mcpName={mcpName}
|
||||
/>
|
||||
);
|
||||
case Theme.CREATIVE:
|
||||
@@ -59,6 +84,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={NavigationItems}
|
||||
mcpName={mcpName}
|
||||
/>
|
||||
);
|
||||
case Theme.TEMU:
|
||||
@@ -68,6 +94,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={NavigationItems}
|
||||
mcpName={mcpName}
|
||||
/>
|
||||
);
|
||||
case Theme.DEFAULT:
|
||||
@@ -76,7 +103,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation items={NavigationItems} />
|
||||
<main className="flex-1">
|
||||
<ProductDetailClient product={product} />
|
||||
<ProductDetailClient product={product} mcpName={mcpName} />
|
||||
</main>
|
||||
<div>
|
||||
<Footer />
|
||||
|
||||
@@ -21,7 +21,7 @@ interface DetailProps {
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -220,7 +221,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"xpack-mcp-market": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
|
||||
@@ -21,7 +21,7 @@ interface DetailProps {
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -154,7 +155,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"xpack-mcp-market": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
|
||||
@@ -21,7 +21,7 @@ interface DetailProps {
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -148,7 +149,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"xpack-mcp-market": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
|
||||
@@ -21,7 +21,7 @@ interface DetailProps {
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -169,7 +170,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"xpack-mcp-market": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
|
||||
@@ -16,11 +16,13 @@ interface ProductDetailClientProps {
|
||||
link: string;
|
||||
name: string
|
||||
}[];
|
||||
mcpName?: string;
|
||||
}
|
||||
|
||||
export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
||||
product,
|
||||
breadcrumbs
|
||||
breadcrumbs,
|
||||
mcpName
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -56,7 +58,7 @@ export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
||||
</div>
|
||||
|
||||
{/* Right side - Server Config */}
|
||||
<ServerConfig product={product} />
|
||||
<ServerConfig product={product} mcpName={mcpName} />
|
||||
</div>
|
||||
|
||||
{/* SEO-friendly: Simple text content for search engines */}
|
||||
|
||||
@@ -10,18 +10,21 @@ import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
interface ServerConfigProps {
|
||||
product: ServiceData;
|
||||
mcpName?: string;
|
||||
}
|
||||
|
||||
export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
|
||||
export const ServerConfig: React.FC<ServerConfigProps> = ({ product, mcpName }) => {
|
||||
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const [url, setUrl] = useState<string>(process.env.NEXT_PUBLIC_MCP_URL || "");
|
||||
useEffect(() => {
|
||||
if (url || !product.slug_name) return;
|
||||
if (url || !product.slug_name) return
|
||||
setUrl(`${window.location.origin}/mcp/${product.slug_name}`);
|
||||
}, [product.slug_name]);
|
||||
|
||||
|
||||
return (
|
||||
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0 mt-12">
|
||||
<div className="mb-4 mt-1">
|
||||
@@ -42,7 +45,7 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"xpack-mcp-market": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
@@ -57,4 +60,4 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user