Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mcp-store): reorder agent row controls on the server detail page (#93767)

Chris Volzerb550f105ed89
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 087adbbc10ea..1791c7876a69 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8224,6 +8224,10 @@ snapshots:
hash: v1.k794b7964.204bddb0ec47c7a02409a9f49859ba7043d999b47fd909ac945277859bac2d0a.OGBvspVEX9BnlqZ6lq0amBQE5_vNK0DQ4VaUcdwtBtY
scenes-app-mcp-analytics-tool-quality-charts--settled-window--light:
hash: v1.k794b7964.d6be31937ca7321d00b299c38f6ba24480b8f1db772edce08c5c501d03694892.aSRmrM3xFQg0JNbAWh8tsjnN1GKBG1QlMLGOTK67oPo
+ scenes-app-mcp-gateway-server--page--dark:
+ hash: v1.k794b7964.181ef8620fa10882b33a2277dd7729a466e6faa6dd5d47fbf5a8bb2d3d90428e.WgP3PJHt3L3hZCpRpi_ZUpa5I2vqj3yZ-pin7RGupNA
+ scenes-app-mcp-gateway-server--page--light:
+ hash: v1.k794b7964.d12187b259fe0e6231d155a107df2a36acd34a9753f5e033fe550810e3670f1e.C5tJ-Tmk7BqN6ybHBrzwXiqIjZjQlyitOeBl0XDCfR8
scenes-app-mcp-servers-connect-server-modal--catalog-api-key-template--dark:
hash: v1.k794b7964.88b9762624eed0dad1e68107a83d764446614ec109f78047d3cb7932cbf8512c.1zVCJCmQ7XSt2Cw7Yz8Lqv_GPYFPE8PL0k8tHi_b6Lc
scenes-app-mcp-servers-connect-server-modal--catalog-api-key-template--light:
diff --git a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx
index 2b5cc28bf785..84d1ca91f261 100644
--- a/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx
+++ b/products/desktop/packages/ui/src/features/mcp-gateway/components/parts/GatewayServerDetail.tsx
@@ -1028,7 +1028,7 @@ function AccessSection({
className="group border-gray-5 border-b px-3 py-2 last:border-b-0"
>
<RobotAvatar />
- <Flex direction="column" className="min-w-0 flex-1">
+ <div className="flex min-w-0 flex-1 flex-col">
<Text truncate className="font-medium text-sm">
{agent.name}
</Text>
@@ -1038,51 +1038,36 @@ function AccessSection({
isYourShare ? "you" : gatewayUserName(agent.user)
}`}
</Text>
- </Flex>
+ </div>
+ {/* Revoking removes only the caller's own share, so the scope
+ toggle and Revoke appear only on rows backed by the caller's
+ connection. */}
{isYourShare && (
- <AgentScopeToggle
- value={agent.scope}
- disabled={accessPending}
- onChange={(scope) =>
- onSetAgentScope(
- agent.service_account_id,
- agent.name,
- scope,
- )
- }
- />
+ <div className="flex shrink-0 items-center gap-3">
+ <AgentScopeToggle
+ value={agent.scope}
+ disabled={accessPending}
+ onChange={(scope) =>
+ onSetAgentScope(
+ agent.service_account_id,
+ agent.name,
+ scope,
+ )
+ }
+ />
+ <Button
+ variant="ghost"
+ color="red"
+ size="1"
+ className="opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100"
+ onClick={() =>
+ onRevokeAgent(agent.service_account_id, agent.name)
+ }
+ >
+ <X size={11} /> Revoke
+ </Button>
+ </div>
)}
- {/* Revoking removes only the caller's own share, so it is
- offered only on rows backed by the caller's connection. */}
- {isYourShare && (
- <Button
- variant="ghost"
- color="red"
- size="1"
- className="opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100"
- onClick={() =>
- onRevokeAgent(agent.service_account_id, agent.name)
- }
- >
- <X size={11} /> Revoke
- </Button>
- )}
- <Flex align="center" gap="2" className="shrink-0">
- <span
- className={`h-[6px] w-[6px] rounded-full ${
- agent.status === "active" ? "bg-(--green-9)" : "bg-gray-8"
- }`}
- />
- <Text color="gray" className="text-xs">
- {agent.status === "active"
- ? `Active${
- formatAgo(agent.last_active_at)
- ? ` ${formatAgo(agent.last_active_at)}`
- : ""
- }`
- : "Paused"}
- </Text>
- </Flex>
</Flex>
);
})}
diff --git a/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx b/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx
index 74f1da07f310..c8ae13d2c577 100644
--- a/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx
+++ b/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx
@@ -186,42 +186,39 @@ export function GatewayAccessSection(): JSX.Element | null {
: ` · shared ${agent.scope === 'team' ? 'to the team ' : ''}by ${agent.user.first_name || agent.user.email}`}
</div>
</div>
- {sharedByYou && (
- <AgentGrantScopeControl
- accountId={agent.service_account_id}
- serverId={server.id}
- scope={agent.scope}
- />
- )}
- {sharedByYou ? (
- <LemonButton
- size="xsmall"
- type="tertiary"
- status="danger"
- icon={<IconX />}
- loading={agentServerAccessLoadingKeys.has(
- agentServerAccessKey(agent.service_account_id, server.id)
- )}
- onClick={() => setAgentServerAccess(agent.service_account_id, server.id, false)}
- >
- Revoke
- </LemonButton>
- ) : (
- <RemoveAllSharesButton
- accountId={agent.service_account_id}
- accountName={agent.name}
- serverId={server.id}
- serverName={server.name}
- shareCount={agentShareCount}
- />
- )}
- <LemonTag type={agent.status === 'active' ? 'success' : 'muted'} size="small">
- {agent.status === 'active'
- ? agent.last_active_at
- ? `Active ${dayjs(agent.last_active_at).fromNow()}`
- : 'Active'
- : 'Paused'}
- </LemonTag>
+ <div className="flex shrink-0 items-center gap-3">
+ {sharedByYou && (
+ <AgentGrantScopeControl
+ accountId={agent.service_account_id}
+ serverId={server.id}
+ scope={agent.scope}
+ />
+ )}
+ {sharedByYou ? (
+ <LemonButton
+ size="xsmall"
+ type="tertiary"
+ status="danger"
+ icon={<IconX />}
+ loading={agentServerAccessLoadingKeys.has(
+ agentServerAccessKey(agent.service_account_id, server.id)
+ )}
+ onClick={() =>
+ setAgentServerAccess(agent.service_account_id, server.id, false)
+ }
+ >
+ Revoke
+ </LemonButton>
+ ) : (
+ <RemoveAllSharesButton
+ accountId={agent.service_account_id}
+ accountName={agent.name}
+ serverId={server.id}
+ serverName={server.name}
+ shareCount={agentShareCount}
+ />
+ )}
+ </div>
</div>
)
})}
diff --git a/products/mcp_store/frontend/gateway/GatewayServerScene.stories.tsx b/products/mcp_store/frontend/gateway/GatewayServerScene.stories.tsx
new file mode 100644
index 000000000000..7d3cdabb94af
--- /dev/null
+++ b/products/mcp_store/frontend/gateway/GatewayServerScene.stories.tsx
@@ -0,0 +1,154 @@
+import { MOCK_DEFAULT_BASIC_USER, MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_USER } from 'lib/api.mock'
+
+import { Meta, StoryObj } from '@storybook/react'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import { GatewayAgentAccessApi, MCPGatewayServerApi, UserBasicApi } from '../generated/api.schemas'
+
+const SERVER_ID = 'srv-linear'
+
+const you: UserBasicApi = {
+ id: MOCK_DEFAULT_BASIC_USER.id,
+ uuid: MOCK_DEFAULT_BASIC_USER.uuid,
+ distinct_id: MOCK_DEFAULT_BASIC_USER.uuid,
+ first_name: MOCK_DEFAULT_BASIC_USER.first_name,
+ last_name: '',
+ email: MOCK_DEFAULT_BASIC_USER.email,
+ hedgehog_config: null,
+}
+
+const teammate: UserBasicApi = {
+ id: 9001,
+ uuid: '0198a2c4-2b1e-7d00-9c2b-1a2b3c4d5e6f',
+ distinct_id: '0198a2c4-2b1e-7d00-9c2b-1a2b3c4d5e6f',
+ first_name: 'Grace',
+ last_name: 'Hopper',
+ email: '[email protected]',
+ hedgehog_config: null,
+}
+
+const agentShare = (
+ handle: string,
+ name: string,
+ overrides: Partial<GatewayAgentAccessApi> = {}
+): GatewayAgentAccessApi => ({
+ service_account_id: `sa-${handle}`,
+ user: you,
+ scope: 'team',
+ name,
+ handle,
+ status: 'active',
+ last_active_at: null,
+ granted_by: null,
+ ...overrides,
+})
+
+const server: MCPGatewayServerApi = {
+ id: SERVER_ID,
+ name: 'Linear',
+ url: 'https://mcp.linear.app/mcp',
+ description: 'Issues, projects, and cycles.',
+ category: 'productivity',
+ template_auth_type: 'oauth',
+ auth_type: 'oauth',
+ is_team_enabled: true,
+ icon_key: '',
+ icon_domain: 'linear.app',
+ docs_url: 'https://linear.app/docs',
+ template_id: 'tpl-linear',
+ tool_count: 12,
+ connections: [
+ {
+ installation_id: 'inst-you',
+ user: you,
+ last_used_at: '2024-07-09T10:00:00Z',
+ pending_oauth: false,
+ needs_reauth: false,
+ },
+ {
+ installation_id: 'inst-teammate',
+ user: teammate,
+ last_used_at: null,
+ pending_oauth: false,
+ needs_reauth: false,
+ },
+ ],
+ your_connection: {
+ installation_id: 'inst-you',
+ is_enabled: true,
+ pending_oauth: false,
+ needs_reauth: false,
+ last_used_at: '2024-07-09T10:00:00Z',
+ },
+ agents: [
+ agentShare('posthog-support', 'Support agent', { scope: 'personal' }),
+ agentShare('posthog-scout', 'Scout agent', { last_active_at: '2024-07-09T11:24:00Z' }),
+ agentShare('posthog-workflow', 'Workflow agent'),
+ agentShare('release-notes', 'Release notes agent', { user: teammate, status: 'paused' }),
+ ],
+ revoked_user_ids: [],
+ is_revoked_for_you: false,
+ created_by: you,
+ created_at: '2024-06-01T00:00:00Z',
+ updated_at: '2024-07-09T00:00:00Z',
+}
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/MCP gateway/Server',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ mockDate: '2024-07-09T12:00:00Z',
+ pageUrl: urls.mcpGatewayServer(SERVER_ID),
+ featureFlags: [FEATURE_FLAGS.MCP_GATEWAY],
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ // The default mock user carries no id, and the agent rows compare ids to find your own shares.
+ 'api/users/@me/': {
+ ...MOCK_DEFAULT_USER,
+ id: MOCK_DEFAULT_BASIC_USER.id,
+ organization: MOCK_DEFAULT_ORGANIZATION,
+ pending_invites: [],
+ },
+ 'api/projects/:team_id/mcp_gateway/config/': {
+ allow_custom_servers: false,
+ allow_member_agent_access: true,
+ default_servers_enabled: true,
+ registered_template_ids: ['tpl-linear'],
+ is_admin: true,
+ },
+ 'api/projects/:team_id/mcp_gateway/servers/': {
+ count: 1,
+ next: null,
+ previous: null,
+ results: [server],
+ },
+ 'api/projects/:team_id/mcp_gateway/servers/:id/': server,
+ 'api/projects/:team_id/mcp_gateway/servers/:id/tools/': { results: [] },
+ 'api/projects/:team_id/mcp_gateway/service_accounts/': {
+ count: 0,
+ next: null,
+ previous: null,
+ results: [],
+ },
+ 'api/projects/:team_id/mcp_gateway/rules/': { count: 0, next: null, previous: null, results: [] },
+ 'api/projects/:team_id/mcp_gateway/members/': { count: 0, next: null, previous: null, results: [] },
+ 'api/projects/:team_id/mcp_servers/': { count: 0, next: null, previous: null, results: [] },
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+// An admin who connected the server and shared it with three agents, plus one teammate share.
+export const Page: Story = {}