);
}
export function MCPAuthSection({
integration,
activeAccount,
hasMCPAuth,
}: MCPAuthSectionProps) {
const [isMCPConnecting, setIsMCPConnecting] = useState(false);
const mcpFetcher = useFetcher<{ redirectURL: string }>();
const disconnectMcpFetcher = useFetcher();
const isMCPConnected = !!activeAccount?.integrationConfiguration?.mcp;
const isConnected = !!activeAccount;
const mcpUrl = `https://core.heysol.ai/api/v1/mcp/${integration.slug}`;
const handleMCPConnect = useCallback(() => {
setIsMCPConnecting(true);
mcpFetcher.submit(
{
integrationDefinitionId: integration.id,
redirectURL: window.location.href,
integrationAccountId: activeAccount?.id as string,
mcp: true,
},
{
method: "post",
action: "/api/v1/oauth",
encType: "application/json",
},
);
}, [integration.id, mcpFetcher, activeAccount?.id]);
const handleMCPDisconnect = useCallback(() => {
if (!activeAccount?.id) return;
disconnectMcpFetcher.submit(
{
integrationAccountId: activeAccount.id,
},
{
method: "post",
action: "/api/v1/integration_account/disconnect_mcp",
encType: "application/json",
},
);
}, [activeAccount?.id, disconnectMcpFetcher]);
// Watch for fetcher completion
React.useEffect(() => {
if (mcpFetcher.state === "idle" && isMCPConnecting) {
if (mcpFetcher.data?.redirectURL) {
window.location.href = mcpFetcher.data.redirectURL;
} else {
setIsMCPConnecting(false);
}
}
}, [mcpFetcher.state, mcpFetcher.data, isMCPConnecting]);
React.useEffect(() => {
if (disconnectMcpFetcher.state === "idle" && disconnectMcpFetcher.data) {
window.location.reload();
}
}, [disconnectMcpFetcher.state, disconnectMcpFetcher.data]);
// Show nothing if not connected at all
if (!isConnected) return null;
// Show MCP box if:
// - hasMCPAuth is true (always show MCP section)
// - OR hasMCPAuth is false but integration is connected (show MCP URL box only)
return (
MCP Authentication
{hasMCPAuth ? (
isMCPConnected ? (
MCP Connected
MCP (Model Context Protocol) authentication is active
) : (
MCP (Model Context Protocol) Authentication
This integration requires MCP (Model Context Protocol)
authentication. Please provide the required MCP credentials in
addition to any other authentication method.
)
) : (
// hasMCPAuth is false, but integration is connected: show just the MCPUrlBox
Integration Connected
You can use the MCP endpoint for this integration: