Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(web): use app url for MCP endpoint (#33)

akmhatey-ai2d606ef4a50a
diff --git a/web/src/components/settings/api-keys-section.tsx b/web/src/components/settings/api-keys-section.tsx
index da70a51d7..e67b26b16 100644
--- a/web/src/components/settings/api-keys-section.tsx
+++ b/web/src/components/settings/api-keys-section.tsx
@@ -34,6 +34,15 @@ interface ApiKey {
created_at: string;
}
+const configuredAppUrl = process.env.NEXT_PUBLIC_APP_URL?.replace(/\/$/, "") ?? "";
+
+function getMcpEndpoint(): string {
+ const appUrl =
+ configuredAppUrl ||
+ (typeof window !== "undefined" ? window.location.origin : "");
+ return `${appUrl}/api/mcp`;
+}
+
function formatDate(iso: string | null): string {
if (!iso) return "—";
return new Date(iso).toLocaleDateString(undefined, {
@@ -50,6 +59,7 @@ export function ApiKeysSection() {
const [newName, setNewName] = useState("");
const [creating, setCreating] = useState(false);
const [revealedToken, setRevealedToken] = useState<string | null>(null);
+ const mcpEndpoint = getMcpEndpoint();
const load = useCallback(async () => {
setLoading(true);
@@ -141,16 +151,13 @@ export function ApiKeysSection() {
<p className="font-medium text-foreground">MCP endpoint</p>
<div className="flex items-center gap-2">
<code className="flex-1 truncate font-mono">
- {typeof window !== "undefined" ? window.location.origin : ""}
- /api/mcp
+ {mcpEndpoint}
</code>
<Button
size="sm"
variant="ghost"
className="h-6 px-2"
- onClick={() =>
- copy(`${window.location.origin}/api/mcp`)
- }
+ onClick={() => copy(mcpEndpoint)}
>
<Copy className="h-3 w-3" />
</Button>