-
Notifications
You must be signed in to change notification settings - Fork 221
feat(profile): surface the XTM One MCP server in the user profile (#6570) #6571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Samuel Hassine (SamuelHassine)
merged 2 commits into
main
from
feat/xtm-one-mcp-profile-card
Jul 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
openaev-front/src/__tests__/admin/components/profile/XtmOneMcpAccess.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { createTheme, ThemeProvider } from '@mui/material/styles'; | ||
| import { cleanup, render, screen } from '@testing-library/react'; | ||
| import { type ReactNode } from 'react'; | ||
| import { IntlProvider } from 'react-intl'; | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import XtmOneMcpAccess from '../../../../admin/components/profile/XtmOneMcpAccess'; | ||
| import { type PlatformSettings, type User } from '../../../../utils/api-types'; | ||
| import { UserContext, type UserContextType } from '../../../../utils/hooks/useAuth'; | ||
|
|
||
| const theme = createTheme(); | ||
|
|
||
| const TITLE = 'XTM One MCP server'; | ||
| const MANAGE_LABEL = 'Manage in XTM One'; | ||
|
|
||
| const DEFAULT_SETTINGS: Partial<PlatformSettings> = { | ||
| platform_xtm_one_configured: true, | ||
| platform_xtm_one_url: 'https://xtmone.example.com', | ||
| }; | ||
|
|
||
| const renderCard = (settingsOverrides: Partial<PlatformSettings> = {}) => { | ||
| const userContext: UserContextType = { | ||
| me: { user_id: 'user-1' } as User, | ||
| settings: { | ||
| ...DEFAULT_SETTINGS, | ||
| ...settingsOverrides, | ||
| } as PlatformSettings, | ||
| isXTMHubAccessible: true, | ||
| userTenants: [], | ||
| currentUserTenant: null, | ||
| switchUserTenant: vi.fn(), | ||
| reloadUserTenants: vi.fn(), | ||
| }; | ||
|
|
||
| const wrapper = ({ children }: { children: ReactNode }) => ( | ||
| <ThemeProvider theme={theme}> | ||
| <IntlProvider locale="en" defaultLocale="en" onError={() => {}}> | ||
| <UserContext.Provider value={userContext}>{children}</UserContext.Provider> | ||
| </IntlProvider> | ||
| </ThemeProvider> | ||
| ); | ||
|
|
||
| return render(<XtmOneMcpAccess />, { wrapper }); | ||
| }; | ||
|
|
||
| describe('XtmOneMcpAccess', () => { | ||
| afterEach(() => { | ||
| cleanup(); | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('Visibility', () => { | ||
| it('renders the card when XTM One is configured', () => { | ||
| renderCard(); | ||
| expect(screen.getByText(TITLE)).toBeDefined(); | ||
| }); | ||
|
|
||
| it('renders nothing when XTM One is not configured', () => { | ||
| const { container } = renderCard({ platform_xtm_one_configured: false }); | ||
| expect(container.firstChild).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when the XTM One URL is missing', () => { | ||
| const { container } = renderCard({ platform_xtm_one_url: undefined }); | ||
| expect(container.firstChild).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when the XTM One URL is not an http(s) URL', () => { | ||
| const { container } = renderCard({ platform_xtm_one_url: 'javascript:alert(1)' }); | ||
| expect(container.firstChild).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('MCP endpoint', () => { | ||
| it('displays the MCP endpoint derived from the XTM One URL', () => { | ||
| renderCard(); | ||
| expect(screen.getByText('https://xtmone.example.com/mcp/openaev')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('normalizes trailing slashes in the configured URL', () => { | ||
| renderCard({ platform_xtm_one_url: 'https://xtmone.example.com///' }); | ||
| expect(screen.getByText('https://xtmone.example.com/mcp/openaev')).toBeDefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Manage in XTM One link', () => { | ||
| it('points to the XTM One profile MCP page, opening in a new tab safely', () => { | ||
| renderCard(); | ||
| const link = screen.getByText(MANAGE_LABEL).closest('a'); | ||
| expect(link).not.toBeNull(); | ||
| expect(link?.getAttribute('href')).toBe('https://xtmone.example.com/profile/mcp'); | ||
| expect(link?.getAttribute('target')).toBe('_blank'); | ||
| expect(link?.getAttribute('rel')).toBe('noopener noreferrer'); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
openaev-front/src/admin/components/profile/XtmOneMcpAccess.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { ContentCopyOutlined, OpenInNewOutlined } from '@mui/icons-material'; | ||
| import { Button, IconButton, Tooltip, Typography } from '@mui/material'; | ||
|
|
||
| import Paper from '../../../components/common/Paper'; | ||
| import { useFormatter } from '../../../components/i18n'; | ||
| import useAuth from '../../../utils/hooks/useAuth'; | ||
| import { toHttpUrl } from '../../../utils/url-helper'; | ||
| import { copyToClipboard } from '../../../utils/utils'; | ||
|
|
||
| /** | ||
| * "XTM One MCP server" profile card - shown only when the platform is | ||
| * connected to XTM One (`platform_xtm_one_configured` + `platform_xtm_one_url`, | ||
| * the same gate as the top-bar CTEM Command Center button). | ||
| * | ||
| * XTM One natively embeds an MCP (Model Context Protocol) server for every | ||
| * registered platform: AI clients (Cursor, Claude Desktop, custom agents) | ||
| * connect to `{platform_xtm_one_url}/mcp/openaev` with a personal XTM One | ||
| * API key and work with OpenAEV content under the caller's own identity. | ||
| * This card makes that endpoint discoverable from the user's profile, next | ||
| * to the classic API access card. | ||
| */ | ||
| const XtmOneMcpAccess = () => { | ||
| const { t } = useFormatter(); | ||
| const { settings } = useAuth(); | ||
|
|
||
| const xtmOneUrl = toHttpUrl(settings.platform_xtm_one_url)?.replace(/\/+$/, ''); | ||
| if (settings.platform_xtm_one_configured !== true || !xtmOneUrl) { | ||
| return null; | ||
| } | ||
|
|
||
| const mcpEndpointUrl = `${xtmOneUrl}/mcp/openaev`; | ||
| const xtmOneProfileUrl = `${xtmOneUrl}/profile/mcp`; | ||
|
|
||
| return ( | ||
| <Paper> | ||
| <Typography variant="h1" style={{ marginBottom: 20 }}> | ||
| {t('XTM One MCP server')} | ||
| </Typography> | ||
| <Typography variant="body1"> | ||
| {t('This platform is connected to XTM One, which natively exposes an MCP (Model Context Protocol) server for OpenAEV. AI clients such as Cursor or Claude Desktop can work with scenarios, simulations, payloads and findings with your own permissions.')} | ||
| </Typography> | ||
| <Typography variant="h4" gutterBottom style={{ marginTop: 20 }}> | ||
| {t('MCP endpoint URL')} | ||
| </Typography> | ||
| <div style={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 8, | ||
| }} | ||
| > | ||
| <pre style={{ | ||
| flex: 1, | ||
| margin: 0, | ||
| }} | ||
| > | ||
| {mcpEndpointUrl} | ||
| </pre> | ||
| <Tooltip title={t('Copy MCP endpoint URL')}> | ||
| <IconButton | ||
| size="small" | ||
| aria-label={t('Copy MCP endpoint URL')} | ||
| onClick={() => copyToClipboard(t, mcpEndpointUrl)} | ||
| > | ||
| <ContentCopyOutlined fontSize="small" /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| </div> | ||
| <Typography variant="body2" style={{ marginTop: 20 }}> | ||
| {t('Authenticate with a personal XTM One API key passed as a bearer token. Your endpoint, connection status and ready-to-copy client configuration are available in your XTM One profile.')} | ||
| </Typography> | ||
| <Button | ||
| variant="contained" | ||
| color="primary" | ||
| component="a" | ||
| href={xtmOneProfileUrl} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| endIcon={<OpenInNewOutlined />} | ||
| style={{ marginTop: 20 }} | ||
| > | ||
| {t('Manage in XTM One')} | ||
| </Button> | ||
| </Paper> | ||
| ); | ||
| }; | ||
|
|
||
| export default XtmOneMcpAccess; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.