The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { styled } from '@linaria/react';
import { Fragment } from 'react';
import { LightCopyIconButton } from '@/ui/input/components/LightCopyIconButton';
import ModelContextProtocolLogo from '@/settings/mcp/assets/model-context-protocol-logo.svg?react';
import { SettingsMcpSetupCard } from '@/settings/mcp/components/SettingsMcpSetupCard';
import { buildMcpSetupCategories } from '@/settings/mcp/utils/buildMcpSetupCategories';
import {
buildMcpConfig,
buildMcpServerUrl,
isHttpsUrl,
} from '@/settings/mcp/utils/mcpSetup';
import { Section } from 'twenty-ui/components/layout';
import { CodeEditor, CodeEditorHeader } from 'twenty-ui/components/code-editor';
import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
import { useLingui } from '@lingui/react/macro';
const StyledMcpEditorHeaderTitle = styled.div`
align-items: center;
display: flex;
gap: ${themeCssVariables.spacing[2]};
`;
const StyledMcpIcon = styled(ModelContextProtocolLogo)`
color: inherit;
flex-shrink: 0;
height: calc(${themeCssVariables.icon.size.md} * 1px);
width: calc(${themeCssVariables.icon.size.md} * 1px);
`;
const StyledMcpSetupContainer = styled.div`
display: flex;
flex-direction: column;
gap: ${themeCssVariables.spacing[10]};
`;
const StyledCardsGrid = styled.div`
display: grid;
gap: ${themeCssVariables.spacing[3]};
grid-template-columns: repeat(2, minmax(0, 1fr));
@media (max-width: ${MOBILE_VIEWPORT}px) {
grid-template-columns: 1fr;
}
`;
export const SettingsMcpSetup = () => {
const { t } = useLingui();
const mcpServerUrl = buildMcpServerUrl(REACT_APP_SERVER_BASE_URL);
const mcpConfig = buildMcpConfig(mcpServerUrl);
const categories = buildMcpSetupCategories({
isHttpsInstallLinkEnabled: isHttpsUrl(mcpServerUrl),
mcpServerUrl,
});
return (
<StyledMcpSetupContainer>
{categories.map((category) => (
<Fragment key={category.title}>
<Section.Root>
<Section.Header
title={category.title}
description={category.description}
/>
<StyledCardsGrid>
{category.cards.map((card) => (
<SettingsMcpSetupCard key={card.title} card={card} />
))}
</StyledCardsGrid>
</Section.Root>
{category.showManualConfigurationAfter && (
<Section.Root>
<Section.Header
title={t`Manual configuration`}
description={t`Access your workspace data from your favorite MCP client like Claude, Codex or Cursor.`}
/>
<CodeEditorHeader
startElement={
<StyledMcpEditorHeaderTitle>
<StyledMcpIcon aria-hidden />
<span>{t`MCP client configuration`}</span>
</StyledMcpEditorHeaderTitle>
}
endElement={<LightCopyIconButton copyText={mcpConfig} />}
/>
<CodeEditor
value={mcpConfig}
language="json"
variant="with-header"
contentPadding="comfortable"
autoHeight
options={{
readOnly: true,
domReadOnly: true,
lineNumbers: 'off',
lineNumbersMinChars: 0,
folding: false,
glyphMargin: false,
scrollBeyondLastLine: false,
renderLineHighlight: 'none',
wordWrap: 'on',
}}
/>
</Section.Root>
)}
</Fragment>
))}
</StyledMcpSetupContainer>
);
};