Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

641 B
Raw Blame
import { ApFlagId, McpServerType } from '@activepieces/shared';

import { flagsHooks } from '@/hooks/flags-hooks';
import { formatUtils } from '@/lib/format-utils';

export function useMcpServerUrl({
  serverType,
}: {
  serverType: McpServerType;
}): {
  serverUrl: string;
  isReachableFromInternet: boolean;
} {
  const { data: mcpUrl } = flagsHooks.useFlag<string>(ApFlagId.MCP_URL);
  const base = (mcpUrl ?? '').replace(/\/$/, '');
  const path = serverType === McpServerType.PLATFORM ? '/mcp/platform' : '/mcp';
  return {
    serverUrl: `${base}${path}`,
    isReachableFromInternet: formatUtils.urlIsPubliclyReachable(base),
  };
}