Skip to content

Commit 6555f57

Browse files
committed
fix(web): render MCP-specific navbar on mcp.swarmdock.ai
Middleware rewrites mcp.swarmdock.ai/* to /mcp/* but the root layout was emitting the main-app nav (/agents, /tasks, /leaderboard, /docs). On the MCP subdomain those resolved to /mcp/agents, /mcp/tasks, etc. — all 404s. Detect the host in the root layout and swap in Registry + Connect links (plus absolute links back to the main site) when serving the MCP subdomain.
1 parent a747375 commit 6555f57

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

packages/web/src/app/layout.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next';
22
import Link from 'next/link';
3+
import { headers } from 'next/headers';
34
import { Analytics } from '@vercel/analytics/next';
45
import { JetBrains_Mono, IBM_Plex_Mono } from 'next/font/google';
56
import { AuthProvider } from '@/contexts/AuthContext';
@@ -37,14 +38,21 @@ export const metadata: Metadata = {
3738
},
3839
};
3940

40-
const navLinks = [
41+
const mainNavLinks = [
4142
{ href: '/agents', label: 'Agents' },
4243
{ href: '/tasks', label: 'Tasks' },
4344
{ href: '/mcp', label: 'MCP' },
4445
{ href: '/leaderboard', label: 'Leaderboard' },
4546
{ href: '/docs', label: 'Docs' },
4647
];
4748

49+
const mcpNavLinks = [
50+
{ href: '/', label: 'Registry' },
51+
{ href: '/connect', label: 'Connect' },
52+
{ href: 'https://www.swarmdock.ai/docs/mcp', label: 'Docs' },
53+
{ href: 'https://www.swarmdock.ai', label: 'SwarmDock' },
54+
];
55+
4856
const ecosystemLinks = [
4957
{ href: 'https://www.swarmfeed.ai', label: 'SwarmFeed' },
5058
{ href: 'https://www.swarmrecall.ai', label: 'SwarmRecall' },
@@ -53,7 +61,14 @@ const ecosystemLinks = [
5361
{ href: 'https://www.swarmvault.ai', label: 'SwarmVault' },
5462
];
5563

56-
export default function RootLayout({ children }: { children: React.ReactNode }) {
64+
export default async function RootLayout({ children }: { children: React.ReactNode }) {
65+
const host = (await headers()).get('host') ?? '';
66+
const isMcpHost = host.startsWith('mcp.');
67+
const navLinks = isMcpHost ? mcpNavLinks : mainNavLinks;
68+
const ctaHref = isMcpHost ? '/connect' : '/docs#quick-start';
69+
const ctaLabel = isMcpHost ? 'Connect Agent' : 'Get Started';
70+
const brandSubtitle = isMcpHost ? 'MCP Registry' : 'Observer Surface';
71+
5772
return (
5873
<html
5974
lang="en"
@@ -79,7 +94,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
7994
SwarmDock
8095
</span>
8196
<span className="mono hidden text-[10px] uppercase tracking-[0.2em] text-[var(--color-text-3)] sm:inline">
82-
Observer Surface
97+
{brandSubtitle}
8398
</span>
8499
</Link>
85100

@@ -97,10 +112,10 @@ export default function RootLayout({ children }: { children: React.ReactNode })
97112
</Link>
98113
))}
99114
<Link
100-
href="/docs#quick-start"
115+
href={ctaHref}
101116
className="ml-2 bg-[#00FF88] px-3 py-1.5 text-sm font-medium text-[#0A0A0A] transition-colors duration-150 hover:brightness-110"
102117
>
103-
Get Started
118+
{ctaLabel}
104119
</Link>
105120
<AuthButton />
106121
</nav>

0 commit comments

Comments
 (0)