: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): group server tools into read-only and write or delete (#130600)
Jake Ruth8e501ed4bf85
diff --git a/products/mcp_store/README.md b/products/mcp_store/README.mdindex 318a8adad7fe..aea98acffffb 100644--- a/products/mcp_store/README.md+++ b/products/mcp_store/README.md@@ -42,6 +42,8 @@ The gateway experience has these pages and workflows:Agent access can be granted or revoked with a per-tool policy, and tool policies can be searched, changed individually, or changed in bulk.Tool discovery can be refreshed from the connected server.Tool descriptions and input schemas are available for inspection, while organization rules remain locked.+ When a server has both kinds, tools are split into read-only and write or delete groups.+ A tool counts as read-only only when the server marks it `readOnlyHint`, its name starts with a read verb, and it has no write or destructive verb.- **Team and agents**: Search agents and members, inspect their access at a glance, and open a detail page.Agent details show identity, shared servers, per-server policies, and recent calls.Member details show connection and access status across registered servers, with admin controls for enabling or disabling access.diff --git a/products/mcp_store/backend/presentation/gateway_views.py b/products/mcp_store/backend/presentation/gateway_views.pyindex eaff9e4ddb79..c30e239a70ad 100644--- a/products/mcp_store/backend/presentation/gateway_views.py+++ b/products/mcp_store/backend/presentation/gateway_views.py@@ -65,7 +65,13 @@ from ..models import (MCPToolPolicy,TeamMCPGatewayConfig,)-from ..policy import GatewayCaller, PolicyContext, is_destructive_tool, is_policy_state_allowed+from ..policy import (+ GatewayCaller,+ PolicyContext,+ is_destructive_tool,+ is_policy_state_allowed,+ is_read_only_connector_tool,+)from .visibility import slack_dev_mcp_ui_enabledlogger = structlog.get_logger(__name__)@@ -493,6 +499,9 @@ class ResolvedToolPolicySerializer(serializers.Serializer):is_destructive = serializers.BooleanField(help_text="Whether the canonical gateway heuristic treats this tool as destructive.")+ is_read_only = serializers.BooleanField(+ help_text="Whether the tool only reads data: the server marks it readOnlyHint and its name starts with a read verb and has no write or destructive verb."+ )policy_state = serializers.ChoiceField(choices=APPROVAL_STATES, help_text="Effective state for the scope.")team_state = serializers.ChoiceField(choices=APPROVAL_STATES,@@ -1165,6 +1174,7 @@ class MCPGatewayServerViewSet("description": description,"input_schema": input_schema,"is_destructive": is_destructive_tool(tool_name, annotations),+ "is_read_only": is_read_only_connector_tool(tool_name, annotations),"policy_state": resolved.state,"team_state": resolved.team_state,"locked": resolved.locked or (scope_type != "team" and resolved.team_state == "do_not_use"),diff --git a/products/mcp_store/backend/test/test_api.py b/products/mcp_store/backend/test/test_api.pyindex b529e0e65a28..6743dbd41ddb 100644--- a/products/mcp_store/backend/test/test_api.py+++ b/products/mcp_store/backend/test/test_api.py@@ -830,6 +830,7 @@ class TestMCPGatewayServerAPI(APIBaseTest):assert tools_response.status_code == status.HTTP_200_OKassert tools_response.json()["results"][0]["is_destructive"] is True+ assert tools_response.json()["results"][0]["is_read_only"] is Falseassert tools_response.json()["results"][0]["team_state"] == "do_not_use"assert active_response.status_code == status.HTTP_400_BAD_REQUESTdiff --git a/products/mcp_store/backend/test/test_policy.py b/products/mcp_store/backend/test/test_policy.pyindex f083ec93aa82..7d7dcff6470a 100644--- a/products/mcp_store/backend/test/test_policy.py+++ b/products/mcp_store/backend/test/test_policy.py@@ -4,7 +4,7 @@ from django.test import SimpleTestCasefrom parameterized import parameterized-from products.mcp_store.backend.policy import is_destructive_tool, member_preset_team_state+from products.mcp_store.backend.policy import is_destructive_tool, is_read_only_connector_tool, member_preset_team_stateclass TestDestructiveToolDetection(SimpleTestCase):@@ -28,6 +28,24 @@ class TestDestructiveToolDetection(SimpleTestCase):) -> None:assert is_destructive_tool(tool_name, annotations) is expected++class TestReadOnlyToolDetection(SimpleTestCase):+ @parameterized.expand(+ [+ ("read_verb_with_hint", "list_issues", {"readOnlyHint": True}, True),+ ("camel_case", "getIssue", {"readOnlyHint": True}, True),+ ("hint_absent", "list_issues", {}, False),+ ("hint_non_bool_ignored", "list_issues", {"readOnlyHint": "true"}, False),+ ("write_verb_ignores_hint", "create_issue", {"readOnlyHint": True}, False),+ ("chained_write_verb", "get_and_update_issue", {"readOnlyHint": True}, False),+ ("destructive_hint_wins", "get_issue", {"readOnlyHint": True, "destructiveHint": True}, False),+ ]+ )+ def test_requires_read_verb_and_hint(+ self, _name: str, tool_name: str, annotations: dict[str, Any], expected: bool+ ) -> None:+ assert is_read_only_connector_tool(tool_name, annotations) is expected+@parameterized.expand([("ask_gates_on_hint", "ask", {"destructiveHint": True}, "needs_approval"),diff --git a/products/mcp_store/frontend/gateway/GatewayServerScene.tsx b/products/mcp_store/frontend/gateway/GatewayServerScene.tsxindex 383dced7d94c..e0c3075396a7 100644--- a/products/mcp_store/frontend/gateway/GatewayServerScene.tsx+++ b/products/mcp_store/frontend/gateway/GatewayServerScene.tsx@@ -292,6 +292,7 @@ function ToolPoliciesSection(): JSX.Element {scopeIsResolving,toolPolicies,toolPoliciesLoading,+ toolPolicyGroups,toolSearch,toolsExpanded,} = useValues(gatewayServerLogic)@@ -415,6 +416,26 @@ function ToolPoliciesSection(): JSX.Element {<div className="border border-dashed rounded p-6 text-center text-secondary text-sm">No tools match “{toolSearch}”.</div>+ ) : toolPolicyGroups ? (+ <LemonCollapse+ multiple+ defaultActiveKeys={toolPolicyGroups.map((group) => group.key)}+ panels={toolPolicyGroups.map((group) => ({+ key: group.key,+ header: (+ <span className="flex items-center gap-2">+ {group.label}+ <LemonTag type="muted" size="small">+ {group.policies.length}+ </LemonTag>+ </span>+ ),+ className: 'divide-y',+ content: group.policies.map((policy) => (+ <ToolPolicyRow key={policy.tool_name} policy={policy} />+ )),+ }))}+ />) : (<div className="border rounded divide-y overflow-hidden bg-surface-primary">{displayedToolPolicies.map((policy) => (diff --git a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.tsindex f837d919671c..728ad2b2d081 100644--- a/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerLogic.test.ts@@ -156,6 +156,7 @@ function toolPolicy(toolName: string, overrides: Partial<ResolvedToolPolicyApi>description: '',input_schema: {},is_destructive: false,+ is_read_only: false,policy_state: 'approved',team_state: null,locked: false,@@ -335,6 +336,28 @@ describe('gatewayServerLogic', () => {expect(logic.values.toolPolicies).toEqual([latestPolicy])})+ it.each([+ {+ name: 'splits read-only from write or delete tools',+ readOnly: 2,+ writeOrDelete: 3,+ expected: [+ { key: 'read_only', count: 2 },+ { key: 'write_or_delete', count: 3 },+ ],+ },+ { name: 'does not group when no tool is read-only', readOnly: 0, writeOrDelete: 3, expected: null },+ ])('$name', ({ readOnly, writeOrDelete, expected }) => {+ logic.actions.loadToolPoliciesSuccess([+ ...Array.from({ length: writeOrDelete }, (_, i) => toolPolicy(`create_${i}`)),+ ...Array.from({ length: readOnly }, (_, i) => toolPolicy(`list_${i}`, { is_read_only: true })),+ ])++ expect(+ logic.values.toolPolicyGroups?.map((group) => ({ key: group.key, count: group.policies.length })) ?? null+ ).toEqual(expected)+ })+it('reports the number of tools changed by a bulk update', async () => {const editablePolicy = toolPolicy('create_issue')const lockedPolicy = toolPolicy('delete_issue', { locked: true, policy_state: 'do_not_use' })diff --git a/products/mcp_store/frontend/gateway/gatewayServerLogic.ts b/products/mcp_store/frontend/gateway/gatewayServerLogic.tsindex 35337205ab29..fed4a445f4d9 100644--- a/products/mcp_store/frontend/gateway/gatewayServerLogic.ts+++ b/products/mcp_store/frontend/gateway/gatewayServerLogic.ts@@ -57,6 +57,12 @@ export type AgentToolPolicyState = 'approved' | 'do_not_use'export const TOOL_PREVIEW_LIMIT = 10+export interface ToolPolicyGroup {+ key: 'read_only' | 'write_or_delete'+ label: string+ policies: ResolvedToolPolicyApi[]+}+function currentProjectId(): string {return String(teamLogic.values.currentTeamId)}@@ -157,6 +163,7 @@ export interface gatewayServerLogicValues {teamToolPoliciesLoading: booleantoolPolicies: ResolvedToolPolicyApi[]toolPoliciesLoading: boolean+ toolPolicyGroups: ToolPolicyGroup[] | nulltoolSearch: stringtoolsExpanded: boolean}@@ -418,6 +425,7 @@ export interface gatewayServerLogicMeta {toolsExpanded: boolean,toolSearch: string) => ResolvedToolPolicyApi[]+ toolPolicyGroups: (filteredToolPolicies: ResolvedToolPolicyApi[]) => ToolPolicyGroup[] | nullavailableScopes: (server: MCPGatewayServerApi | null,serviceAccounts: MCPServiceAccountApi[],@@ -784,6 +792,19 @@ export const gatewayServerLogic = kea<gatewayServerLogicType>([? filteredToolPolicies: filteredToolPolicies.slice(0, TOOL_PREVIEW_LIMIT),],+ toolPolicyGroups: [+ (s) => [s.filteredToolPolicies],+ (filteredToolPolicies: ResolvedToolPolicyApi[]): ToolPolicyGroup[] | null => {+ const readOnly = filteredToolPolicies.filter((policy) => policy.is_read_only)+ const writeOrDelete = filteredToolPolicies.filter((policy) => !policy.is_read_only)+ return readOnly.length && writeOrDelete.length+ ? [+ { key: 'read_only', label: 'Read-only tools', policies: readOnly },+ { key: 'write_or_delete', label: 'Write or delete tools', policies: writeOrDelete },+ ]+ : null+ },+ ],// Members always manage their own policy. Admins can also manage the// team baseline, and agent scopes follow the team setting.availableScopes: [diff --git a/products/mcp_store/frontend/generated/api.schemas.ts b/products/mcp_store/frontend/generated/api.schemas.tsindex fdc0dd4c3982..8425e014c163 100644--- a/products/mcp_store/frontend/generated/api.schemas.ts+++ b/products/mcp_store/frontend/generated/api.schemas.ts@@ -677,6 +677,8 @@ export interface ResolvedToolPolicyApi {input_schema: ResolvedToolPolicyApiInputSchema/** Whether the canonical gateway heuristic treats this tool as destructive. */is_destructive: boolean+ /** Whether the tool only reads data: the server marks it readOnlyHint and its name starts with a read verb and has no write or destructive verb. */+ is_read_only: boolean/** Effective state for the scope.** * `approved` - Approveddiff --git a/products/tasks/frontend/components/TaskConnectorsPicker/CyclotronJobInputTaskConnectors.stories.tsx b/products/tasks/frontend/components/TaskConnectorsPicker/CyclotronJobInputTaskConnectors.stories.tsxindex 4bd23762218c..1ba40e6fddac 100644--- a/products/tasks/frontend/components/TaskConnectorsPicker/CyclotronJobInputTaskConnectors.stories.tsx+++ b/products/tasks/frontend/components/TaskConnectorsPicker/CyclotronJobInputTaskConnectors.stories.tsx@@ -67,6 +67,7 @@ function resolvedTool(toolName: string, policyState: MCPToolApprovalStateEnumApidescription: `${toolName} tool`,input_schema: {},is_destructive: policyState === 'do_not_use',+ is_read_only: false,policy_state: policyState,team_state: null,locked: false,diff --git a/products/tasks/frontend/components/TaskConnectorsPicker/taskConnectorsPickerLogic.test.ts b/products/tasks/frontend/components/TaskConnectorsPicker/taskConnectorsPickerLogic.test.tsindex e5f11da12f56..b0f1e671b41d 100644--- a/products/tasks/frontend/components/TaskConnectorsPicker/taskConnectorsPickerLogic.test.ts+++ b/products/tasks/frontend/components/TaskConnectorsPicker/taskConnectorsPickerLogic.test.ts@@ -82,6 +82,7 @@ function resolvedTool(toolName: string, policyState: MCPToolApprovalStateEnumApidescription: '',input_schema: {},is_destructive: false,+ is_read_only: false,policy_state: policyState,team_state: null,locked: false,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex c5c45a521b1d..2cffd37cb67c 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -73819,6 +73819,8 @@ export namespace Schemas {input_schema: ResolvedToolPolicyInputSchema;/** Whether the canonical gateway heuristic treats this tool as destructive. */is_destructive: boolean;+ /** Whether the tool only reads data: the server marks it readOnlyHint and its name starts with a read verb and has no write or destructive verb. */+ is_read_only: boolean;/** Effective state for the scope.** * `approved` - Approved