SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(mcp-page): added acitve host url instead of current url on mcp page (#11141)
SagarRajput-7ad8f3328e0d7
diff --git a/docs/api/openapi.yml b/docs/api/openapi.ymlindex 8a17b30329..b3dcd80ff5 100644--- a/docs/api/openapi.yml+++ b/docs/api/openapi.yml@@ -17273,9 +17273,9 @@ paths:description: Internal Server Errorsecurity:- api_key:- - ADMIN+ - VIEWER- tokenizer:- - ADMIN+ - VIEWERsummary: Get host info from Zeus.tags:- zeusdiff --git a/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.test.tsx b/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.test.tsxindex fb0e7f7e42..f457f97c6b 100644--- a/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.test.tsx+++ b/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.test.tsx@@ -67,4 +67,40 @@ describe('AuthCard', () => {expect(mockOnCreateServiceAccount).toHaveBeenCalledTimes(1);});++ it('shows URL for non-admin (all roles can fetch instance URL)', () => {+ render(<AuthCard {...defaultProps} isAdmin={false} />);++ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ 'http://localhost',+ );+ });++ describe('isLoadingInstanceUrl', () => {+ it('shows a skeleton and hides the URL while loading', () => {+ render(<AuthCard {...defaultProps} isAdmin isLoadingInstanceUrl />);++ expect(screen.queryByTestId('mcp-instance-url')).not.toBeInTheDocument();+ expect(document.querySelector('.ant-skeleton-input')).toBeInTheDocument();+ });++ it('does not render the copy button while loading', () => {+ render(<AuthCard {...defaultProps} isAdmin isLoadingInstanceUrl />);++ expect(+ screen.queryByRole('button', { name: 'Copy SigNoz instance URL' }),+ ).not.toBeInTheDocument();+ });++ it('shows the URL and copy button once loading is done', () => {+ render(<AuthCard {...defaultProps} isAdmin isLoadingInstanceUrl={false} />);++ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ 'http://localhost',+ );+ expect(+ screen.getByRole('button', { name: 'Copy SigNoz instance URL' }),+ ).toBeInTheDocument();+ });+ });});diff --git a/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.tsx b/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.tsxindex 60028503cc..e95efa6f02 100644--- a/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.tsx+++ b/frontend/src/container/MCPServerSettings/AuthCard/AuthCard.tsx@@ -1,3 +1,4 @@+import { Skeleton } from 'antd';import { Badge, Button } from '@signozhq/ui';import { Info, KeyRound } from '@signozhq/icons';import CopyIconButton from '../CopyIconButton';@@ -7,6 +8,7 @@ import './AuthCard.styles.scss';interface AuthCardProps {isAdmin: boolean;instanceUrl: string;+ isLoadingInstanceUrl?: boolean;onCopyInstanceUrl: () => void;onCreateServiceAccount: () => void;}@@ -14,6 +16,7 @@ interface AuthCardProps {function AuthCard({isAdmin,instanceUrl,+ isLoadingInstanceUrl = false,onCopyInstanceUrl,onCreateServiceAccount,}: AuthCardProps): JSX.Element {@@ -32,13 +35,18 @@ function AuthCard({<div className="mcp-auth-card__field"><span className="mcp-auth-card__field-label">SigNoz Instance URL</span>- <div className="mcp-auth-card__endpoint-value">- <span data-testid="mcp-instance-url">{instanceUrl}</span>- <CopyIconButton- ariaLabel="Copy SigNoz instance URL"- onCopy={onCopyInstanceUrl}- />- </div>+ {isLoadingInstanceUrl ? (+ <Skeleton.Input active size="small" />+ ) : (+ <div className="mcp-auth-card__endpoint-value">+ <span data-testid="mcp-instance-url">{instanceUrl}</span>+ <CopyIconButton+ ariaLabel="Copy SigNoz instance URL"+ onCopy={onCopyInstanceUrl}+ disabled={isLoadingInstanceUrl}+ />+ </div>+ )}</div><div className="mcp-auth-card__field">diff --git a/frontend/src/container/MCPServerSettings/MCPServerSettings.test.tsx b/frontend/src/container/MCPServerSettings/MCPServerSettings.test.tsxindex 9abad3cf2e..253ec4ef31 100644--- a/frontend/src/container/MCPServerSettings/MCPServerSettings.test.tsx+++ b/frontend/src/container/MCPServerSettings/MCPServerSettings.test.tsx@@ -6,6 +6,8 @@ const mockLogEvent = jest.fn();const mockCopyToClipboard = jest.fn();const mockHistoryPush = jest.fn();const mockUseGetGlobalConfig = jest.fn();+const mockUseGetHosts = jest.fn();+const mockUseGetTenantLicense = jest.fn();const mockToastSuccess = jest.fn();const mockToastWarning = jest.fn();@@ -19,6 +21,14 @@ jest.mock('api/generated/services/global', () => ({mockUseGetGlobalConfig(...args),}));+jest.mock('api/generated/services/zeus', () => ({+ useGetHosts: (...args: unknown[]): unknown => mockUseGetHosts(...args),+}));++jest.mock('hooks/useGetTenantLicense', () => ({+ useGetTenantLicense: (): unknown => mockUseGetTenantLicense(),+}));+jest.mock('react-use', () => ({__esModule: true,useCopyToClipboard: (): [unknown, jest.Mock] => [null, mockCopyToClipboard],@@ -47,6 +57,23 @@ jest.mock('utils/basePath', () => ({}));const MCP_URL = 'https://mcp.us.signoz.cloud/mcp';+const CUSTOM_HOST_URL = 'https://myteam.signoz.cloud';+const DEFAULT_HOST_URL = 'https://default.signoz.cloud';++function setupLicense({+ isCloudUser = true,+ isEnterpriseSelfHostedUser = false,+}: {+ isCloudUser?: boolean;+ isEnterpriseSelfHostedUser?: boolean;+} = {}): void {+ mockUseGetTenantLicense.mockReturnValue({+ isCloudUser,+ isEnterpriseSelfHostedUser,+ isCommunityUser: !isCloudUser && !isEnterpriseSelfHostedUser,+ isCommunityEnterpriseUser: false,+ });+}function setupGlobalConfig({ mcpUrl }: { mcpUrl: string | null }): void {mockUseGetGlobalConfig.mockReturnValue({@@ -55,7 +82,29 @@ function setupGlobalConfig({ mcpUrl }: { mcpUrl: string | null }): void {});}+function setupHosts({+ hosts = [],+ isLoading = false,+ isError = false,+}: {+ hosts?: { name?: string; url?: string; is_default?: boolean }[];+ isLoading?: boolean;+ isError?: boolean;+} = {}): void {+ mockUseGetHosts.mockReturnValue({+ data: isLoading || isError ? undefined : { data: { hosts } },+ isLoading,+ isError,+ });+}+describe('MCPServerSettings', () => {+ beforeEach(() => {+ // Default: cloud user, hosts loaded but empty → instanceUrl falls back to getBaseUrl()+ setupLicense();+ setupHosts();+ });+afterEach(() => {jest.clearAllMocks();});@@ -158,4 +207,145 @@ describe('MCPServerSettings', () => {'Instance URL copied to clipboard',);});++ describe('instance URL resolution', () => {+ it('uses the active custom host URL when available', async () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupHosts({+ hosts: [+ { name: 'default', url: DEFAULT_HOST_URL, is_default: true },+ { name: 'myteam', url: CUSTOM_HOST_URL, is_default: false },+ ],+ });+ const user = userEvent.setup({ pointerEventsCheck: 0 });++ render(<MCPServerSettings />);++ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ CUSTOM_HOST_URL,+ );++ await user.click(+ screen.getByRole('button', { name: 'Copy SigNoz instance URL' }),+ );++ expect(mockCopyToClipboard).toHaveBeenCalledWith(CUSTOM_HOST_URL);+ });++ it('falls back to the default host URL when no custom host exists', async () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupHosts({+ hosts: [{ name: 'default', url: DEFAULT_HOST_URL, is_default: true }],+ });+ const user = userEvent.setup({ pointerEventsCheck: 0 });++ render(<MCPServerSettings />);++ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ DEFAULT_HOST_URL,+ );++ await user.click(+ screen.getByRole('button', { name: 'Copy SigNoz instance URL' }),+ );++ expect(mockCopyToClipboard).toHaveBeenCalledWith(DEFAULT_HOST_URL);+ });++ it('falls back to browser URL when hosts request errors', async () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupHosts({ isError: true });+ const user = userEvent.setup({ pointerEventsCheck: 0 });++ render(<MCPServerSettings />);++ await user.click(+ screen.getByRole('button', { name: 'Copy SigNoz instance URL' }),+ );++ expect(mockCopyToClipboard).toHaveBeenCalledWith('http://localhost');+ });++ it('shows URL skeleton while hosts are loading', () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupHosts({ isLoading: true });++ render(<MCPServerSettings />);++ expect(screen.queryByTestId('mcp-instance-url')).not.toBeInTheDocument();+ expect(document.querySelector('.ant-skeleton-input')).toBeInTheDocument();+ });++ it('does not copy while hosts are still loading', async () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupHosts({ isLoading: true });+ userEvent.setup({ pointerEventsCheck: 0 });++ render(<MCPServerSettings />);++ expect(+ screen.queryByRole('button', { name: 'Copy SigNoz instance URL' }),+ ).not.toBeInTheDocument();+ expect(mockCopyToClipboard).not.toHaveBeenCalled();+ });++ it('disables the hosts query for non-cloud deployments', () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupLicense({ isCloudUser: false, isEnterpriseSelfHostedUser: true });++ render(<MCPServerSettings />, undefined, { role: 'ADMIN' });++ const callOptions = mockUseGetHosts.mock.calls[0]?.[0];+ expect(callOptions?.query?.enabled).toBe(false);+ });++ it('uses browser URL immediately for enterprise self-hosted (no skeleton)', async () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupLicense({ isCloudUser: false, isEnterpriseSelfHostedUser: true });+ setupHosts({ isLoading: false });+ const user = userEvent.setup({ pointerEventsCheck: 0 });++ render(<MCPServerSettings />, undefined, { role: 'ADMIN' });++ expect(+ document.querySelector('.ant-skeleton-input'),+ ).not.toBeInTheDocument();+ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ 'http://localhost',+ );++ await user.click(+ screen.getByRole('button', { name: 'Copy SigNoz instance URL' }),+ );++ expect(mockCopyToClipboard).toHaveBeenCalledWith('http://localhost');+ });++ it('enables the hosts query for all cloud users including viewers', () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupLicense({ isCloudUser: true });++ render(<MCPServerSettings />, undefined, { role: 'VIEWER' });++ const callOptions = mockUseGetHosts.mock.calls[0]?.[0];+ expect(callOptions?.query?.enabled).toBe(true);+ });++ it('shows instance URL for cloud viewer', () => {+ setupGlobalConfig({ mcpUrl: MCP_URL });+ setupLicense({ isCloudUser: true });+ setupHosts({+ hosts: [{ name: 'default', url: DEFAULT_HOST_URL, is_default: true }],+ });++ render(<MCPServerSettings />, undefined, { role: 'VIEWER' });++ expect(+ document.querySelector('.ant-skeleton-input'),+ ).not.toBeInTheDocument();+ expect(screen.getByTestId('mcp-instance-url')).toHaveTextContent(+ DEFAULT_HOST_URL,+ );+ });+ });});diff --git a/frontend/src/container/MCPServerSettings/MCPServerSettings.tsx b/frontend/src/container/MCPServerSettings/MCPServerSettings.tsxindex 8b91b73e40..517f3dbb91 100644--- a/frontend/src/container/MCPServerSettings/MCPServerSettings.tsx+++ b/frontend/src/container/MCPServerSettings/MCPServerSettings.tsx@@ -1,11 +1,13 @@-import { useCallback, useEffect, useState } from 'react';+import { useCallback, useEffect, useMemo, useState } from 'react';import { useCopyToClipboard } from 'react-use';import logEvent from 'api/common/logEvent';import ROUTES from 'constants/routes';import { SA_QUERY_PARAMS } from 'container/ServiceAccountsSettings/constants';import { useGetGlobalConfig } from 'api/generated/services/global';+import { useGetHosts } from 'api/generated/services/zeus';import history from 'lib/history';import { useAppContext } from 'providers/App/App';+import { useGetTenantLicense } from 'hooks/useGetTenantLicense';import { USER_ROLES } from 'types/roles';import { getBaseUrl } from 'utils/basePath';@@ -34,7 +36,23 @@ function MCPServerSettings(): JSX.Element {const [, copyToClipboard] = useCopyToClipboard();const isAdmin = user.role === USER_ROLES.ADMIN;- const instanceUrl = getBaseUrl();+ const { isCloudUser } = useGetTenantLicense();++ const {+ data: hostsData,+ isLoading: isLoadingHosts,+ isError: isHostsError,+ } = useGetHosts({ query: { enabled: isCloudUser } });++ const instanceUrl = useMemo(() => {+ if (isLoadingHosts || isHostsError || !hostsData) {+ return getBaseUrl();+ }+ const hosts = hostsData.data?.hosts ?? [];+ const activeHost =+ hosts.find((h) => !h.is_default) ?? hosts.find((h) => h.is_default);+ return activeHost?.url ?? getBaseUrl();+ }, [hostsData, isLoadingHosts, isHostsError]);const { data: globalConfig, isLoading: isConfigLoading } =useGetGlobalConfig();@@ -70,10 +88,13 @@ function MCPServerSettings(): JSX.Element {}, []);const handleCopyInstanceUrl = useCallback(() => {+ if (isLoadingHosts) {+ return;+ }copyToClipboard(instanceUrl);toast.success('Instance URL copied to clipboard');void logEvent(ANALYTICS.INSTANCE_URL_COPIED, {});- }, [copyToClipboard, instanceUrl]);+ }, [copyToClipboard, instanceUrl, isLoadingHosts]);const handleDocsLinkClick = useCallback((target: string) => {void logEvent(ANALYTICS.DOCS_LINK_CLICKED, { target });@@ -132,6 +153,7 @@ function MCPServerSettings(): JSX.Element {<AuthCardisAdmin={isAdmin}instanceUrl={instanceUrl}+ isLoadingInstanceUrl={isLoadingHosts}onCopyInstanceUrl={handleCopyInstanceUrl}onCreateServiceAccount={handleCreateServiceAccount}/>diff --git a/frontend/src/pages/Settings/Settings.tsx b/frontend/src/pages/Settings/Settings.tsxindex b0398e070a..85654e6b2f 100644--- a/frontend/src/pages/Settings/Settings.tsx+++ b/frontend/src/pages/Settings/Settings.tsx@@ -36,6 +36,7 @@ function SettingsPage(): JSX.Element {const isAdmin = user.role === USER_ROLES.ADMIN;const isEditor = user.role === USER_ROLES.EDITOR;+ const isViewer = user.role === USER_ROLES.VIEWER;const isWorkspaceBlocked = trialInfo?.workSpaceBlock || false;@@ -102,6 +103,13 @@ function SettingsPage(): JSX.Element {: item.isEnabled,}));}++ if (isViewer) {+ updatedItems = updatedItems.map((item) => ({+ ...item,+ isEnabled: item.key === ROUTES.MCP_SERVER ? true : item.isEnabled,+ }));+ }}if (isEnterpriseSelfHostedUser) {@@ -134,6 +142,13 @@ function SettingsPage(): JSX.Element {: item.isEnabled,}));}++ if (isViewer) {+ updatedItems = updatedItems.map((item) => ({+ ...item,+ isEnabled: item.key === ROUTES.MCP_SERVER ? true : item.isEnabled,+ }));+ }}if (!isCloudUser && !isEnterpriseSelfHostedUser) {@@ -166,6 +181,7 @@ function SettingsPage(): JSX.Element {}, [isAdmin,isEditor,+ isViewer,isCloudUser,isEnterpriseSelfHostedUser,isFetchingActiveLicense,diff --git a/frontend/src/pages/Settings/__tests__/Settings.test.tsx b/frontend/src/pages/Settings/__tests__/Settings.test.tsxindex fcd275f6f7..3488ad07fe 100644--- a/frontend/src/pages/Settings/__tests__/Settings.test.tsx+++ b/frontend/src/pages/Settings/__tests__/Settings.test.tsx@@ -82,12 +82,13 @@ describe('SettingsPage nav sections', () => {expect(screen.getByTestId(id)).toBeInTheDocument();});- it.each(['billing', 'roles', 'mcp-server'])(- 'does not render "%s" element',- (id) => {- expect(screen.queryByTestId(id)).not.toBeInTheDocument();- },- );+ it.each(['billing', 'roles'])('does not render "%s" element', (id) => {+ expect(screen.queryByTestId(id)).not.toBeInTheDocument();+ });++ it('renders "mcp-server" element', () => {+ expect(screen.getByTestId('mcp-server')).toBeInTheDocument();+ });});describe('Self-hosted Admin', () => {diff --git a/pkg/apiserver/signozapiserver/zeus.go b/pkg/apiserver/signozapiserver/zeus.goindex 36ba8a3817..406bd040e1 100644--- a/pkg/apiserver/signozapiserver/zeus.go+++ b/pkg/apiserver/signozapiserver/zeus.go@@ -27,7 +27,7 @@ func (provider *provider) addZeusRoutes(router *mux.Router) error {return err}- if err := router.Handle("/api/v2/zeus/hosts", handler.New(provider.authZ.AdminAccess(provider.zeusHandler.GetHosts), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/zeus/hosts", handler.New(provider.authZ.ViewAccess(provider.zeusHandler.GetHosts), handler.OpenAPIDef{ID: "GetHosts",Tags: []string{"zeus"},Summary: "Get host info from Zeus.",@@ -39,7 +39,7 @@ func (provider *provider) addZeusRoutes(router *mux.Router) error {SuccessStatusCode: http.StatusOK,ErrorStatusCodes: []int{http.StatusBadRequest, http.StatusUnauthorized, http.StatusForbidden, http.StatusNotFound},Deprecated: false,- SecuritySchemes: newSecuritySchemes(types.RoleAdmin),+ SecuritySchemes: newSecuritySchemes(types.RoleViewer),})).Methods(http.MethodGet).GetError(); err != nil {return err}