: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(mcp_store): default agent server shares to team scope (#83228)
Chris Volzerc40384599a4f
diff --git a/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx b/products/mcp_store/frontend/gateway/GatewayServerAccess.tsxindex 6cd59373a96b..ecd143b0c0bd 100644--- a/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx+++ b/products/mcp_store/frontend/gateway/GatewayServerAccess.tsx@@ -16,7 +16,7 @@ import { dayjs } from 'lib/dayjs'import { defaultAgentGrantPolicy, isPolicyStateAllowedByCeiling } from './gatewayPolicyUtils'import { AgentToolPolicyState, gatewayServerLogic } from './gatewayServerLogic'-import { AgentGrantScopeControl, RemoveAllSharesButton, toProfileUser } from './gatewayUtils'+import { AGENT_GRANT_SCOPE_OPTIONS, AgentGrantScopeControl, RemoveAllSharesButton, toProfileUser } from './gatewayUtils'import { agentServerAccessKey, mcpGatewayLogic, memberServerAccessKey } from './mcpGatewayLogic'const AGENT_POLICY_OPTIONS = [@@ -258,6 +258,7 @@ function GatewayAgentAccessModal(): JSX.Element | null {const {agentAccessModalOpen,agentAccessPolicyMap,+ agentAccessScope,agentAccessSelectedId,agentShareDisabledReason,agentServerAccessLoadingKeys,@@ -270,6 +271,7 @@ function GatewayAgentAccessModal(): JSX.Element | null {const {closeAgentAccessModal,loadTeamToolPolicies,+ setAgentAccessScope,setAgentAccessSelectedId,setAgentAccessToolPolicy,setAllAgentAccessTools,@@ -340,6 +342,21 @@ function GatewayAgentAccessModal(): JSX.Element | null {{agentAccessSelectedId && (<>+ <div className="flex items-center justify-between gap-3">+ <div>+ <div className="font-semibold">Share with</div>+ <div className="text-sm text-secondary">+ A team share lets the agent use your connection for every run in this project.+ </div>+ </div>+ <LemonSegmentedButton+ size="small"+ value={agentAccessScope}+ options={AGENT_GRANT_SCOPE_OPTIONS}+ onChange={setAgentAccessScope}+ />+ </div>+<div className="flex items-center justify-between gap-3"><div><div className="font-semibold">Tool access</div>diff --git a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.tsindex 10f94ad9940f..5233003a462f 100644--- a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts@@ -381,7 +381,7 @@ describe('gatewayServerLogic', () => {expect(mockServiceAccountAccess).toHaveBeenCalledWith(expect.any(String), account.id, {gateway_server_id: 'server-id',enabled: true,- scope: 'personal',+ scope: 'team',policies: [{ tool_name: 'list_issues', policy_state: 'approved' },{ tool_name: 'create_issue', policy_state: 'do_not_use' },@@ -390,6 +390,25 @@ describe('gatewayServerLogic', () => {expect(logic.values.agentAccessModalOpen).toBe(false)})+ it('sends the scope picked in the share modal instead of the team default', async () => {+ const account = serviceAccount()+ parentLogic.actions.loadServiceAccountsSuccess([account])+ logic.actions.openAgentAccessModal()+ logic.actions.loadTeamToolPoliciesSuccess([toolPolicy('list_issues')])+ logic.actions.setAgentAccessSelectedId(account.id)+ logic.actions.setAgentAccessScope('personal')++ await expectLogic(logic, () => {+ logic.actions.submitAgentAccess()+ }).toFinishAllListeners()++ expect(mockServiceAccountAccess).toHaveBeenCalledWith(+ expect.any(String),+ account.id,+ expect.objectContaining({ scope: 'personal' })+ )+ })+it.each([{condition: 'the team server is off',diff --git a/products/mcp_store/frontend/gateway/gatewayServerLogic.ts b/products/mcp_store/frontend/gateway/gatewayServerLogic.tsindex 917ac52db9fc..e232127ae98b 100644--- a/products/mcp_store/frontend/gateway/gatewayServerLogic.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerLogic.ts@@ -29,6 +29,7 @@ import {} from '../generated/api'import {GatewayMemberSummaryApi,+ MCPAgentGrantScopeEnumApi,MCPGatewayServerApi,MCPToolApprovalStateEnumApi,ResolvedToolPolicyApi,@@ -131,6 +132,7 @@ export interface gatewayServerLogicValues {serviceAccountsLoading: boolean // mcpGatewayLogicagentAccessModalOpen: booleanagentAccessPolicyMap: Record<string, AgentToolPolicyState>+ agentAccessScope: MCPAgentGrantScopeEnumApiagentAccessSelectedId: string | nullagentShareDisabledReason: string | undefinedagentSharesByAccountId: Record<string, AgentServerShare>@@ -215,13 +217,13 @@ export interface gatewayServerLogicActions {accountId: string,serverId: string,enabled: boolean,- scope?: import('../generated/api.schemas').MCPAgentGrantScopeEnumApi | undefined,+ scope?: MCPAgentGrantScopeEnumApi | undefined,policies?: import('../generated/api.schemas').ToolPolicyEntryApi[] | undefined) => {accountId: stringenabled: booleanpolicies: import('../generated/api.schemas').ToolPolicyEntryApi[] | undefined- scope: import('../generated/api.schemas').MCPAgentGrantScopeEnumApi+ scope: MCPAgentGrantScopeEnumApiserverId: string} // mcpGatewayLogicsetAgentServerAccessSuccess: (@@ -291,6 +293,9 @@ export interface gatewayServerLogicActions {returnToServers: () => {value: true}+ setAgentAccessScope: (scope: MCPAgentGrantScopeEnumApi) => {+ scope: MCPAgentGrantScopeEnumApi+ }setAgentAccessSelectedId: (accountId: string | null) => {accountId: string | null}@@ -487,6 +492,7 @@ export const gatewayServerLogic = kea<gatewayServerLogicType>([showAgentAccessModal: true,closeAgentAccessModal: true,setAgentAccessSelectedId: (accountId: string | null) => ({ accountId }),+ setAgentAccessScope: (scope: MCPAgentGrantScopeEnumApi) => ({ scope }),setAgentAccessToolPolicy: (toolName: string, state: AgentToolPolicyState) => ({ toolName, state }),setAllAgentAccessTools: (state: AgentToolPolicyState) => ({ state }),submitAgentAccess: true,@@ -626,6 +632,14 @@ export const gatewayServerLogic = kea<gatewayServerLogicType>([setAgentServerAccessSuccess: () => ({}),},],+ agentAccessScope: [+ 'team' as MCPAgentGrantScopeEnumApi,+ {+ setAgentAccessScope: (_, { scope }) => scope,+ closeAgentAccessModal: () => 'team',+ setAgentServerAccessSuccess: () => 'team',+ },+ ],requestedAgentScopeId: [null as string | null,{@@ -847,7 +861,13 @@ export const gatewayServerLogic = kea<gatewayServerLogicType>([values.agentAccessPolicyMap[policy.tool_name] ??defaultAgentGrantPolicy(policy.tool_name, policy.team_state, policy.is_destructive),}))- actions.setAgentServerAccess(values.agentAccessSelectedId, values.server.id, true, 'personal', policies)+ actions.setAgentServerAccess(+ values.agentAccessSelectedId,+ values.server.id,+ true,+ values.agentAccessScope,+ policies+ )},syncScopeFromUrl: async ({ scopeParam }, breakpoint) => {await breakpoint(0)diff --git a/products/mcp_store/frontend/gateway/gatewayUtils.tsx b/products/mcp_store/frontend/gateway/gatewayUtils.tsxindex a6244b9414e6..5b41c13c2a63 100644--- a/products/mcp_store/frontend/gateway/gatewayUtils.tsx+++ b/products/mcp_store/frontend/gateway/gatewayUtils.tsx@@ -42,7 +42,7 @@ export function credentialOwnerLabel(owner: UserBasicApi, grantScope: string): sreturn grantScope === 'team' ? `via ${name}'s connection (team share)` : `via ${name}'s connection`}-const AGENT_GRANT_SCOPE_OPTIONS: { value: MCPAgentGrantScopeEnumApi; label: string; tooltip: string }[] = [+export const AGENT_GRANT_SCOPE_OPTIONS: { value: MCPAgentGrantScopeEnumApi; label: string; tooltip: string }[] = [{value: 'personal',label: 'Just my agents',diff --git a/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts b/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.tsindex 9d47704a79d3..ff474db428d0 100644--- a/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts+++ b/products/mcp_store/frontend/gateway/mcpGatewayLogic.test.ts@@ -700,10 +700,10 @@ describe('mcpGatewayLogic', () => {})// The endpoint defaults an omitted scope back to personal, so a share sent without- // one silently demotes a team share.+ // one silently demotes a team share. The action fills in 'team', the product default.it.each([- ['team' as const, 'team'],- [undefined, 'personal'],+ ['personal' as const, 'personal'],+ [undefined, 'team'],])('sends scope %s as %s when sharing a server with an agent', async (requested, expected) => {mockServiceAccountAccess.mockResolvedValue(serviceAccountWithShare(expected as MCPAgentGrantScopeEnumApi))diff --git a/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts b/products/mcp_store/frontend/gateway/mcpGatewayLogic.tsindex 1941737f969d..03080032b8c7 100644--- a/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts+++ b/products/mcp_store/frontend/gateway/mcpGatewayLogic.ts@@ -730,7 +730,7 @@ export const mcpGatewayLogic = kea<mcpGatewayLogicType>([accountId: string,serverId: string,enabled: boolean,- scope: MCPAgentGrantScopeEnumApi = 'personal',+ scope: MCPAgentGrantScopeEnumApi = 'team',policies?: ToolPolicyEntryApi[]) => ({accountId,