Skip to content

Commit 173e7c1

Browse files
fix(mcp): use tenant subdomain URL in MCP config snippet
The config snippet now generates the correct tenant-scoped URL (e.g., https://holacodigo.preciopana.com/api/mcp/cli) instead of the bare platform domain. This ensures proxy.ts resolves the correct tenant context for MCP requests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7084941 commit 173e7c1

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

app/[locale]/dashboard/admin/api-tokens/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getUserRole } from '@/lib/supabase/get-user-role'
2+
import { getCurrentTenant } from '@/lib/supabase/tenant'
23
import { redirect } from 'next/navigation'
34
import { listMcpTokens } from '@/app/actions/mcp-tokens'
45
import ApiTokensPage from '@/components/dashboard/api-tokens-page'
@@ -10,11 +11,15 @@ export default async function AdminApiTokensPage() {
1011
}
1112

1213
const { data: tokens } = await listMcpTokens()
13-
const domain = process.env.NEXT_PUBLIC_PLATFORM_DOMAIN || 'localhost:3000'
14+
const tenant = await getCurrentTenant()
15+
const platformDomain = process.env.NEXT_PUBLIC_PLATFORM_DOMAIN || 'localhost:3000'
16+
const mcpUrl = tenant?.slug
17+
? `https://${tenant.slug}.${platformDomain}/api/mcp/cli`
18+
: `https://${platformDomain}/api/mcp/cli`
1419

1520
return (
1621
<div className="p-6 lg:p-8">
17-
<ApiTokensPage tokens={tokens ?? []} domain={domain} />
22+
<ApiTokensPage tokens={tokens ?? []} mcpUrl={mcpUrl} />
1823
</div>
1924
)
2025
}

app/[locale]/dashboard/teacher/api-tokens/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getUserRole } from '@/lib/supabase/get-user-role'
2+
import { getCurrentTenant } from '@/lib/supabase/tenant'
23
import { redirect } from 'next/navigation'
34
import { listMcpTokens } from '@/app/actions/mcp-tokens'
45
import ApiTokensPage from '@/components/dashboard/api-tokens-page'
@@ -10,11 +11,15 @@ export default async function TeacherApiTokensPage() {
1011
}
1112

1213
const { data: tokens } = await listMcpTokens()
13-
const domain = process.env.NEXT_PUBLIC_PLATFORM_DOMAIN || 'localhost:3000'
14+
const tenant = await getCurrentTenant()
15+
const platformDomain = process.env.NEXT_PUBLIC_PLATFORM_DOMAIN || 'localhost:3000'
16+
const mcpUrl = tenant?.slug
17+
? `https://${tenant.slug}.${platformDomain}/api/mcp/cli`
18+
: `https://${platformDomain}/api/mcp/cli`
1419

1520
return (
1621
<div className="p-6 lg:p-8">
17-
<ApiTokensPage tokens={tokens ?? []} domain={domain} />
22+
<ApiTokensPage tokens={tokens ?? []} mcpUrl={mcpUrl} />
1823
</div>
1924
)
2025
}

components/dashboard/api-tokens-page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import { createMcpToken, revokeMcpToken, deleteMcpToken, type McpToken } from '@
2727

2828
interface ApiTokensPageProps {
2929
tokens: McpToken[]
30-
domain: string
30+
mcpUrl: string
3131
}
3232

33-
export default function ApiTokensPage({ tokens, domain }: ApiTokensPageProps) {
33+
export default function ApiTokensPage({ tokens, mcpUrl }: ApiTokensPageProps) {
3434
const t = useTranslations('dashboard.admin.apiTokens')
3535
const [createOpen, setCreateOpen] = useState(false)
3636
const [revealedToken, setRevealedToken] = useState<string | null>(null)
@@ -96,7 +96,7 @@ export default function ApiTokensPage({ tokens, domain }: ApiTokensPageProps) {
9696
const configSnippet = (token: string) => JSON.stringify({
9797
mcpServers: {
9898
lms: {
99-
url: `https://${domain}/api/mcp/cli`,
99+
url: mcpUrl,
100100
headers: {
101101
Authorization: `Bearer ${token}`,
102102
},

0 commit comments

Comments
 (0)