: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(signals): per-scout MCP server selection from team-shared servers (#78385)
Chris Volzerd789aec2f7fb
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 0d335d4ab2ac..783a994aabce 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6434,6 +6434,14 @@ snapshots:hash: v1.k794b7964.570e5dddd645996b94ff94b2c563b32ced3793db3ab5ccf360d16126af3b9a0b.WC_VEZ1N_iX-o4r11w15QWfD8Nzo1gFerTznKiaIX84scenes-app-inbox-scene--self-driving-verdict-pending--light:hash: v1.k794b7964.1d230f03b5a074e0816ee4c5dd1b4591cfdf86bb602971a6233019985f1c2677.h7Zlyp6gh4AnCQRve-W4zeSDnhAhhqVM1FIqiYN1gNA+ scenes-app-inbox-scoutmcpserverspicker--create-dialog-variant--dark:+ hash: v1.k794b7964.afe2203f4dd53373a3203fcfa611b5b65555341bdc2fc7fd73c15c2d83914600.O4kSRnOgICuQDkyD2HJCwBXdzE-KwsfzWT98nm43_5A+ scenes-app-inbox-scoutmcpserverspicker--create-dialog-variant--light:+ hash: v1.k794b7964.52ea24b706c17b6194aa901ede7083b98628a47b85893fa67fea5060e27aae0c.-CvgHcWxOm0IRQxBZw2wgeHd3sAcJn4jfgdkqmxpt9w+ scenes-app-inbox-scoutmcpserverspicker--scout-settings-variant--dark:+ hash: v1.k794b7964.cb0a021303b103cdcd037db93be44c2c5eae3e59494ab8a726ac8e430f631dfd.n4BzfjRbtrkqXUS8HZwDAYrPQHYDeqCHuny9Z4Oz134+ scenes-app-inbox-scoutmcpserverspicker--scout-settings-variant--light:+ hash: v1.k794b7964.2f1013abc412adb4544bca6a00209d3051c46969db69d4242ab201ecf5d189f3.YVfbrzpaRzPwuCbeFXmaVOLla0fvhHmAm1CkuaKWCLIscenes-app-inbox-signalsourcespanel--armed-but-tools-off--dark:hash: v1.k794b7964.dad07e3272e433a69b81e55d5fac37d75d3f743154490c1ff3c5ef57d657be16.4cTh_S35TMTgXe_HQWzOP8HRN-aUWN9DNUKLTgmMoj4scenes-app-inbox-signalsourcespanel--armed-but-tools-off--light:diff --git a/products/mcp_store/backend/agents.py b/products/mcp_store/backend/agents.pyindex 7a3947843746..b79339b9a634 100644--- a/products/mcp_store/backend/agents.py+++ b/products/mcp_store/backend/agents.py@@ -165,7 +165,7 @@ class GatewayAgentPrincipal:whose MCP grants the run may use.`credential_owner_id` is None for a run nobody owns (an autonomous support- reply, a creatorless scout). Such a principal reaches team-scoped grants+ reply, any scout run). Such a principal reaches team-scoped grantsonly, never a member's personal grant."""diff --git a/products/mcp_store/backend/facade/api.py b/products/mcp_store/backend/facade/api.pyindex d5508d27d284..59b5b947df1a 100644--- a/products/mcp_store/backend/facade/api.py+++ b/products/mcp_store/backend/facade/api.py@@ -140,6 +140,7 @@ def _mounts_for_agent_run(team_id: int,agent_account: MCPServiceAccount,credential_owner_id: int | None,+ allowed_gateway_server_ids: list[str] | None = None,) -> list[tuple[MCPServiceAccountServerAccess, MCPServerInstallation]]:"""The (grant, credential) pairs this run mounts.@@ -159,7 +160,13 @@ def _mounts_for_agent_run(agent catalog lists every reachable grant and the proxy's `credential_owner`query parameter lets a run name a teammate's team share instead. Selectionis confined to the grants the run already reaches, so it never escalates.++ `allowed_gateway_server_ids` narrows the mounts to the listed gateway+ servers (a scout's per-scout selection). It gates every grant regardless of+ scope, so a run that passes it mounts exactly the selected servers and+ nothing else. None leaves mounts unfiltered; an empty list mounts nothing."""+ allowed = {str(server_id) for server_id in allowed_gateway_server_ids or []}rows = (MCPServiceAccountServerAccess.objects.for_team(team_id).filter(service_account=agent_account)@@ -172,6 +179,8 @@ def _mounts_for_agent_run(list)for access in rows:+ if allowed_gateway_server_ids is not None and str(access.gateway_server_id) not in allowed:+ continue# Same resolution the gateway proxy and the API serializers use, so a# grant whose credential drifted off its team, server, or owner is# dropped here too instead of being mounted into the sandbox.@@ -266,6 +275,7 @@ def get_installations_for_sandbox(task_origin: str | None = None,task_agent_key: str | None = None,credential_owner_id: int | None = None,+ allowed_gateway_server_ids: list[str] | None = None,) -> list[ActiveInstallationInfo]:"""Return MCP installations for sandbox agent use.@@ -288,6 +298,10 @@ def get_installations_for_sandbox(is provided. When the user has a ready personal installation for the sameURL as a shared one, only the personal one is returned — the user acts asthemselves rather than through the shared credential.++ ``allowed_gateway_server_ids`` narrows the agent mounts to the listed+ gateway servers regardless of grant scope (a scout's per-scout selection);+ see ``_mounts_for_agent_run``. It only applies on the agent path."""try:base_queryset = MCPServerInstallation.objects.filter(team_id=team_id, is_enabled=True).select_related(@@ -325,7 +339,9 @@ def get_installations_for_sandbox(task_origin=task_origin,)else:- agent_mounts = _mounts_for_agent_run(team_id, agent_account, credential_owner_id)+ agent_mounts = _mounts_for_agent_run(+ team_id, agent_account, credential_owner_id, allowed_gateway_server_ids+ )else:shared_queryset = base_queryset.filter(scope="shared")shared_queryset = shared_queryset.filter(diff --git a/products/mcp_store/backend/gateway.py b/products/mcp_store/backend/gateway.pyindex aa27ca88e777..9f1964f8c3be 100644--- a/products/mcp_store/backend/gateway.py+++ b/products/mcp_store/backend/gateway.py@@ -106,8 +106,8 @@ def reachable_agent_grants(team_id: int, credential_owner_id: int | None) -> Q:"""The grants an agent run may use: the run's own credential owner's grantsat any scope, plus every member's team-scoped grants.- A run with no credential owner (an autonomous support reply, a creatorless- scout) reaches team-scoped grants only. Grant rows with no user resolve for+ A run with no credential owner (an autonomous support reply, any scout+ run) reaches team-scoped grants only. Grant rows with no user resolve fornobody, so they are excluded from every lane.An admin's per-member revocation of the server applies here as well as ondiff --git a/products/mcp_store/backend/models.py b/products/mcp_store/backend/models.pyindex 5f905e02595b..cf63871380c3 100644--- a/products/mcp_store/backend/models.py+++ b/products/mcp_store/backend/models.py@@ -39,7 +39,7 @@ SCOPE_CHOICES = [# How far an agent grant reaches. "personal" applies only to runs whose# credential owner is the granting member; "team" lets any of the team's agent# runs borrow that member's credential, including runs with no owner at all-# (autonomous support replies, creatorless scouts). It never lets another human+# (autonomous support replies, scout runs). It never lets another human# use the credential.AGENT_GRANT_SCOPE_CHOICES = [("personal", "Personal"),diff --git a/products/mcp_store/backend/test/test_facade.py b/products/mcp_store/backend/test/test_facade.pyindex 6021429c6de9..af803f6978f9 100644--- a/products/mcp_store/backend/test/test_facade.py+++ b/products/mcp_store/backend/test/test_facade.py@@ -480,6 +480,52 @@ class TestGetInstallationsForSandbox(BaseTest):assert principal is not Noneassert principal.credential_owner_id is None+ def test_per_scout_allowlist_gates_grants_of_every_scope(self) -> None:+ account = self._support_agent()+ teammate = User.objects.create_and_join(self.organization, "[email protected]", "password")+ picked_server = self._create_gateway_server(name="Picked", url="https://picked.example.com/mcp")+ dropped_server = self._create_gateway_server(name="Dropped", url="https://dropped.example.com/mcp")+ picked = self._create_installation(user=teammate, gateway_server=picked_server, url=picked_server.url)+ dropped = self._create_installation(user=teammate, gateway_server=dropped_server, url=dropped_server.url)+ self._grant(account, picked_server, user=teammate, installation=picked, scope="team")+ self._grant(account, dropped_server, user=teammate, installation=dropped, scope="team")++ def resolve(allowed: list[str] | None) -> set[str]:+ # No credential owner, like a scout run: only team shares are reachable, and the+ # allowlist picks which of them mount.+ return {+ result.id+ for result in get_installations_for_sandbox(+ self.team.id,+ task_origin="support_reply",+ task_agent_key="support",+ allowed_gateway_server_ids=allowed,+ )+ }++ assert resolve([str(picked_server.id)]) == {str(picked.id)}+ # An empty selection mounts nothing at all: team shares are gated too, so a scout+ # with no servers selected runs without MCP servers.+ assert resolve([]) == set()+ assert resolve(None) == {str(picked.id), str(dropped.id)}++ def test_per_scout_allowlist_gates_a_credential_owners_personal_grant_too(self) -> None:+ account = self._support_agent()+ server = self._create_gateway_server(name="Owned", url="https://owned.example.com/mcp")+ other_server = self._create_gateway_server(name="Other", url="https://other.example.com/mcp")+ owned = self._create_installation(gateway_server=server, url=server.url)+ self._grant(account, server, user=self.user, installation=owned)++ results = get_installations_for_sandbox(+ self.team.id,+ task_origin="support_reply",+ task_agent_key="support",+ credential_owner_id=self.user.id,+ allowed_gateway_server_ids=[str(other_server.id)],+ )++ assert results == []+def test_owner_credential_wins_over_a_teammates_team_share_of_the_same_server(self) -> None:account = self._support_agent()teammate = User.objects.create_and_join(self.organization, "[email protected]", "password")diff --git a/products/signals/backend/migrations/0091_signalscoutconfig_mcp_gateway_server_ids.py b/products/signals/backend/migrations/0091_signalscoutconfig_mcp_gateway_server_ids.pynew file mode 100644index 000000000000..f428c19b2c33--- /dev/null+++ b/products/signals/backend/migrations/0091_signalscoutconfig_mcp_gateway_server_ids.py@@ -0,0 +1,17 @@+# Generated by Django 5.2.14 on 2026-08-05 19:10++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0090_signal_scout_run_recent_idx"),+ ]++ operations = [+ migrations.AddField(+ model_name="signalscoutconfig",+ name="mcp_gateway_server_ids",+ field=models.JSONField(db_default=[], default=list),+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex e3027c4830bc..2ebe7def0465 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0090_signal_scout_run_recent_idx+0091_signalscoutconfig_mcp_gateway_server_idsdiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 2a3618bdd485..edd251ad2725 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -1415,6 +1415,15 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):# describes ONE record; cardinality is the scout's call (one record per run, one per judged# entity, ...), so no separate mode enum is stored.structured_output_schema = models.JSONField(null=True, blank=True)+ # MCP gateway servers (UUIDs as strings) this scout's runs may mount, chosen from the+ # connections members shared to the whole team. Selection is per scout: the runner+ # snapshots it onto the task, and provisioning mounts only the team-scoped grants on the+ # listed servers, so an empty list mounts none. Personal grants never back a scout run,+ # which keeps runs identical no matter who created or edits the scout. Stale or unknown+ # ids simply never match a grant.+ # Deliberately NOT excluded from activity logging, because changing which external tools+ # a scout reaches is a security-relevant change, like `network_access`.+ mcp_gateway_server_ids = models.JSONField(default=list, db_default=[])# Optional five-field cron expression anchoring runs to wall-clock slots (e.g. "30 9 * * *",# "0 9,17 * * *", "0 9 * * 1-5"). Takes precedence over the rolling `run_interval_minutes`# when set. The coordinator evaluates it in `team.timezone`, so scheduled times followdiff --git a/products/signals/backend/scout_harness/runner.py b/products/signals/backend/scout_harness/runner.pyindex aabf4618b5e3..af277494e677 100644--- a/products/signals/backend/scout_harness/runner.py+++ b/products/signals/backend/scout_harness/runner.py@@ -677,10 +677,12 @@ async def _spawn_and_run(verbose=verbose,origin_product=tasks_facade.TaskOriginProduct.SIGNALS_SCOUT,mcp_builtin_agent_key="scout",- # MCP Store grants are personal, so the run mounts the connections its scout's creator- # delegated to the Scout agent — not the acting user's, and not the team's. A scout the- # coordinator auto-discovered has no creator, and mounts no Store connections at all.- mcp_credential_owner_id=config.created_by_id,+ # No credential owner on purpose: a scout is a team resource, so its runs mount only+ # connections members shared to the whole team, never anyone's personal grants. That+ # keeps runs identical no matter who created or edits the scout, and covers ownerless+ # coordinator-discovered scouts. The per-scout selection below picks which of those+ # team-shared servers this scout's runs mount. Empty selects none.+ mcp_gateway_server_ids=[str(server_id) for server_id in (config.mcp_gateway_server_ids or [])],# Tag every scout $ai_generation with its stage AND its scout, so scout spend is both# splittable out of the ai_product='signals' bucket (scouts carry no signal_report_id)# and attributable to one scout. `ai_stage` is the only run-shaped value the harnessdiff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex e2f021834354..226c82c956b3 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -11,6 +11,7 @@ from __future__ import annotationsfrom datetime import UTC, datetimefrom typing import Any+from uuid import UUIDfrom django.utils import timezone@@ -2134,6 +2135,32 @@ def _validate_scout_model(value: str | None, context: dict, current: str | Nonereturn value+# One scout should never need anywhere near this many external tools; the cap only bounds+# abuse of the JSON column.+MAX_SCOUT_MCP_GATEWAY_SERVERS = 100++_MCP_GATEWAY_SERVER_IDS_HELP = (+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections "+ "members shared to the whole team. Selection is per scout: an empty list gives the "+ "scout no MCP servers. Applies from the scout's next run."+)+++def _mcp_gateway_server_ids_field(*, read_only: bool = False) -> serializers.ListField:+ return serializers.ListField(+ child=serializers.UUIDField(),+ read_only=read_only,+ required=False,+ max_length=MAX_SCOUT_MCP_GATEWAY_SERVERS,+ help_text=_MCP_GATEWAY_SERVER_IDS_HELP,+ )+++def _normalize_mcp_gateway_server_ids(value: list[UUID]) -> list[str]:+ # The JSON column stores canonical strings — UUID instances aren't JSON-serializable.+ return [str(server_id) for server_id in value]++class SignalScoutConfigSerializer(serializers.ModelSerializer):"""Read shape for a per-(team, skill) scout config.@@ -2277,6 +2304,7 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):required=False,help_text=_SCOUT_TAGS_HELP_TEXT,)+ mcp_gateway_server_ids = _mcp_gateway_server_ids_field(read_only=True)@extend_schema_field(OpenApiTypes.STR)def get_description(self, obj: SignalScoutConfig) -> str:@@ -2309,6 +2337,7 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):"structured_output_schema","network_access","model",+ "mcp_gateway_server_ids","last_run_at","consecutive_failure_count","status_changed_at",@@ -2451,6 +2480,7 @@ class SignalScoutConfigUpdateSerializer(serializers.ModelSerializer):allow_null=True,help_text=_STRUCTURED_OUTPUT_SCHEMA_HELP,)+ mcp_gateway_server_ids = _mcp_gateway_server_ids_field()def validate_run_cron_schedule(self, value: str | None) -> str | None:return _validate_run_cron_schedule(value) if value is not None else None@@ -2467,6 +2497,9 @@ class SignalScoutConfigUpdateSerializer(serializers.ModelSerializer):def validate_structured_output_schema(self, value: dict | None) -> dict | None:return _validate_structured_output_schema(value)+ def validate_mcp_gateway_server_ids(self, value: list[UUID]) -> list[str]:+ return _normalize_mcp_gateway_server_ids(value)+def update(self, instance: SignalScoutConfig, validated_data: dict) -> SignalScoutConfig:# Re-anchor the coordinator's cron due-check only when the schedule actually changes —# an emit/enabled-only save must not defer an already-overdue scheduled run.@@ -2545,6 +2578,7 @@ class SignalScoutConfigUpdateSerializer(serializers.ModelSerializer):"model","auto_pause_exempt","tags",+ "mcp_gateway_server_ids",]@@ -2614,6 +2648,8 @@ class SignalScoutConfigOptionsSerializer(serializers.Serializer):help_text=_STRUCTURED_OUTPUT_SCHEMA_HELP,)+ mcp_gateway_server_ids = _mcp_gateway_server_ids_field()+def validate_run_cron_schedule(self, value: str | None) -> str | None:return _validate_run_cron_schedule(value) if value is not None else None@@ -2633,6 +2669,9 @@ class SignalScoutConfigOptionsSerializer(serializers.Serializer):def validate_structured_output_schema(self, value: dict | None) -> dict | None:return _validate_structured_output_schema(value)+ def validate_mcp_gateway_server_ids(self, value: list[UUID]) -> list[str]:+ return _normalize_mcp_gateway_server_ids(value)+class SignalScoutConfigCreateSerializer(SignalScoutConfigOptionsSerializer):"""Request body for registering a scout config without waiting for the coordinator tick.diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.pyindex 2a784384ca31..c2b9ee262efc 100644--- a/products/signals/backend/test/test_scout_harness.py+++ b/products/signals/backend/test/test_scout_harness.py@@ -1036,24 +1036,23 @@ async def test_run_tags_session_with_scout_ai_stage(ateam, aerrors_skill):@pytest.mark.asyncio@pytest.mark.django_db[email protected]("with_creator", [True, False])-async def test_run_delegates_the_scout_creator_as_mcp_credential_owner(ateam, aerrors_skill, with_creator):- # MCP Store grants are personal, so a scout run mounts the connections its creator delegated- # to the Scout agent — never the acting user's. A scout with no creator (coordinator- # auto-discovered) stays fail-closed and mounts nothing.+async def test_run_passes_the_per_scout_server_selection_and_no_credential_owner(ateam, aerrors_skill):+ # A scout is a team resource: its runs mount only team-scoped grants, gated by the+ # config's per-scout server selection, and never delegate anyone's personal grants.+ # Passing a credential owner here would silently re-open the personal lane.session, result = await database_sync_to_async(_make_fake_session, thread_sensitive=False)(ateam)captured: dict = {}- def _seed_config() -> int | None:- creator = (- User.objects.create(email=f"scout-owner-{random.randint(1, 99999)}@example.com") if with_creator else None- )+ def _seed_config() -> None:+ creator = User.objects.create(email=f"scout-owner-{random.randint(1, 99999)}@example.com")SignalScoutConfig.objects.unscoped().create(- team_id=ateam.id, skill_name="signals-scout-errors", created_by=creator+ team_id=ateam.id,+ skill_name="signals-scout-errors",+ created_by=creator,+ mcp_gateway_server_ids=["11111111-1111-1111-1111-111111111111"],)- return creator.id if creator is not None else None- owner_id = await database_sync_to_async(_seed_config, thread_sensitive=False)()+ await database_sync_to_async(_seed_config, thread_sensitive=False)()async def _capture_start(*args, on_task_run_created=None, **kwargs):captured.update(kwargs)@@ -1075,7 +1074,8 @@ async def test_run_delegates_the_scout_creator_as_mcp_credential_owner(ateam, aeawait arun_signals_scout(team_id=ateam.id, skill_name="signals-scout-errors")assert captured["mcp_builtin_agent_key"] == "scout"- assert captured["mcp_credential_owner_id"] == owner_id+ assert captured.get("mcp_credential_owner_id") is None+ assert captured["mcp_gateway_server_ids"] == ["11111111-1111-1111-1111-111111111111"]@pytest.mark.asynciodiff --git a/products/signals/backend/test/test_scout_harness_api.py b/products/signals/backend/test/test_scout_harness_api.pyindex 2fa64fa7f8c0..8228731418a3 100644--- a/products/signals/backend/test/test_scout_harness_api.py+++ b/products/signals/backend/test/test_scout_harness_api.py@@ -2,6 +2,7 @@ from __future__ import annotationsfrom datetime import datetime, timedeltafrom typing import TYPE_CHECKING+from uuid import uuid4from posthog.test.base import APIBaseTestfrom unittest.mock import AsyncMock, patch@@ -1863,6 +1864,22 @@ class TestScoutHarnessConfigAPI(APIBaseTest):assert config.run_interval_minutes == 60assert config.enabled_by_id == self.user.id+ def test_partial_update_stores_mcp_gateway_server_ids_as_strings(self) -> None:+ config = SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-foo")+ server_id = str(uuid4())++ response = self.client.patch(+ self._detail_url(str(config.id)),+ data={"mcp_gateway_server_ids": [server_id]},+ format="json",+ )++ assert response.status_code == status.HTTP_200_OK+ assert response.json()["mcp_gateway_server_ids"] == [server_id]+ config.refresh_from_db()+ # The JSON column must hold canonical strings, or the row save crashes on UUID instances.+ assert config.mcp_gateway_server_ids == [server_id]+def test_partial_update_disable_records_a_user_pause(self) -> None:config = SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-foo")diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex d58d4e6e5c5f..1bef283ddeea 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -1904,6 +1904,11 @@ export interface SignalScoutConfigOptionsApi {* @nullable*/structured_output_schema?: SignalScoutConfigOptionsApiStructuredOutputSchema+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[]}/**@@ -2038,6 +2043,11 @@ export interface SignalScoutConfigApi {* @nullable*/readonly model: string | null+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ readonly mcp_gateway_server_ids: readonly string[]/*** When the coordinator last dispatched this scout. Null if it has never run.* @nullable@@ -2118,6 +2128,11 @@ export interface SignalScoutConfigCreateApi {* @nullable*/structured_output_schema?: SignalScoutConfigCreateApiStructuredOutputSchema+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[]/*** The `signals-scout-*` skill to register a config for. The skill must already exist on this project — author it via the skills store first.* @maxLength 200@@ -2176,6 +2191,11 @@ export interface PatchedSignalScoutConfigUpdateApi {* @maxItems 10*/tags?: string[]+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[]}/**diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex e91ea8a11967..a97cd3af95ea 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -342,6 +342,8 @@ export const signalsScoutCreateBodyConfigOneModelMax = 200export const signalsScoutCreateBodyConfigOneTagsMax = 10+export const signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax = 100+export const SignalsScoutCreateBody = /* @__PURE__ */ zod.object({name: zod@@ -464,6 +466,13 @@ export const SignalsScoutCreateBody = /* @__PURE__ */ zod.describe('Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'),+ mcp_gateway_server_ids: zod+ .array(zod.uuid())+ .max(signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),}).describe('Schedule, enablement, and delivery options accepted while creating a scout.').optional()@@ -488,6 +497,8 @@ export const signalsScoutConfigCreateBodyModelMax = 200export const signalsScoutConfigCreateBodyTagsMax = 10+export const signalsScoutConfigCreateBodyMcpGatewayServerIdsMax = 100+export const signalsScoutConfigCreateBodySkillNameMax = 200export const SignalsScoutConfigCreateBody = /* @__PURE__ */ zod@@ -573,6 +584,13 @@ export const SignalsScoutConfigCreateBody = /* @__PURE__ */ zod.describe('Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'),+ mcp_gateway_server_ids: zod+ .array(zod.uuid())+ .max(signalsScoutConfigCreateBodyMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),skill_name: zod.string().max(signalsScoutConfigCreateBodySkillNameMax)@@ -599,6 +617,8 @@ export const signalsScoutConfigUpdateBodyModelMax = 200export const signalsScoutConfigUpdateBodyTagsMax = 10+export const signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax = 100+export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.object({enabled: zod@@ -689,6 +709,13 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.describe('Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.'),+ mcp_gateway_server_ids: zod+ .array(zod.uuid())+ .max(signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),}).describe('Editable schedule, enablement, and emit posture for one scout config.')diff --git a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts b/products/signals/frontend/inbox/__mocks__/scoutConfigs.tsindex 2cbd91b6dd3b..80fdb7aa14a7 100644--- a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts+++ b/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts@@ -21,6 +21,7 @@ function makeMockScout(overrides: MockScoutOverrides): SignalScoutConfigApi {status_changed_at: null,auto_pause_exempt: false,tags: [],+ mcp_gateway_server_ids: [],created_at: '2026-06-11T09:00:00Z',...overrides,}diff --git a/products/signals/frontend/inbox/components/config/AgentsTab.tsx b/products/signals/frontend/inbox/components/config/AgentsTab.tsxindex 6c66cf047af3..132deff3eba7 100644--- a/products/signals/frontend/inbox/components/config/AgentsTab.tsx+++ b/products/signals/frontend/inbox/components/config/AgentsTab.tsx@@ -12,7 +12,6 @@ import { signalSourcesLogic } from '../../signalSourcesLogic'import { AgentsRoster } from './AgentsRoster'import { ConnectionsSection } from './ConnectionsSection'import { DataSourceSetup } from './DataSourceSetup'-import { McpServersSection } from './McpServersSection'import { ScoutsFleetSection } from './scouts/ScoutsFleetSection'import { SlackNotificationsSection } from './SlackNotificationsSection'@@ -121,12 +120,6 @@ export function AgentsTab(): JSX.Element {<SlackNotificationsSection /></Subsection>)}-- {featureFlags[FEATURE_FLAGS.MCP_SERVERS] && (- <Subsection title="MCP servers" description="Shared external tools that scheduled Scouts can use.">- <McpServersSection />- </Subsection>- )}</div></div>)diff --git a/products/signals/frontend/inbox/components/config/McpServersSection.tsx b/products/signals/frontend/inbox/components/config/McpServersSection.tsxdeleted file mode 100644index 12d1e7757f78..000000000000--- a/products/signals/frontend/inbox/components/config/McpServersSection.tsx+++ /dev/null@@ -1,111 +0,0 @@-import { useMountedLogic, useValues } from 'kea'--import { IconChevronRight, IconServer } from '@posthog/icons'-import { LemonTag, LemonTagType, Link, Spinner } from '@posthog/lemon-ui'-import { ServerIcon } from '@posthog/products-mcp-store/frontend/scene/icons'--import { fullName } from 'lib/utils/strings'-import { urls } from 'scenes/urls'--import type { MCPServiceAccountServerApi } from 'products/mcp_store/frontend/generated/api.schemas'--import { scoutMcpServersLogic } from '../../logics/scoutMcpServersLogic'--const CONNECTION_STATE: Record<- MCPServiceAccountServerApi['connection_state'],- { label: string; tagType: LemonTagType }-> = {- ready: { label: 'Connection ready', tagType: 'success' },- pending_oauth: { label: 'Pending OAuth', tagType: 'warning' },- needs_reauth: { label: 'Reconnect', tagType: 'danger' },- disabled: { label: 'Disabled', tagType: 'muted' },- missing_credential: { label: 'Needs connection', tagType: 'warning' },-}--export function McpServersSection(): JSX.Element {- useMountedLogic(scoutMcpServersLogic)- const { scoutAccount, scoutServersLoading, teammateScoutServers, yourScoutServers } =- useValues(scoutMcpServersLogic)-- if (scoutServersLoading && scoutAccount === null) {- return (- <div className="flex items-center gap-2 rounded border border-dashed px-3 py-4 text-sm text-secondary">- <Spinner /> Loading Scout MCP servers...- </div>- )- }-- return (- <div className="rounded border bg-bg-light overflow-hidden">- {yourScoutServers.length === 0 ? (- <div className="flex items-start gap-3 px-3 py-3">- <IconServer className="size-5 shrink-0 mt-0.5 text-secondary" />- <div className="min-w-0">- <div className="font-medium text-sm text-default">- You have not shared any MCP servers with Scout- </div>- <p className="text-xs text-secondary mt-0.5 mb-0">- Share one of your connections in MCP server settings. Your scouts can also use connections- teammates shared to the team.- </p>- </div>- </div>- ) : (- <div className="divide-y">- {yourScoutServers.map((server) => (- <ScoutServerRow key={server.id} server={server} />- ))}- </div>- )}- {teammateScoutServers.length > 0 && (- <div className="border-t">- <div className="px-3 py-2 text-xs text-secondary">- Shared to the team by teammates. Your scouts use these too.- </div>- <div className="divide-y border-t">- {teammateScoutServers.map((server) => (- <ScoutServerRow key={`${server.id}-${server.shared_by.id}`} server={server} attributed />- ))}- </div>- </div>- )}- <Link- to={urls.settings('mcp-servers')}- className="group flex items-center justify-between gap-3 border-t px-3 py-2 text-xs no-underline transition-colors hover:bg-bg-3000"- >- <span className="text-secondary group-hover:text-default">View MCP server settings</span>- <IconChevronRight className="size-4 shrink-0 text-muted transition-colors group-hover:text-default" />- </Link>- {scoutAccount?.status === 'paused' ? (- <div className="border-t px-3 py-2 text-xs text-secondary">Scout MCP access is paused.</div>- ) : null}- </div>- )-}--function ScoutServerRow({- server,- attributed,-}: {- server: MCPServiceAccountServerApi- attributed?: boolean-}): JSX.Element {- const state = CONNECTION_STATE[server.connection_state]- const sharedBy = fullName(server.shared_by) || server.shared_by.email- return (- <div className="flex items-center gap-3 px-3 py-2.5">- <ServerIcon iconDomain={server.icon_domain} size={28} />- <div className="min-w-0 flex-1">- <div className="font-medium text-sm text-default truncate">{server.name}</div>- {attributed ? (- <div className="text-xs text-secondary truncate">Shared to the team by {sharedBy}</div>- ) : (- server.description && <div className="text-xs text-secondary truncate">{server.description}</div>- )}- </div>- <LemonTag type={state.tagType} size="small">- {state.label}- </LemonTag>- </div>- )-}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsxindex 0f043c5ed98e..2b5147fe162e 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx@@ -20,6 +20,7 @@ const config: SignalScoutConfigApi = {run_cron_schedule: '0 9 * * *',output_destinations: {},structured_output_schema: null,+ mcp_gateway_server_ids: [],last_run_at: null,consecutive_failure_count: 0,status_changed_at: null,diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.tsxindex d576b05b7653..f78125a22e94 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.tsx@@ -23,6 +23,7 @@ import {SCOUT_DAILY_AT_SCHEDULE_MODE,timeToDailyCron,} from '../../../utils/scoutRunsWindow'+import { ScoutMcpServersPicker } from './ScoutMcpServersPicker'import { ScoutSlackDestination } from './ScoutSlackDestination'import { ScoutTagsEditor } from './ScoutTagsEditor'@@ -223,6 +224,14 @@ export function ScoutConfigForm({onChange={(outputDestinations) => onUpdate(config.id, { output_destinations: outputDestinations })}disabledReason={controlsDisabledReason}/>+ <ScoutMcpServersPicker+ compact+ selectedServerIds={[...(config.mcp_gateway_server_ids ?? [])]}+ onChange={(serverIds) => onUpdate(config.id, { mcp_gateway_server_ids: serverIds })}+ // Editable while the scout is disabled, like network access: the selection must be+ // settable BEFORE the enable or the first run races out with the wrong toolset.+ disabledReason={updating ? 'Saving scout settings' : undefined}+ />{/* Only custom scouts are deletable. A canonical scout would be re-seeded from disk afterdeletion (and couldn't be re-added from the UI), so its terminal action stays disable. */}{onDelete && config.scout_origin === 'custom' ? (diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutCreateModal.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutCreateModal.tsxindex 0db26ae98709..7081eb7d3f32 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutCreateModal.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutCreateModal.tsx@@ -30,6 +30,7 @@ import {SIGNALS_SCOUT_SKILL_PREFIX,} from '../../../utils/scoutRunsWindow'import { MAX_SCOUT_TAGS, normalizeScoutTags } from '../../../utils/scoutTags'+import { ScoutMcpServersPicker } from './ScoutMcpServersPicker'import { ScoutSlackDestination } from './ScoutSlackDestination'export interface ScoutCreateModalProps {@@ -173,6 +174,16 @@ export function ScoutCreateModal({ isOpen, onClose, initialValues, onCreated }:/></LemonField>+ <LemonField name="config.mcp_gateway_server_ids">+ {({ value, onChange }) => (+ <ScoutMcpServersPicker+ selectedServerIds={value ?? []}+ onChange={onChange}+ disabledReason={isScoutCreateFormSubmitting ? 'Creating the scout' : undefined}+ />+ )}+ </LemonField>+<div className="flex flex-col gap-3 border-t border-primary pt-4"><span className="font-medium text-sm">Run settings</span><LemonField.Purediff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.stories.tsxnew file mode 100644index 000000000000..8de0aa0d4543--- /dev/null+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.stories.tsx@@ -0,0 +1,101 @@+import type { Meta, StoryObj } from '@storybook/react'+import { useState } from 'react'++import { FEATURE_FLAGS } from 'lib/constants'++import { mswDecorator } from '~/mocks/browser'++import { ScoutMcpServersPicker } from './ScoutMcpServersPicker'++/** Stories drive the picker like its call sites do: selection state lives outside. */+function ControlledPicker({ compact }: { compact?: boolean }): JSX.Element {+ const [selectedServerIds, setSelectedServerIds] = useState<string[]>(['linear-id'])+ return (+ <ScoutMcpServersPicker+ compact={compact}+ selectedServerIds={selectedServerIds}+ onChange={setSelectedServerIds}+ />+ )+}++const YOU = { id: 179, uuid: 'you-uuid', email: '[email protected]', hedgehog_config: null }+const TEAMMATE = { id: 2, uuid: 'mate-uuid', email: '[email protected]', hedgehog_config: null }++function grant(+ id: string,+ name: string,+ sharedBy = YOU,+ scope = 'team',+ connectionState = 'ready'+): Record<string, unknown> {+ return {+ id,+ shared_by: sharedBy,+ scope,+ name,+ description: `${name} workspace`,+ icon_key: name.toLowerCase(),+ icon_domain: `${name.toLowerCase()}.com`,+ connection_state: connectionState,+ }+}++const scoutAccount = {+ id: 'scout-account-id',+ name: 'Scout',+ description: 'Scheduled scouts',+ handle: 'svc-scout',+ agent_key: 'scout',+ status: 'active',+ server_ids: ['linear-id', 'notion-id', 'github-id', 'stripe-id', 'slack-id'],+ servers: [+ grant('linear-id', 'Linear'),+ grant('notion-id', 'Notion', TEAMMATE),+ grant('github-id', 'GitHub', TEAMMATE),+ grant('stripe-id', 'Stripe', YOU, 'team', 'needs_reauth'),+ grant('slack-id', 'Slack'),+ // Personal grants never back a scout run, so this one must not render.+ grant('zendesk-id', 'Zendesk', YOU, 'personal'),+ ],+ last_active_at: null,+ created_at: '2026-07-22T00:00:00Z',+ updated_at: '2026-07-22T00:00:00Z',+}++const meta: Meta<typeof ScoutMcpServersPicker> = {+ title: 'Scenes-App/Inbox/ScoutMcpServersPicker',+ component: ScoutMcpServersPicker,+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/mcp_gateway/service_accounts/': () => [+ 200,+ { count: 1, next: null, previous: null, results: [scoutAccount] },+ ],+ },+ }),+ ],+ parameters: {+ testOptions: { waitForLoadersToDisappear: true },+ featureFlags: [FEATURE_FLAGS.MCP_SERVERS],+ },+}+export default meta+type Story = StoryObj<typeof ScoutMcpServersPicker>++export const CreateDialogVariant: Story = {+ render: () => (+ <div className="max-w-2xl p-4">+ <ControlledPicker />+ </div>+ ),+}++export const ScoutSettingsVariant: Story = {+ render: () => (+ <div className="max-w-md p-4">+ <ControlledPicker compact />+ </div>+ ),+}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.tsxnew file mode 100644index 000000000000..cac9e5f08284--- /dev/null+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutMcpServersPicker.tsx@@ -0,0 +1,251 @@+import { useMountedLogic, useValues } from 'kea'+import { useState } from 'react'++import { IconChevronRight, IconServer } from '@posthog/icons'+import { LemonSwitch, LemonTag, LemonTagType, Link, Spinner } from '@posthog/lemon-ui'+import { ServerIcon } from '@posthog/products-mcp-store/frontend/scene/icons'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import type { MCPServiceAccountServerApi } from 'products/mcp_store/frontend/generated/api.schemas'++import { scoutMcpServersLogic } from '../../../logics/scoutMcpServersLogic'++/** Rows shown before the list collapses behind "See more". */+const MAX_VISIBLE_SERVERS = 2++interface ScoutMcpServersPickerProps {+ /** Gateway server ids selected for this scout (`mcp_gateway_server_ids`). */+ selectedServerIds: string[]+ onChange: (serverIds: string[]) => void+ /** Compact rows matching the inline scout settings form; the default suits the create dialog. */+ compact?: boolean+ disabledReason?: string+}++/**+ * Per-scout selection among the MCP servers members shared to the whole team, persisted as the+ * scout config's `mcp_gateway_server_ids`. Scouts are a team resource, so only team shares are+ * offered: the selection is the same for every viewer, and matches exactly what the run mounts.+ * Sharing a connection to the team happens on the MCP gateway page, not here.+ */+export function ScoutMcpServersPicker(props: ScoutMcpServersPickerProps): JSX.Element | null {+ const { featureFlags } = useValues(featureFlagLogic)+ if (!featureFlags[FEATURE_FLAGS.MCP_SERVERS]) {+ return null+ }+ return props.compact ? <CompactPicker {...props} /> : <FullPicker {...props} />+}++function connectionIssue(server: MCPServiceAccountServerApi): { label: string; tagType: LemonTagType } | null {+ switch (server.connection_state) {+ case 'needs_reauth':+ return { label: 'Reconnect', tagType: 'danger' }+ case 'pending_oauth':+ return { label: 'Pending OAuth', tagType: 'warning' }+ case 'disabled':+ return { label: 'Disabled', tagType: 'muted' }+ case 'missing_credential':+ return { label: 'Needs connection', tagType: 'warning' }+ default:+ return null+ }+}++interface PickerState {+ hiddenCount: number+ initialLoading: boolean+ selectDisabledReason: string | undefined+ showAll: boolean+ setShowAll: (showAll: boolean) => void+ toggleServer: (serverId: string, selected: boolean) => void+ visibleServers: MCPServiceAccountServerApi[]+}++function usePickerState({ selectedServerIds, onChange, disabledReason }: ScoutMcpServersPickerProps): PickerState {+ const [showAll, setShowAll] = useState(false)+ const { scoutAccount, scoutServersLoading, teamScoutServers } = useValues(scoutMcpServersLogic)++ const initialLoading = scoutServersLoading && scoutAccount === null+ const visibleServers = showAll ? teamScoutServers : teamScoutServers.slice(0, MAX_VISIBLE_SERVERS)+ const toggleServer = (serverId: string, selected: boolean): void => {+ onChange(selected ? [...selectedServerIds, serverId] : selectedServerIds.filter((id) => id !== serverId))+ }+ return {+ hiddenCount: teamScoutServers.length - visibleServers.length,+ initialLoading,+ selectDisabledReason:+ disabledReason ??+ (scoutAccount === null && !scoutServersLoading ? 'Scout MCP access is unavailable' : undefined),+ showAll,+ setShowAll,+ toggleServer,+ visibleServers,+ }+}++function SelectSwitch({+ server,+ size,+ state,+ selectedServerIds,+}: {+ server: MCPServiceAccountServerApi+ size?: 'small'+ state: PickerState+ selectedServerIds: string[]+}): JSX.Element {+ return (+ <LemonSwitch+ size={size}+ checked={selectedServerIds.includes(server.id)}+ disabledReason={state.selectDisabledReason}+ onChange={(checked) => state.toggleServer(server.id, checked)}+ aria-label={`Let this scout use ${server.name}`}+ />+ )+}++function FullPicker(props: ScoutMcpServersPickerProps): JSX.Element {+ useMountedLogic(scoutMcpServersLogic)+ const { scoutAccount } = useValues(scoutMcpServersLogic)+ const state = usePickerState(props)++ let body: JSX.Element+ if (state.initialLoading) {+ body = (+ <div className="flex items-center gap-2 rounded border border-dashed px-3 py-4 text-sm text-secondary">+ <Spinner /> Loading MCP servers...+ </div>+ )+ } else if (state.visibleServers.length === 0) {+ body = (+ <div className="flex items-start gap-3 rounded border border-dashed px-3 py-3">+ <IconServer className="size-5 shrink-0 mt-0.5 text-secondary" />+ <div className="min-w-0">+ <div className="font-medium text-sm text-default">No MCP servers shared with the team yet</div>+ <p className="text-xs text-secondary mt-0.5 mb-0">+ <Link to={urls.mcpGateway()}>Share an MCP server with the team</Link> to give scouts external+ tools.+ </p>+ </div>+ </div>+ )+ } else {+ body = (+ <div className="rounded border bg-bg-light overflow-hidden">+ <div className="divide-y">+ {state.visibleServers.map((server) => {+ const issue = connectionIssue(server)+ return (+ <div key={server.id} className="flex items-center gap-3 px-3 py-2.5">+ <ServerIcon iconDomain={server.icon_domain} size={28} />+ <div className="min-w-0 flex-1">+ <div className="font-medium text-sm text-default truncate">{server.name}</div>+ {server.description && (+ <div className="text-xs text-secondary truncate">{server.description}</div>+ )}+ </div>+ {issue && (+ <LemonTag type={issue.tagType} size="small">+ {issue.label}+ </LemonTag>+ )}+ <SelectSwitch+ server={server}+ state={state}+ selectedServerIds={props.selectedServerIds}+ />+ </div>+ )+ })}+ </div>+ {!state.showAll && state.hiddenCount > 0 && (+ <button+ type="button"+ onClick={() => state.setShowAll(true)}+ className="w-full border-t border-primary px-3 py-2 text-left text-xs text-secondary transition-colors hover:bg-bg-3000 hover:text-default"+ >+ See {state.hiddenCount} more+ </button>+ )}+ {scoutAccount?.status === 'paused' && (+ <div className="border-t border-primary px-3 py-2 text-xs text-secondary">+ Scout MCP access is paused.+ </div>+ )}+ <Link+ to={urls.mcpGateway()}+ className="group flex items-center justify-between gap-3 border-t border-primary px-3 py-2 text-xs no-underline transition-colors hover:bg-bg-3000"+ >+ <span className="text-secondary group-hover:text-default">Share more MCP servers</span>+ <IconChevronRight className="size-4 shrink-0 text-muted transition-colors group-hover:text-default" />+ </Link>+ </div>+ )+ }++ return (+ <div className="flex flex-col gap-3 border-t border-primary pt-4">+ <div className="flex flex-col gap-0.5">+ <span className="font-medium text-sm">MCP servers</span>+ <p className="text-xs text-secondary mb-0">+ Choose which of the team's shared MCP servers this scout can use.+ </p>+ </div>+ {body}+ </div>+ )+}++function CompactPicker(props: ScoutMcpServersPickerProps): JSX.Element {+ useMountedLogic(scoutMcpServersLogic)+ const state = usePickerState(props)++ return (+ <div className="flex flex-col gap-2 border-t border-primary pt-2">+ <div className="flex flex-col min-w-0">+ <span className="text-xs text-default">MCP servers</span>+ <span className="text-[11.5px] text-muted">+ Choose which of the team's shared MCP servers this scout can use.{' '}+ <Link to={urls.mcpGateway()}>Manage MCP servers</Link>+ </span>+ </div>+ {state.initialLoading ? (+ <span className="flex items-center gap-2 text-[11.5px] text-muted">+ <Spinner /> Loading MCP servers...+ </span>+ ) : state.visibleServers.length === 0 ? (+ <span className="text-[11.5px] text-muted">+ <Link to={urls.mcpGateway()}>Share an MCP server with the team</Link> to give scouts external tools.+ </span>+ ) : (+ <div className="flex flex-col gap-1.5">+ {state.visibleServers.map((server) => (+ <div key={server.id} className="flex items-center gap-2">+ <ServerIcon iconDomain={server.icon_domain} size={20} />+ <span className="min-w-0 flex-1 truncate text-xs text-default">{server.name}</span>+ <SelectSwitch+ server={server}+ size="small"+ state={state}+ selectedServerIds={props.selectedServerIds}+ />+ </div>+ ))}+ {!state.showAll && state.hiddenCount > 0 && (+ <button+ type="button"+ onClick={() => state.setShowAll(true)}+ className="w-fit text-left text-[11.5px] text-muted transition-colors hover:text-default"+ >+ See {state.hiddenCount} more+ </button>+ )}+ </div>+ )}+ </div>+ )+}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsxindex 45b84b09014f..e2fe72d63195 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx@@ -23,6 +23,7 @@ const config: SignalScoutConfigApi = {run_cron_schedule: null,output_destinations: {},structured_output_schema: null,+ mcp_gateway_server_ids: [],network_access: 'trusted',model: null,last_run_at: null,diff --git a/products/signals/frontend/inbox/components/shell/AgentSetupColumn.tsx b/products/signals/frontend/inbox/components/shell/AgentSetupColumn.tsxindex 599263f4cf28..ae10794505f0 100644--- a/products/signals/frontend/inbox/components/shell/AgentSetupColumn.tsx+++ b/products/signals/frontend/inbox/components/shell/AgentSetupColumn.tsx@@ -1,24 +1,19 @@import { useActions, useMountedLogic, useValues } from 'kea'import { combineUrl, router } from 'kea-router'-import { IconBolt, IconCheckCircle, IconChevronRight, IconCompass, IconGithub, IconServer } from '@posthog/icons'+import { IconBolt, IconCheckCircle, IconChevronRight, IconCompass, IconGithub } from '@posthog/icons'import { LemonModal, LemonSkeleton, LemonTag, Link } from '@posthog/lemon-ui'-import { ServerIcon } from '@posthog/products-mcp-store/frontend/scene/icons'-import { FEATURE_FLAGS } from 'lib/constants'import { integrationsLogic } from 'lib/integrations/integrationsLogic'import { slackChannelDisplayName } from 'lib/integrations/slackChannel'import { IconSlack } from 'lib/lemon-ui/icons'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { cn } from 'lib/utils/css-classes'import { GithubIntegration } from 'scenes/integrations/components/GithubIntegration'import { scoutFleetLogic } from '../../logics/scoutFleetLogic'-import { scoutMcpServersLogic } from '../../logics/scoutMcpServersLogic'import { signalTeamConfigLogic } from '../../logics/signalTeamConfigLogic'import { userAutonomyLogic } from '../../logics/userAutonomyLogic'import { signalSourcesLogic } from '../../signalSourcesLogic'-import { McpServersSection } from '../config/McpServersSection'import { ScoutsFleetSection } from '../config/scouts/ScoutsFleetSection'import { SelfDrivingSection } from '../config/SelfDrivingSection'import { SignalSourcesPanel } from '../config/SignalSourcesPanel'@@ -221,51 +216,6 @@ function CodeAccessWidget(): JSX.Element {)}-function McpServersWidget(): JSX.Element {- useMountedLogic(scoutMcpServersLogic)- const { availableScoutServers, scoutAccount, scoutServersLoading, scoutServersNeedingSetup, yourScoutServers } =- useValues(scoutMcpServersLogic)- const { openSetupModal } = useActions(agentSetupModalLogic)- const availableCount = availableScoutServers.length- const needsSetupCount = scoutServersNeedingSetup.length- let status = 'Share external tools'- let tone: WidgetTone = 'neutral'- if (scoutAccount?.status === 'paused') {- status = 'MCP access paused'- } else if (availableCount > 0 && needsSetupCount > 0) {- status = `${availableCount} available · ${needsSetupCount} need setup`- tone = 'done'- } else if (availableCount > 0) {- status = `${availableCount} available to your scouts`- tone = 'done'- } else if (needsSetupCount > 0) {- status = `${needsSetupCount} need setup`- tone = 'todo'- }- return (- <SetupWidgetCard- icon={<IconServer />}- title="MCP servers"- size="md"- tone={tone}- loading={scoutServersLoading && yourScoutServers.length === 0}- status={status}- onClick={() => openSetupModal('mcp-servers')}- >- {yourScoutServers.length > 0 && (- <div className="flex items-center gap-1 pt-1">- {yourScoutServers.slice(0, 6).map((server) => (- <ServerIcon key={server.id} iconDomain={server.icon_domain} size={16} />- ))}- {yourScoutServers.length > 6 && (- <span className="text-[11px] text-muted">+{yourScoutServers.length - 6}</span>- )}- </div>- )}- </SetupWidgetCard>- )-}-function NotificationsWidget(): JSX.Element {useMountedLogic(userAutonomyLogic)const { slackIntegrations, integrationsLoading } = useValues(integrationsLogic)@@ -338,12 +288,6 @@ const SETUP_MODALS: Record<width: 760,body: <GithubSetupBody />,},- 'mcp-servers': {- title: 'MCP servers',- description: 'Connections you share with your scheduled scouts.',- width: 560,- body: <McpServersSection />,- },}function SetupModal(): JSX.Element {@@ -374,7 +318,6 @@ function SetupModal(): JSX.Element {export function AgentSetupColumn({ layout }: { layout: 'rail' | 'stacked' }): JSX.Element {useMountedLogic(integrationsLogic)useMountedLogic(signalSourcesLogic)- const { featureFlags } = useValues(featureFlagLogic)return (<div@@ -392,7 +335,6 @@ export function AgentSetupColumn({ layout }: { layout: 'rail' | 'stacked' }): JS<SetupSection title="Connections"><CodeAccessWidget /><NotificationsWidget />- {featureFlags[FEATURE_FLAGS.MCP_SERVERS] && <McpServersWidget />}</SetupSection><SetupSection title="Usage"><InboxUsageWidget />diff --git a/products/signals/frontend/inbox/components/shell/agentSetupModalLogic.ts b/products/signals/frontend/inbox/components/shell/agentSetupModalLogic.tsindex d43eb789d00d..7661385ea857 100644--- a/products/signals/frontend/inbox/components/shell/agentSetupModalLogic.ts+++ b/products/signals/frontend/inbox/components/shell/agentSetupModalLogic.ts@@ -4,7 +4,7 @@ import { router, urlToAction } from 'kea-router'import { urls } from 'scenes/urls'/** Setup widgets whose management UI opens in a modal. */-export type AgentSetupModalKey = 'signal-sources' | 'scout-troop' | 'slack' | 'github' | 'mcp-servers'+export type AgentSetupModalKey = 'signal-sources' | 'scout-troop' | 'slack' | 'github'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface agentSetupModalLogicValues {diff --git a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.tsindex 36661645a365..7c81d3f4b60b 100644--- a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts@@ -40,6 +40,7 @@ const CREATED_SCOUT: SignalScoutCreateResponseApi = {run_cron_schedule: null,output_destinations: {},structured_output_schema: null,+ mcp_gateway_server_ids: [],last_run_at: null,consecutive_failure_count: 0,status_changed_at: null,@@ -102,6 +103,7 @@ describe('scoutCreateModalLogic', () => {emit: false,run_interval_minutes: 60,run_cron_schedule: null,+ mcp_gateway_server_ids: [],output_destinations: {slack: {integration_id: 42,@@ -123,6 +125,7 @@ describe('scoutCreateModalLogic', () => {emit: false,run_interval_minutes: 60,run_cron_schedule: null,+ mcp_gateway_server_ids: [],output_destinations: {slack: {integration_id: 42,@@ -162,6 +165,7 @@ describe('scoutCreateModalLogic', () => {run_interval_minutes: 1440,run_cron_schedule: '45 14 * * *',tags: [],+ mcp_gateway_server_ids: [],},}),})@@ -176,6 +180,7 @@ describe('scoutCreateModalLogic', () => {run_interval_minutes: 1440,run_cron_schedule: '45 14 * * *',tags: [],+ mcp_gateway_server_ids: [],},}))diff --git a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.tsindex 787b32624ec0..0c271f891c1c 100644--- a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts@@ -26,7 +26,10 @@ import {import { MAX_SCOUT_TAG_LENGTH, MAX_SCOUT_TAGS, normalizeScoutTag } from '../utils/scoutTags'type ScoutCreateConfigFormValues = Required<- Pick<SignalScoutConfigOptionsApi, 'enabled' | 'emit' | 'run_interval_minutes' | 'run_cron_schedule' | 'tags'>+ Pick<+ SignalScoutConfigOptionsApi,+ 'enabled' | 'emit' | 'run_interval_minutes' | 'run_cron_schedule' | 'tags' | 'mcp_gateway_server_ids'+ >> &Pick<SignalScoutConfigOptionsApi, 'output_destinations'>@@ -57,6 +60,7 @@ export const DEFAULT_SCOUT_CREATE_FORM_VALUES: ScoutCreateFormValues = {run_interval_minutes: 1440,run_cron_schedule: null,tags: [],+ mcp_gateway_server_ids: [],},}diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.tsindex c8aa531c48a6..73d33ecc70b8 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts@@ -45,6 +45,7 @@ const BASE_CONFIG: SignalScoutConfigApi = {run_cron_schedule: null,output_destinations: {},structured_output_schema: null,+ mcp_gateway_server_ids: [],last_run_at: null,consecutive_failure_count: 0,status_changed_at: null,diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.tsindex 12b14915fbaf..19fc1da5d710 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts@@ -234,10 +234,10 @@ export interface scoutFleetLogicActions {}patchScoutConfigLocally: (configId: string,- updates: SignalScoutConfigUpdate+ updates: Partial<SignalScoutConfig> | SignalScoutConfigUpdate) => {configId: string- updates: PatchedSignalScoutConfigUpdateApi+ updates: Partial<SignalScoutConfigApi> | PatchedSignalScoutConfigUpdateApi}removeScoutConfigLocally: (configId: string) => {configId: string@@ -342,7 +342,11 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([actions({updateScoutConfig: (configId: string, updates: SignalScoutConfigUpdate) => ({ configId, updates }),updateScoutConfigFinished: (configId: string) => ({ configId }),- patchScoutConfigLocally: (configId: string, updates: SignalScoutConfigUpdate) => ({ configId, updates }),+ // A full server config doubles as a local patch when reconciling optimistic edits.+ patchScoutConfigLocally: (configId: string, updates: SignalScoutConfigUpdate | Partial<SignalScoutConfig>) => ({+ configId,+ updates,+ }),deleteScout: (configId: string) => ({ configId }),deleteScoutFinished: (configId: string) => ({ configId }),removeScoutConfigLocally: (configId: string) => ({ configId }),diff --git a/products/signals/frontend/inbox/logics/scoutMcpServersLogic.test.ts b/products/signals/frontend/inbox/logics/scoutMcpServersLogic.test.tsindex 04b21c9ac201..1f3e991478ec 100644--- a/products/signals/frontend/inbox/logics/scoutMcpServersLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutMcpServersLogic.test.ts@@ -3,8 +3,6 @@ import { MOCK_DEFAULT_USER } from 'lib/api.mock'import { expectLogic } from 'kea-test-utils'-import { userLogic } from 'scenes/userLogic'-import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'@@ -36,7 +34,7 @@ function server(name: string,connectionState: ConnectionStateEnumApi,sharedBy: UserBasicApi = YOU,- scope: MCPServiceAccountServerApi['scope'] = 'personal'+ scope: MCPServiceAccountServerApi['scope'] = 'team'): MCPServiceAccountServerApi {return {id,@@ -70,6 +68,10 @@ function account(}}+function listResponse<T>(results: T[]): [number, { count: number; next: null; previous: null; results: T[] }] {+ return [200, { count: results.length, next: null, previous: null, results }]+}+describe('scoutMcpServersLogic', () => {let logic: ReturnType<typeof scoutMcpServersLogic.build> | undefined@@ -81,109 +83,19 @@ describe('scoutMcpServersLogic', () => {logic?.unmount()})- it('separates your Scout grants from teammate team shares and flags the ones needing setup', async () => {- const notion = server('notion-id', 'Notion', 'missing_credential')- const linear = server('linear-id', 'Linear', 'ready')- const teammateGithub = server('github-id', 'GitHub', 'ready', TEAMMATE, 'team')- const teammateSentry = server('sentry-id', 'Sentry', 'ready', TEAMMATE)- const zendesk = server('zendesk-id', 'Zendesk', 'ready')- useMocks({- get: {- '/api/projects/:team_id/mcp_gateway/service_accounts/': () => [- 200,- {- count: 2,- next: null,- previous: null,- results: [- account('support', [zendesk]),- account('scout', [notion, linear, teammateGithub, teammateSentry]),- ],- },- ],- },- })-- logic = scoutMcpServersLogic()- logic.mount()- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.scoutServers).toEqual([notion, linear, teammateGithub, teammateSentry])- expect(logic.values.yourScoutServers).toEqual([notion, linear])- expect(logic.values.teammateScoutServers).toEqual([teammateGithub])- expect(logic.values.isScoutMcpAccessEnabled).toBe(true)- expect(logic.values.readyScoutServers).toEqual([linear, teammateGithub])- expect(logic.values.availableScoutServers).toEqual([linear, teammateGithub])- expect(logic.values.scoutServersNeedingSetup).toEqual([notion])- })-- it('counts a server the viewer already shares once, even when a teammate team-shares it too', async () => {- const yourLinear = server('linear-id', 'Linear', 'ready')- const teammateLinear = server('linear-id', 'Linear', 'ready', TEAMMATE, 'team')- useMocks({- get: {- '/api/projects/:team_id/mcp_gateway/service_accounts/': () => [- 200,- {- count: 1,- next: null,- previous: null,- results: [account('scout', [yourLinear, teammateLinear])],- },- ],- },- })-- logic = scoutMcpServersLogic()- logic.mount()- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.readyScoutServers).toEqual([yourLinear])- expect(logic.values.availableScoutServers).toEqual([yourLinear])- })-- it('attributes no grants while the current user is still loading', async () => {- const linear = server('linear-id', 'Linear', 'ready')- const teammateGithub = server('github-id', 'GitHub', 'ready', TEAMMATE)- useMocks({- get: {- '/api/projects/:team_id/mcp_gateway/service_accounts/': () => [- 200,- {- count: 1,- next: null,- previous: null,- results: [account('scout', [linear, teammateGithub])],- },- ],- },- })-- logic = scoutMcpServersLogic()- logic.mount()- await expectLogic(logic).toFinishAllListeners()- userLogic.actions.loadUserSuccess(null)-- expect(logic.values.currentUserId).toBeNull()- expect(logic.values.yourScoutServers).toEqual([])- expect(logic.values.teammateScoutServers).toEqual([])- expect(logic.values.availableScoutServers).toEqual([])- expect(logic.values.scoutServersNeedingSetup).toEqual([])- })-- it('does not expose ready servers when MCP access is paused', async () => {- const linear = server('linear-id', 'Linear', 'ready')+ it('offers only team shares from the scout account, one row per server, preferring a ready share', async () => {+ const personalNotion = server('notion-id', 'Notion', 'ready', YOU, 'personal')+ const staleLinear = server('linear-id', 'linear', 'needs_reauth', YOU)+ const readyLinear = server('linear-id', 'linear', 'ready', TEAMMATE)+ const github = server('github-id', 'GitHub', 'ready', TEAMMATE)+ const supportZendesk = server('zendesk-id', 'Zendesk', 'ready')useMocks({get: {- '/api/projects/:team_id/mcp_gateway/service_accounts/': () => [- 200,- {- count: 1,- next: null,- previous: null,- results: [account('scout', [linear], { status: 'paused' })],- },- ],+ '/api/projects/:team_id/mcp_gateway/service_accounts/': () =>+ listResponse([+ account('support', [supportZendesk]),+ account('scout', [personalNotion, staleLinear, readyLinear, github]),+ ]),},})@@ -191,10 +103,10 @@ describe('scoutMcpServersLogic', () => {logic.mount()await expectLogic(logic).toFinishAllListeners()- expect(logic.values.scoutServers).toEqual([linear])- expect(logic.values.isScoutMcpAccessEnabled).toBe(false)- expect(logic.values.readyScoutServers).toEqual([linear])- expect(logic.values.availableScoutServers).toEqual([])- expect(logic.values.scoutServersNeedingSetup).toEqual([])+ expect(logic.values.scoutServers).toEqual([personalNotion, staleLinear, readyLinear, github])+ // The personal grant never backs a scout run, so it never shows. The two team shares+ // of Linear collapse to one row, and the ready one carries it so the health tag does+ // not report a problem the run does not have. Sorting ignores case.+ expect(logic.values.teamScoutServers).toEqual([github, readyLinear])})})diff --git a/products/signals/frontend/inbox/logics/scoutMcpServersLogic.ts b/products/signals/frontend/inbox/logics/scoutMcpServersLogic.tsindex 37943d4f7f71..a86710ab4486 100644--- a/products/signals/frontend/inbox/logics/scoutMcpServersLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutMcpServersLogic.ts@@ -3,9 +3,6 @@ import { loaders } from 'kea-loaders'import { subscriptions } from 'kea-subscriptions'import { teamLogic } from 'scenes/teamLogic'-import { userLogic } from 'scenes/userLogic'--import { UserType } from '~/types'import { mcpGatewayServiceAccountsList } from 'products/mcp_store/frontend/generated/api'import type {@@ -16,19 +13,12 @@ import type {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface scoutMcpServersLogicValues {currentTeamId: number | null // teamLogic- user: UserType | null // userLogic- availableScoutServers: MCPServiceAccountServerApi[]- currentUserId: number | null- isScoutMcpAccessEnabled: boolean- readyScoutServers: MCPServiceAccountServerApi[]scoutAccount: MCPServiceAccountApi | nullscoutServers: MCPServiceAccountServerApi[]scoutServersLoading: boolean- scoutServersNeedingSetup: MCPServiceAccountServerApi[]serviceAccounts: MCPServiceAccountApi[]serviceAccountsLoading: boolean- teammateScoutServers: MCPServiceAccountServerApi[]- yourScoutServers: MCPServiceAccountServerApi[]+ teamScoutServers: MCPServiceAccountServerApi[]}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -53,27 +43,9 @@ export interface scoutMcpServersLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface scoutMcpServersLogicMeta {__keaTypeGenInternalSelectorTypes: {- currentUserId: (user: UserType | null) => number | nullscoutAccount: (serviceAccounts: MCPServiceAccountApi[]) => MCPServiceAccountApi | null- isScoutMcpAccessEnabled: (scoutAccount: MCPServiceAccountApi | null) => booleanscoutServers: (scoutAccount: MCPServiceAccountApi | null) => MCPServiceAccountServerApi[]- yourScoutServers: (- scoutServers: MCPServiceAccountServerApi[],- currentUserId: number | null- ) => MCPServiceAccountServerApi[]- teammateScoutServers: (- scoutServers: MCPServiceAccountServerApi[],- currentUserId: number | null- ) => MCPServiceAccountServerApi[]- readyScoutServers: (- yourScoutServers: MCPServiceAccountServerApi[],- teammateScoutServers: MCPServiceAccountServerApi[]- ) => MCPServiceAccountServerApi[]- availableScoutServers: (- readyScoutServers: MCPServiceAccountServerApi[],- isScoutMcpAccessEnabled: boolean- ) => MCPServiceAccountServerApi[]- scoutServersNeedingSetup: (yourScoutServers: MCPServiceAccountServerApi[]) => MCPServiceAccountServerApi[]+ teamScoutServers: (scoutServers: MCPServiceAccountServerApi[]) => MCPServiceAccountServerApi[]scoutServersLoading: (serviceAccountsLoading: boolean) => boolean}}@@ -88,7 +60,7 @@ export type scoutMcpServersLogicType = MakeLogicType<export const scoutMcpServersLogic = kea<scoutMcpServersLogicType>([path(['scenes', 'inbox', 'logics', 'scoutMcpServersLogic']),connect({- values: [teamLogic, ['currentTeamId'], userLogic, ['user']],+ values: [teamLogic, ['currentTeamId']],}),loaders(({ values }) => ({serviceAccounts: [@@ -105,75 +77,47 @@ export const scoutMcpServersLogic = kea<scoutMcpServersLogicType>([],})),selectors({- currentUserId: [(s) => [s.user], (user: UserType | null): number | null => user?.id ?? null],scoutAccount: [(s) => [s.serviceAccounts],(serviceAccounts: MCPServiceAccountApi[]): MCPServiceAccountApi | null =>serviceAccounts.find((account) => account.agent_key === 'scout') ?? null,],- isScoutMcpAccessEnabled: [- (s) => [s.scoutAccount],- (scoutAccount: MCPServiceAccountApi | null): boolean => scoutAccount?.status === 'active',- ],scoutServers: [(s) => [s.scoutAccount],(scoutAccount: MCPServiceAccountApi | null): MCPServiceAccountServerApi[] => [...(scoutAccount?.servers ?? []),],],- // A grant belongs to one member. A scout run mounts the grants of the person it runs for- // plus every team-scoped grant in the project, so a teammate's personal grant never backs- // the viewer's scouts but a teammate's team share does. While the user is still loading- // neither partition can be attributed, so both stay empty rather than reading the- // viewer's own grants as teammates'.- yourScoutServers: [- (s) => [s.scoutServers, s.currentUserId],- (scoutServers: MCPServiceAccountServerApi[], currentUserId: number | null): MCPServiceAccountServerApi[] =>- currentUserId === null ? [] : scoutServers.filter((server) => server.shared_by.id === currentUserId),- ],- teammateScoutServers: [- (s) => [s.scoutServers, s.currentUserId],- (scoutServers: MCPServiceAccountServerApi[], currentUserId: number | null): MCPServiceAccountServerApi[] =>- currentUserId === null- ? []- : scoutServers.filter((server) => server.shared_by.id !== currentUserId && server.scope === 'team'),- ],- readyScoutServers: [- (s) => [s.yourScoutServers, s.teammateScoutServers],- (- yourScoutServers: MCPServiceAccountServerApi[],- teammateScoutServers: MCPServiceAccountServerApi[]- ): MCPServiceAccountServerApi[] => {- const yoursReady = yourScoutServers.filter((server) => server.connection_state === 'ready')- // A run's own grant for a server wins over a teammate's team share of the same- // server, so a server the viewer already shares must not be counted twice.- const yourServerIds = new Set(yoursReady.map((server) => server.id))- return [- ...yoursReady,- ...teammateScoutServers.filter(- (server) => server.connection_state === 'ready' && !yourServerIds.has(server.id)- ),- ]+ // Scout runs mount only team-scoped grants, so the picker offers exactly those. Several+ // members can team-share the same server; the picker selects servers, not shares, so+ // collapse to one row per server. Prefer a ready share for the row so the health tag+ // reflects the best backing credential, since the run mounts every healthy team share.+ teamScoutServers: [+ (s) => [s.scoutServers],+ (scoutServers: MCPServiceAccountServerApi[]): MCPServiceAccountServerApi[] => {+ const byServer = new Map<string, MCPServiceAccountServerApi>()+ for (const server of scoutServers) {+ if (server.scope !== 'team') {+ continue+ }+ const existing = byServer.get(server.id)+ if (!existing || (existing.connection_state !== 'ready' && server.connection_state === 'ready')) {+ byServer.set(server.id, server)+ }+ }+ return [...byServer.values()].sort((a, b) =>+ a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })+ )},],- availableScoutServers: [- (s) => [s.readyScoutServers, s.isScoutMcpAccessEnabled],- (- readyScoutServers: MCPServiceAccountServerApi[],- isScoutMcpAccessEnabled: boolean- ): MCPServiceAccountServerApi[] => (isScoutMcpAccessEnabled ? readyScoutServers : []),- ],- scoutServersNeedingSetup: [- (s) => [s.yourScoutServers],- (yourScoutServers: MCPServiceAccountServerApi[]): MCPServiceAccountServerApi[] =>- yourScoutServers.filter((server) => server.connection_state !== 'ready'),- ],scoutServersLoading: [(s) => [s.serviceAccountsLoading],(serviceAccountsLoading: boolean): boolean => serviceAccountsLoading,],}),subscriptions(({ actions }) => ({- currentTeamId: () => actions.loadServiceAccounts(),+ currentTeamId: () => {+ actions.loadServiceAccounts()+ },})),])diff --git a/products/tasks/backend/logic/services/custom_prompt_internals.py b/products/tasks/backend/logic/services/custom_prompt_internals.pyindex bac42b821d4b..40e5899e9dd7 100644--- a/products/tasks/backend/logic/services/custom_prompt_internals.py+++ b/products/tasks/backend/logic/services/custom_prompt_internals.py@@ -211,6 +211,7 @@ async def create_task_and_trigger(workflow_id_prefix: str | None = None,mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,):title = f"[sandbox_prompt:{step_name}] {description[:80]}" if step_name else description[:100]team = await sync_to_async(Team.objects.get)(id=context.team_id)@@ -244,6 +245,7 @@ async def create_task_and_trigger(github_read_access=context.github_read_access,mcp_builtin_agent_key=mcp_builtin_agent_key,mcp_credential_owner_id=mcp_credential_owner_id,+ mcp_gateway_server_ids=mcp_gateway_server_ids,interaction_origin=context.interaction_origin,)# lambda wrap: task.latest_run is a lazy ORM property; sync_to_async needs a callablediff --git a/products/tasks/backend/logic/services/custom_prompt_multi_turn_runner.py b/products/tasks/backend/logic/services/custom_prompt_multi_turn_runner.pyindex dcfd67a093b2..d288a5d7ad28 100644--- a/products/tasks/backend/logic/services/custom_prompt_multi_turn_runner.py+++ b/products/tasks/backend/logic/services/custom_prompt_multi_turn_runner.py@@ -69,6 +69,7 @@ class MultiTurnSession:workflow_id_prefix: str | None = None,mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,) -> tuple[MultiTurnSession, _ModelT]:"""Start a multi-turn sandbox session and wait for the first structured response.@@ -104,6 +105,7 @@ class MultiTurnSession:workflow_id_prefix=workflow_id_prefix,mcp_builtin_agent_key=mcp_builtin_agent_key,mcp_credential_owner_id=mcp_credential_owner_id,+ mcp_gateway_server_ids=mcp_gateway_server_ids,)try:parsed = cls._parse_and_validate(last_message, model, label="initial turn")@@ -160,6 +162,7 @@ class MultiTurnSession:workflow_id_prefix: str | None = None,mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,) -> tuple[MultiTurnSession, str]:"""Start a multi-turn sandbox session and return the first raw agent response.@@ -171,6 +174,10 @@ class MultiTurnSession:`mcp_credential_owner_id` names the person whose MCP Store grants the run maymount. It is separate from the acting user in `context`: the sandbox still actsas the acting user, but grants are personal, so a run with no owner mounts none.++ `mcp_gateway_server_ids` narrows the run's mounts to the listed gateway servers+ regardless of grant scope (a scout's per-scout selection). None leaves them+ unfiltered; an empty list mounts nothing."""task, task_run = await create_task_and_trigger(prompt,@@ -184,6 +191,7 @@ class MultiTurnSession:workflow_id_prefix=workflow_id_prefix,mcp_builtin_agent_key=mcp_builtin_agent_key,mcp_credential_owner_id=mcp_credential_owner_id,+ mcp_gateway_server_ids=mcp_gateway_server_ids,)logger.info("multi_turn: started task=%s run=%s step=%s", task.id, task_run.id, step_name or "unknown")# Get session's parent workflow to send heartbeats to keep the agent alive while waiting for turns.diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex 0bc8c169ed98..803944041414 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -53,6 +53,7 @@ LogLevel = Literal["debug", "info", "warn", "error"]MCPBuiltInAgentKey = Literal["support", "scout"]MCP_BUILT_IN_AGENT_STATE_KEY = "mcp_builtin_agent_key"MCP_CREDENTIAL_OWNER_STATE_KEY = "mcp_credential_owner_id"+MCP_GATEWAY_SERVER_ALLOWLIST_STATE_KEY = "mcp_gateway_server_ids"MCP_BUILT_IN_AGENT_KEY_BY_ORIGIN: dict[str, MCPBuiltInAgentKey] = {"support_reply": "support","signals_scout": "scout",@@ -381,6 +382,23 @@ class Task(DeletedMetaFields, models.Model):owner_id = (self.state or {}).get(MCP_CREDENTIAL_OWNER_STATE_KEY)return owner_id if isinstance(owner_id, int) else None+ @property+ def mcp_gateway_server_allowlist(self) -> list[str] | None:+ """Gateway server ids the run may mount, gating every grant regardless of scope.++ None (no snapshot) leaves mount resolution unfiltered — every non-scout task, and+ pre-snapshot rows. Once a snapshot exists, a malformed value fails closed to an empty+ allowlist: a scout whose selection is unreadable must not fall back to mounting every+ reachable grant. Reads through `mcp_builtin_agent_key` like the owner id: only a+ stamped agent task carries one.+ """+ if self.mcp_builtin_agent_key is None:+ return None+ ids = (self.state or {}).get(MCP_GATEWAY_SERVER_ALLOWLIST_STATE_KEY)+ if ids is None:+ return None+ return [str(i) for i in ids] if isinstance(ids, list) else []+def capture_event(self, event: str, properties: dict | None = None, capture_fn: Callable[..., None] | None = None) -> None:@@ -611,6 +629,7 @@ class Task(DeletedMetaFields, models.Model):mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,client_provenance: TaskClientProvenance | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,) -> tuple["Task", dict[str, Any]]:"""Create the Task row and assemble the initial run's `extra_state`.@@ -696,6 +715,8 @@ class Task(DeletedMetaFields, models.Model):# run to delegate to, and a stray owner id must not be able to ride on a task.if mcp_credential_owner_id is not None:initial_state[MCP_CREDENTIAL_OWNER_STATE_KEY] = mcp_credential_owner_id+ if mcp_gateway_server_ids is not None:+ initial_state[MCP_GATEWAY_SERVER_ALLOWLIST_STATE_KEY] = [str(i) for i in mcp_gateway_server_ids]task = Task.objects.create(team=team,@@ -846,6 +867,7 @@ class Task(DeletedMetaFields, models.Model):mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,client_provenance: TaskClientProvenance | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,) -> "Task":"""Create the Task row without an initial run or workflow.@@ -874,6 +896,7 @@ class Task(DeletedMetaFields, models.Model):mcp_builtin_agent_key=mcp_builtin_agent_key,client_provenance=client_provenance,mcp_credential_owner_id=mcp_credential_owner_id,+ mcp_gateway_server_ids=mcp_gateway_server_ids,)return task@@ -917,6 +940,7 @@ class Task(DeletedMetaFields, models.Model):github_read_access: bool = False,mcp_builtin_agent_key: MCPBuiltInAgentKey | None = None,mcp_credential_owner_id: int | None = None,+ mcp_gateway_server_ids: list[str] | None = None,) -> "Task":from products.tasks.backend.temporal.client import _normalize_slack_context, execute_task_processing_workflow@@ -952,6 +976,7 @@ class Task(DeletedMetaFields, models.Model):custom_image_id=custom_image_id,mcp_builtin_agent_key=mcp_builtin_agent_key,mcp_credential_owner_id=mcp_credential_owner_id,+ mcp_gateway_server_ids=mcp_gateway_server_ids,)run_extra_state = dict(extra_state or {})diff --git a/products/tasks/backend/temporal/process_task/activities/send_followup_to_sandbox.py b/products/tasks/backend/temporal/process_task/activities/send_followup_to_sandbox.pyindex 0e95faa276a9..01609622febb 100644--- a/products/tasks/backend/temporal/process_task/activities/send_followup_to_sandbox.py+++ b/products/tasks/backend/temporal/process_task/activities/send_followup_to_sandbox.py@@ -387,6 +387,7 @@ def _refresh_sandbox_mcp(origin_product=task_run.task.origin_product,task_agent_key=task_run.task.mcp_builtin_agent_key,credential_owner_id=task_run.task.mcp_credential_owner_id,+ allowed_gateway_server_ids=task_run.task.mcp_gateway_server_allowlist,)if user_mcp_configs:mcp_configs = mcp_configs + user_mcp_configsdiff --git a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py b/products/tasks/backend/temporal/process_task/activities/start_agent_server.pyindex c5cd6c67a439..d370377ba813 100644--- a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py+++ b/products/tasks/backend/temporal/process_task/activities/start_agent_server.py@@ -266,6 +266,7 @@ def _prepare_launch(ctx: TaskProcessingContext, scopes: PosthogMcpScopes, sandboorigin_product=task.origin_product,task_agent_key=task.mcp_builtin_agent_key,credential_owner_id=task.mcp_credential_owner_id,+ allowed_gateway_server_ids=task.mcp_gateway_server_allowlist,)if user_mcp_configs:mcp_configs = mcp_configs + user_mcp_configsdiff --git a/products/tasks/backend/temporal/process_task/activities/tests/test_start_agent_server.py b/products/tasks/backend/temporal/process_task/activities/tests/test_start_agent_server.pyindex f0bedbf591fe..c07e94cdf9ff 100644--- a/products/tasks/backend/temporal/process_task/activities/tests/test_start_agent_server.py+++ b/products/tasks/backend/temporal/process_task/activities/tests/test_start_agent_server.py@@ -197,6 +197,7 @@ async def test_start_agent_server_uses_captured_sandbox_event_ingest_flag(mockerorigin_product="support_reply",mcp_builtin_agent_key="support",mcp_credential_owner_id=17,+ mcp_gateway_server_allowlist=["srv-1"],)task_queryset = mocker.patch("products.tasks.backend.temporal.process_task.activities.start_agent_server.Task.objects.select_related"@@ -246,6 +247,7 @@ async def test_start_agent_server_uses_captured_sandbox_event_ingest_flag(mockerorigin_product="support_reply",task_agent_key="support",credential_owner_id=17,+ allowed_gateway_server_ids=["srv-1"],)sandbox.start_agent_server.assert_called_once()assert sandbox.start_agent_server.call_args.kwargs["event_ingest_token"] == "event-ingest-token"@@ -270,6 +272,7 @@ async def test_start_agent_server_forwards_imported_and_relayed_mcp_servers(mockorigin_product="user_created",mcp_builtin_agent_key=None,mcp_credential_owner_id=None,+ mcp_gateway_server_allowlist=None,)mocker.patch("products.tasks.backend.temporal.process_task.activities.start_agent_server.create_oauth_access_token_for_run",@@ -327,6 +330,7 @@ async def test_start_agent_server_passes_initial_permission_mode(mocker) -> Noneorigin_product="user_created",mcp_builtin_agent_key=None,mcp_credential_owner_id=None,+ mcp_gateway_server_allowlist=None,)mocker.patch("products.tasks.backend.temporal.process_task.activities.start_agent_server.create_oauth_access_token_for_run",diff --git a/products/tasks/backend/temporal/process_task/tests/test_send_followup_to_sandbox.py b/products/tasks/backend/temporal/process_task/tests/test_send_followup_to_sandbox.pyindex f73bdf5016b7..4100cf8c4aae 100644--- a/products/tasks/backend/temporal/process_task/tests/test_send_followup_to_sandbox.py+++ b/products/tasks/backend/temporal/process_task/tests/test_send_followup_to_sandbox.py@@ -56,6 +56,7 @@ def _make_task_run_mock(team_id: int = 7, created_by_id: int | None = 42, state:task.origin_product = "user_created"task.mcp_builtin_agent_key = Nonetask.mcp_credential_owner_id = None+ task.mcp_gateway_server_allowlist = Noneif created_by_id is not None:task.created_by = MagicMock(id=created_by_id, distinct_id=f"user-{created_by_id}")else:@@ -103,6 +104,7 @@ class TestRefreshSandboxMcp:task_run.task.origin_product = "support_reply"task_run.task.mcp_builtin_agent_key = "support"task_run.task.mcp_credential_owner_id = 99+ task_run.task.mcp_gateway_server_allowlist = ["srv-9"]_refresh(task_run, auth_token="jwt")mock_oauth.assert_called_once_with(task_run.task, task_run.state, scopes="read_only")@@ -119,6 +121,7 @@ class TestRefreshSandboxMcp:origin_product="support_reply",task_agent_key="support",credential_owner_id=99,+ allowed_gateway_server_ids=["srv-9"],)mock_send_refresh.assert_called_once()_, kwargs = mock_send_refresh.call_argsdiff --git a/products/tasks/backend/temporal/process_task/tests/test_utils.py b/products/tasks/backend/temporal/process_task/tests/test_utils.pyindex b21b03f3bc76..3dc4bf90176c 100644--- a/products/tasks/backend/temporal/process_task/tests/test_utils.py+++ b/products/tasks/backend/temporal/process_task/tests/test_utils.py@@ -373,6 +373,7 @@ class TestFetchUserMcpServerConfigs(TestCase):task_origin=None,task_agent_key=None,credential_owner_id=None,+ allowed_gateway_server_ids=None,)assert configs == [McpServerConfig(@@ -465,10 +466,12 @@ class TestFetchUserMcpServerConfigs(TestCase):origin_product="support_reply",task_agent_key="support",credential_owner_id=self.CREDENTIAL_OWNER_ID,+ allowed_gateway_server_ids=["server-1"],)# The credential owner is forwarded separately from the acting user: the sandbox acts- # as `user_id`, but it may only mount the grants belonging to the owner.+ # as `user_id`, but it may only mount the grants belonging to the owner. The per-scout+ # allowlist rides along untouched — the facade applies it, not this layer.mock_facade.assert_called_once_with(self.TEAM_ID,user_id=self.USER_ID,@@ -476,6 +479,7 @@ class TestFetchUserMcpServerConfigs(TestCase):task_origin="support_reply",task_agent_key="support",credential_owner_id=self.CREDENTIAL_OWNER_ID,+ allowed_gateway_server_ids=["server-1"],)assert configs == [McpServerConfig(@@ -506,6 +510,7 @@ class TestFetchUserMcpServerConfigs(TestCase):task_origin=None,task_agent_key=None,credential_owner_id=None,+ allowed_gateway_server_ids=None,)@patch(MOCK_API_URL)diff --git a/products/tasks/backend/temporal/process_task/utils.py b/products/tasks/backend/temporal/process_task/utils.pyindex 595138bc89e4..e5ba3d8864e7 100644--- a/products/tasks/backend/temporal/process_task/utils.py+++ b/products/tasks/backend/temporal/process_task/utils.py@@ -575,6 +575,7 @@ def get_user_mcp_server_configs(origin_product: str | None = None,task_agent_key: str | None = None,credential_owner_id: int | None = None,+ allowed_gateway_server_ids: list[str] | None = None,) -> list[McpServerConfig]:"""Fetch MCP Store installations for sandbox use and return configs.@@ -596,6 +597,11 @@ def get_user_mcp_server_configs(those installations. Without it, an unattended loop run would mount every shared team connectorrather than only the ones its owner chose.+ ``allowed_gateway_server_ids`` is the built-in agent counterpart (a scout's per-scout+ selection, from ``Task.mcp_gateway_server_allowlist``): it narrows the agent's mounts to+ the listed gateway servers regardless of grant scope. ``None`` leaves them unfiltered;+ an empty list mounts nothing.+The `x-posthog-mcp-consumer` header is set on every config so the agent'sidentity propagates through the MCP Store proxy to whichever upstream MCPthe user installed. The PostHog MCP needs this to resolve single-exec mode@@ -611,6 +617,7 @@ def get_user_mcp_server_configs(task_origin=origin_product,task_agent_key=task_agent_key,credential_owner_id=credential_owner_id,+ allowed_gateway_server_ids=allowed_gateway_server_ids,)if allowed_installation_ids is not None:allowed = {str(i) for i in allowed_installation_ids}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 2c66ab214800..ed75ea0dc95d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -59342,6 +59342,11 @@ export namespace Schemas {* @maxItems 10*/tags?: string[];+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[];}export interface PatchedSignalSourceConfig {@@ -69688,6 +69693,11 @@ export namespace Schemas {* @nullable*/readonly model: string | null;+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ readonly mcp_gateway_server_ids: readonly string[];/*** When the coordinator last dispatched this scout. Null if it has never run.* @nullable@@ -69761,6 +69771,11 @@ export namespace Schemas {* @nullable*/structured_output_schema?: SignalScoutConfigCreateStructuredOutputSchema;+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[];/*** The `signals-scout-*` skill to register a config for. The skill must already exist on this project — author it via the skills store first.* @maxLength 200@@ -69819,6 +69834,11 @@ export namespace Schemas {* @nullable*/structured_output_schema?: SignalScoutConfigOptionsStructuredOutputSchema;+ /**+ * MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.+ * @maxItems 100+ */+ mcp_gateway_server_ids?: string[];}/**diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 84c8ee3841f1..171580406a9e 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -430,6 +430,8 @@ export const signalsScoutCreateBodyConfigOneModelMax = 200export const signalsScoutCreateBodyConfigOneTagsMax = 10+export const signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax = 100+export const SignalsScoutCreateBody = /* @__PURE__ */ zod.object({name: zod@@ -552,6 +554,13 @@ export const SignalsScoutCreateBody = /* @__PURE__ */ zod.describe('Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'),+ mcp_gateway_server_ids: zod+ .array(zod.string())+ .max(signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),}).describe('Schedule, enablement, and delivery options accepted while creating a scout.').optional()@@ -606,6 +615,8 @@ export const signalsScoutConfigCreateBodyModelMax = 200export const signalsScoutConfigCreateBodyTagsMax = 10+export const signalsScoutConfigCreateBodyMcpGatewayServerIdsMax = 100+export const signalsScoutConfigCreateBodySkillNameMax = 200export const SignalsScoutConfigCreateBody = /* @__PURE__ */ zod@@ -691,6 +702,13 @@ export const SignalsScoutConfigCreateBody = /* @__PURE__ */ zod.describe('Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'),+ mcp_gateway_server_ids: zod+ .array(zod.string())+ .max(signalsScoutConfigCreateBodyMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),skill_name: zod.string().max(signalsScoutConfigCreateBodySkillNameMax)@@ -726,6 +744,8 @@ export const signalsScoutConfigUpdateBodyModelMax = 200export const signalsScoutConfigUpdateBodyTagsMax = 10+export const signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax = 100+export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.object({enabled: zod@@ -816,6 +836,13 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.describe('Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.'),+ mcp_gateway_server_ids: zod+ .array(zod.string())+ .max(signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax)+ .optional()+ .describe(+ "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."+ ),}).describe('Editable schedule, enablement, and emit posture for one scout config.')diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.tsindex 19026e50f336..dca112472cad 100644--- a/services/mcp/src/tools/generated/signals.ts+++ b/services/mcp/src/tools/generated/signals.ts@@ -548,6 +548,9 @@ const scoutConfigCreate = (): ToolBase<typeof ScoutConfigCreateSchema, Schemas.Sif (params.structured_output_schema !== undefined) {body['structured_output_schema'] = params.structured_output_schema}+ if (params.mcp_gateway_server_ids !== undefined) {+ body['mcp_gateway_server_ids'] = params.mcp_gateway_server_ids+ }if (params.skill_name !== undefined) {body['skill_name'] = params.skill_name}@@ -649,6 +652,9 @@ const scoutConfigUpdate = (): ToolBase<typeof ScoutConfigUpdateSchema, WithPostHif (params.tags !== undefined) {body['tags'] = params.tags}+ if (params.mcp_gateway_server_ids !== undefined) {+ body['mcp_gateway_server_ids'] = params.mcp_gateway_server_ids+ }const result = await context.api.request<Schemas.SignalScoutConfig>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/configs/${encodeURIComponent(String(params.id))}/`,@@ -1239,6 +1245,9 @@ const signalsScoutConfigCreate = (): ToolBase<typeof SignalsScoutConfigCreateSchif (params.structured_output_schema !== undefined) {body['structured_output_schema'] = params.structured_output_schema}+ if (params.mcp_gateway_server_ids !== undefined) {+ body['mcp_gateway_server_ids'] = params.mcp_gateway_server_ids+ }if (params.skill_name !== undefined) {body['skill_name'] = params.skill_name}@@ -1349,6 +1358,9 @@ const signalsScoutConfigUpdate = (): ToolBase<if (params.tags !== undefined) {body['tags'] = params.tags}+ if (params.mcp_gateway_server_ids !== undefined) {+ body['mcp_gateway_server_ids'] = params.mcp_gateway_server_ids+ }const result = await context.api.request<Schemas.SignalScoutConfig>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/configs/${encodeURIComponent(String(params.id))}/`,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.jsonindex 532320c2d115..71f54c49e808 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json@@ -14,6 +14,14 @@"description": "Whether this scout runs on its schedule. Defaults to true.","type": "boolean"},+ "mcp_gateway_server_ids": {+ "description": "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.",+ "items": {+ "type": "string"+ },+ "maxItems": 100,+ "type": "array"+ },"model": {"anyOf": [{diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.jsonindex 01139b66368a..d6b8b1263126 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json@@ -17,6 +17,14 @@"description": "A UUID string identifying this Signal scout config.","type": "string"},+ "mcp_gateway_server_ids": {+ "description": "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.",+ "items": {+ "type": "string"+ },+ "maxItems": 100,+ "type": "array"+ },"model": {"anyOf": [{diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create-prepare.jsonindex d05c609bcf6b..e3539112831f 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create-prepare.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create-prepare.json@@ -21,6 +21,14 @@"description": "Whether this scout runs on its schedule. Defaults to true.","type": "boolean"},+ "mcp_gateway_server_ids": {+ "description": "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.",+ "items": {+ "type": "string"+ },+ "maxItems": 100,+ "type": "array"+ },"model": {"anyOf": [{diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.jsonindex 532320c2d115..71f54c49e808 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json@@ -14,6 +14,14 @@"description": "Whether this scout runs on its schedule. Defaults to true.","type": "boolean"},+ "mcp_gateway_server_ids": {+ "description": "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.",+ "items": {+ "type": "string"+ },+ "maxItems": 100,+ "type": "array"+ },"model": {"anyOf": [{diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.jsonindex 01139b66368a..d6b8b1263126 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json@@ -17,6 +17,14 @@"description": "A UUID string identifying this Signal scout config.","type": "string"},+ "mcp_gateway_server_ids": {+ "description": "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run.",+ "items": {+ "type": "string"+ },+ "maxItems": 100,+ "type": "array"+ },"model": {"anyOf": [{