Skip to content

fix(mcp): surface scope-gated tools in exec search#60676

Merged
Gilbert09 merged 2 commits into
masterfrom
tom/mcp-scope-gated-search
Jun 3, 2026
Merged

fix(mcp): surface scope-gated tools in exec search#60676
Gilbert09 merged 2 commits into
masterfrom
tom/mcp-scope-gated-search

Conversation

@Gilbert09
Copy link
Copy Markdown
Member

Problem

This came out of MCP agent feedback that the data-warehouse source/schema management tools were "missing" — an agent doing a source-sync follow-up could find external-data-sync-logs but not external-data-sources-refresh-schemas, external-data-schemas-list, external-data-schemas-partial-update, or the reload tools.

Those tools are not missing — they have been defined and enabled since March 2026. The real issue is in the discovery layer: the exec search command only matches over the session's already-loaded tool set, which is silently filtered by the API key's scopes (getToolsFromContexthasScopes). A key with query:read but not external_data_source sees execute-sql and external-data-sync-logs (both query:read) but every source/schema management tool (external_data_source:read/:write) is dropped with no signal. The agent then reasonably concludes the tools don't exist.

Changes

Made the exec search command scope-aware. When a query matches tools that exist and are enabled for the session's features but were hidden by scope filtering, search now returns them under a scope_gated_matches field alongside a hint naming the missing scope(s) — turning a silent omission into an actionable "add this scope to your personal API key" message.

  • tools/toolDefinitions.ts — new getScopeGatedTools() helper + ScopeGatedTool type (tools that pass every filter except scopes).
  • tools/exec.tssearch surfaces scope-gated matches; new optional scopeGatedTools param on createExecTool.
  • mcp.ts, hono/request-state-resolver.ts, hono/tool-executor.ts — compute and thread the scope-gated set through both exec wiring paths.
  • templates/sections/tool-search.md — instruct agents to surface the scope hint to the user rather than declaring the tool unavailable.

No tool definitions or scopes changed — this is purely a discoverability improvement.

How did you test this code?

I'm an agent (Claude Code); I did not perform manual MCP-client testing. Automated tests I actually ran:

  • Added unit tests in tests/unit/exec.test.ts covering: plain-array search results (unchanged), scope-gated matches producing the hint + scope_gated_matches, and scope-gated tools that don't match the query being ignored.
  • Full unit project: 1355 tests pass (49 files).
  • Affected hono tests (tool-executor, tool-executor-metrics, analytics): 19 pass.
  • tsc --noEmit clean for all touched files.
  • Updated 3 snapshots — diffs reflect only the new tool-search.md line.

🤖 Agent context

Authored by Claude Code (Opus) at Tom's direction, in response to a piece of MCP agent feedback categorized as "missing_tool".

Investigation path: first verified the supposedly-missing tools were in fact present and enabled: true in products/data_warehouse/mcp/tools.yaml (since PR #50859, March 2026), ruling out the "missing tool" premise. Then traced the discovery path — tool-search.md → exec search (exec.ts) → allTools, which is built post-scope-filter in both the DO path (mcp.ts via getToolsFromContext) and the hono path (request-state-resolver.ts via ToolCatalog.getFilteredTools). Confirmed the differentiator was scopes: external-data-sync-logs requires query:read while every source/schema tool requires external_data_source:*, which matches exactly the tool set the reporter could vs. couldn't use.

Considered but rejected: (1) editing tool descriptions/keywords — descriptions were already good, this wasn't a keyword-match problem; (2) changing the domain-collapsing logic in instructions.ts — orthogonal to the scope issue; (3) loosening scope filtering — wrong, the filter is correct, the problem was the silent failure. Chose to make the failure visible instead.

@Gilbert09 Gilbert09 requested review from Copilot, joshsny and skoob13 May 29, 2026 13:43
@Gilbert09 Gilbert09 requested a review from a team May 29, 2026 13:47
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Size Change: 0 B

Total Size: 81 MB

ℹ️ View Unchanged
Filename Size
frontend/dist-report/decompression-worker/src/scenes/session-recordings/player/snapshot-processing/decompressionWorker 2.85 kB
frontend/dist-report/exporter/_chunks/chunk 8.45 MB
frontend/dist-report/exporter/_parent/products/actions/frontend/pages/Action 25 kB
frontend/dist-report/exporter/_parent/products/actions/frontend/pages/Actions 1.33 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/AIObservabilityScene 119 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/AIObservabilitySessionScene 19.9 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/AIObservabilityTraceScene 132 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/AIObservabilityUsers 872 B
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/clusters/AIObservabilityClusterScene 21.7 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/clusters/AIObservabilityClustersScene 55.1 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/datasets/AIObservabilityDatasetScene 21 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene 3.64 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation 59.9 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene 28.2 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/evaluations/EvaluationTemplates 915 B
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/LLMASessionFeedbackDisplay 5.19 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene 37.8 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/prompts/LLMPromptScene 29.2 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/prompts/LLMPromptsScene 4.83 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/skills/LLMSkillScene 929 B
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/skills/LLMSkillsScene 946 B
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/tags/AIObservabilityTag 27.4 kB
frontend/dist-report/exporter/_parent/products/ai_observability/frontend/tags/AIObservabilityTagsScene 7.31 kB
frontend/dist-report/exporter/_parent/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene 19 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/components/Assignee/CyclotronJobInputAssignee 1.67 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/components/SlaBusinessHours/CyclotronJobInputBusinessHours 3.06 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/components/TicketTags/CyclotronJobInputTicketTags 1.06 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/scenes/settings/SupportSettingsScene 1.82 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/scenes/ticket/SupportTicketScene 34.4 kB
frontend/dist-report/exporter/_parent/products/conversations/frontend/scenes/tickets/SupportTicketsScene 1.07 kB
frontend/dist-report/exporter/_parent/products/customer_analytics/frontend/CustomerAnalyticsScene 53.1 kB
frontend/dist-report/exporter/_parent/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/CustomerAnalyticsConfigurationScene 2.65 kB
frontend/dist-report/exporter/_parent/products/customer_analytics/frontend/scenes/CustomerJourneyBuilderScene/CustomerJourneyBuilderScene 2.18 kB
frontend/dist-report/exporter/_parent/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/CustomerJourneyTemplatesScene 7.86 kB
frontend/dist-report/exporter/_parent/products/data_warehouse/DataWarehouseScene 46.8 kB
frontend/dist-report/exporter/_parent/products/data_warehouse/frontend/scenes/NewSourceScene/NewSourceScene 1.12 kB
frontend/dist-report/exporter/_parent/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene 24.7 kB
frontend/dist-report/exporter/_parent/products/data_warehouse/frontend/scenes/SourceScene/SourceScene 1.06 kB
frontend/dist-report/exporter/_parent/products/data_warehouse/frontend/scenes/SourcesScene/SourcesScene 6.31 kB
frontend/dist-report/exporter/_parent/products/deployments/frontend/Deployment 4.05 kB
frontend/dist-report/exporter/_parent/products/deployments/frontend/DeploymentProject 5.58 kB
frontend/dist-report/exporter/_parent/products/deployments/frontend/Deployments 9.31 kB
frontend/dist-report/exporter/_parent/products/early_access_features/frontend/EarlyAccessFeature 1.02 kB
frontend/dist-report/exporter/_parent/products/early_access_features/frontend/EarlyAccessFeatures 3.24 kB
frontend/dist-report/exporter/_parent/products/endpoints/frontend/EndpointScene 40.6 kB
frontend/dist-report/exporter/_parent/products/endpoints/frontend/EndpointsScene 24.5 kB
frontend/dist-report/exporter/_parent/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintsScene/ErrorTrackingIssueFingerprintsScene 7.41 kB
frontend/dist-report/exporter/_parent/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene 104 kB
frontend/dist-report/exporter/_parent/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene 27.1 kB
frontend/dist-report/exporter/_parent/products/feature_flags/frontend/FeatureFlagTemplatesScene 7.38 kB
frontend/dist-report/exporter/_parent/products/games/368Hedgehogs/368Hedgehogs 5.61 kB
frontend/dist-report/exporter/_parent/products/games/FlappyHog/FlappyHog 6.12 kB
frontend/dist-report/exporter/_parent/products/legal_documents/frontend/scenes/LegalDocumentNewScene 60.5 kB
frontend/dist-report/exporter/_parent/products/legal_documents/frontend/scenes/LegalDocumentsScene 5.31 kB
frontend/dist-report/exporter/_parent/products/links/frontend/LinkScene 25.2 kB
frontend/dist-report/exporter/_parent/products/links/frontend/LinksScene 4.55 kB
frontend/dist-report/exporter/_parent/products/live_debugger/frontend/LiveDebugger 19.5 kB
frontend/dist-report/exporter/_parent/products/logs/frontend/LogsScene 17.9 kB
frontend/dist-report/exporter/_parent/products/logs/frontend/scenes/LogsAlertDetailScene/LogsAlertDetailScene 17.2 kB
frontend/dist-report/exporter/_parent/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene 8.49 kB
frontend/dist-report/exporter/_parent/products/logs/frontend/scenes/LogsSamplingDetailScene/LogsSamplingDetailScene 5.3 kB
frontend/dist-report/exporter/_parent/products/logs/frontend/scenes/LogsSamplingNewScene/LogsSamplingNewScene 2.25 kB
frontend/dist-report/exporter/_parent/products/managed_migrations/frontend/ManagedMigration 14.9 kB
frontend/dist-report/exporter/_parent/products/mcp_analytics/frontend/MCPAnalyticsScene 40.6 kB
frontend/dist-report/exporter/_parent/products/mcp_analytics/frontend/MCPAnalyticsToolDetail 18.5 kB
frontend/dist-report/exporter/_parent/products/metrics/frontend/MetricsScene 16.2 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart 3.31 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart 3.14 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart 7.85 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart 4.41 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart 4.6 kB
frontend/dist-report/exporter/_parent/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart 4.35 kB
frontend/dist-report/exporter/_parent/products/replay_vision/frontend/observations/ReplayObservation 8.64 kB
frontend/dist-report/exporter/_parent/products/replay_vision/frontend/replay_scanners/ReplayScanner 35.3 kB
frontend/dist-report/exporter/_parent/products/replay_vision/frontend/replay_scanners/ReplayScannersScene 11.6 kB
frontend/dist-report/exporter/_parent/products/replay_vision/frontend/replay_scanners/ScannerTemplatesScene 4.59 kB
frontend/dist-report/exporter/_parent/products/revenue_analytics/frontend/RevenueAnalyticsScene 26.5 kB
frontend/dist-report/exporter/_parent/products/session_summaries/frontend/SessionGroupSummariesTable 5.05 kB
frontend/dist-report/exporter/_parent/products/session_summaries/frontend/SessionGroupSummaryScene 19.2 kB
frontend/dist-report/exporter/_parent/products/tasks/frontend/SlackTaskContextScene 8.88 kB
frontend/dist-report/exporter/_parent/products/tasks/frontend/TaskDetailScene 23.8 kB
frontend/dist-report/exporter/_parent/products/tasks/frontend/TaskTracker 14.6 kB
frontend/dist-report/exporter/_parent/products/tracing/frontend/TracingScene 60.5 kB
frontend/dist-report/exporter/_parent/products/user_interviews/frontend/UserInterview 9.32 kB
frontend/dist-report/exporter/_parent/products/user_interviews/frontend/UserInterviewResponse 7.79 kB
frontend/dist-report/exporter/_parent/products/user_interviews/frontend/UserInterviews 6.08 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewIndexScene 2.56 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewRunScene 44.8 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewRunsScene 7.32 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewSettingsScene 11.1 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene 13.9 kB
frontend/dist-report/exporter/_parent/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene 19.6 kB
frontend/dist-report/exporter/_parent/products/workflows/frontend/TemplateLibrary/MessageTemplate 16.6 kB
frontend/dist-report/exporter/_parent/products/workflows/frontend/Workflows/WorkflowScene 111 kB
frontend/dist-report/exporter/_parent/products/workflows/frontend/WorkflowsScene 60.2 kB
frontend/dist-report/exporter/src/exporter/exporter 19.7 kB
frontend/dist-report/exporter/src/exporter/scenes/ExporterDashboardScene 2.02 kB
frontend/dist-report/exporter/src/exporter/scenes/ExporterHeatmapScene 19.9 kB
frontend/dist-report/exporter/src/exporter/scenes/ExporterInsightScene 3.02 kB
frontend/dist-report/exporter/src/exporter/scenes/ExporterInterviewScene 310 kB
frontend/dist-report/exporter/src/exporter/scenes/ExporterNotebookScene 2.71 MB
frontend/dist-report/exporter/src/exporter/scenes/ExporterRecordingScene 1.13 kB
frontend/dist-report/exporter/src/exporterSharedChunkAnchors 1.19 kB
frontend/dist-report/exporter/src/lib/components/Cards/TextCard/TextCardMarkdownEditor 11.3 kB
frontend/dist-report/exporter/src/lib/components/MonacoDiffEditor 471 B
frontend/dist-report/exporter/src/lib/lemon-ui/LemonMarkdown/MermaidDiagram 2.25 kB
frontend/dist-report/exporter/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown 842 B
frontend/dist-report/exporter/src/lib/lemon-ui/Link/Link 359 B
frontend/dist-report/exporter/src/lib/monaco/CodeEditorInline 832 B
frontend/dist-report/exporter/src/lib/monaco/vimMode 211 kB
frontend/dist-report/exporter/src/lib/ui/Button/ButtonPrimitives 422 B
frontend/dist-report/exporter/src/queries/nodes/WebVitals/WebVitals 7.52 kB
frontend/dist-report/exporter/src/queries/nodes/WebVitals/WebVitalsPathBreakdown 4.09 kB
frontend/dist-report/exporter/src/queries/schema 856 kB
frontend/dist-report/exporter/src/scenes/approvals/changeRequestsLogic 884 B
frontend/dist-report/exporter/src/scenes/authentication/passkeyLogic 824 B
frontend/dist-report/exporter/src/scenes/data-pipelines/event-filtering/EventFilterScene 22.2 kB
frontend/dist-report/exporter/src/scenes/data-pipelines/TransformationsScene 6.54 kB
frontend/dist-report/exporter/src/scenes/insights/views/BoxPlot/BoxPlot 5.39 kB
frontend/dist-report/exporter/src/scenes/insights/views/CalendarHeatMap/CalendarHeatMap 8.84 kB
frontend/dist-report/exporter/src/scenes/insights/views/RegionMap/RegionMap 29.8 kB
frontend/dist-report/exporter/src/scenes/insights/views/WorldMap/WorldMap 1.04 MB
frontend/dist-report/exporter/src/scenes/models/ModelsScene 19 kB
frontend/dist-report/exporter/src/scenes/models/NodeDetailScene 17 kB
frontend/dist-report/monaco-editor-worker/src/lib/monaco/workers/monacoEditorWorker 288 kB
frontend/dist-report/monaco-json-worker/src/lib/monaco/workers/monacoJsonWorker 419 kB
frontend/dist-report/monaco-typescript-worker/src/lib/monaco/workers/monacoTsWorker 7.02 MB
frontend/dist-report/posthog-app/_chunks/chunk 8.66 MB
frontend/dist-report/posthog-app/_parent/products/actions/frontend/pages/Action 25.1 kB
frontend/dist-report/posthog-app/_parent/products/actions/frontend/pages/Actions 1.4 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/AIObservabilityScene 120 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/AIObservabilitySessionScene 19.9 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/AIObservabilityTraceScene 132 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/AIObservabilityUsers 906 B
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/clusters/AIObservabilityClusterScene 21.7 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/clusters/AIObservabilityClustersScene 55.1 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/datasets/AIObservabilityDatasetScene 21 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/datasets/AIObservabilityDatasetsScene 3.67 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation 59.9 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/evaluations/AIObservabilityEvaluationsScene 28.2 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/evaluations/EvaluationTemplates 949 B
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/LLMASessionFeedbackDisplay 5.23 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene 37.8 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/prompts/LLMPromptScene 29.2 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/prompts/LLMPromptsScene 4.86 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/skills/LLMSkillScene 963 B
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/skills/LLMSkillsScene 980 B
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/tags/AIObservabilityTag 27.4 kB
frontend/dist-report/posthog-app/_parent/products/ai_observability/frontend/tags/AIObservabilityTagsScene 7.34 kB
frontend/dist-report/posthog-app/_parent/products/business_knowledge/frontend/scenes/BusinessKnowledgeScene 19 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/components/Assignee/CyclotronJobInputAssignee 1.71 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/components/SlaBusinessHours/CyclotronJobInputBusinessHours 3.09 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/components/TicketTags/CyclotronJobInputTicketTags 1.09 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/scenes/settings/SupportSettingsScene 1.85 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/scenes/ticket/SupportTicketScene 26.6 kB
frontend/dist-report/posthog-app/_parent/products/conversations/frontend/scenes/tickets/SupportTicketsScene 1.11 kB
frontend/dist-report/posthog-app/_parent/products/customer_analytics/frontend/CustomerAnalyticsScene 51.9 kB
frontend/dist-report/posthog-app/_parent/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/CustomerAnalyticsConfigurationScene 2.68 kB
frontend/dist-report/posthog-app/_parent/products/customer_analytics/frontend/scenes/CustomerJourneyBuilderScene/CustomerJourneyBuilderScene 2.22 kB
frontend/dist-report/posthog-app/_parent/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/CustomerJourneyTemplatesScene 7.9 kB
frontend/dist-report/posthog-app/_parent/products/data_warehouse/DataWarehouseScene 1.81 kB
frontend/dist-report/posthog-app/_parent/products/data_warehouse/frontend/scenes/NewSourceScene/NewSourceScene 1.22 kB
frontend/dist-report/posthog-app/_parent/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene 24.8 kB
frontend/dist-report/posthog-app/_parent/products/data_warehouse/frontend/scenes/SourceScene/SourceScene 1.13 kB
frontend/dist-report/posthog-app/_parent/products/data_warehouse/frontend/scenes/SourcesScene/SourcesScene 6.34 kB
frontend/dist-report/posthog-app/_parent/products/deployments/frontend/Deployment 4.08 kB
frontend/dist-report/posthog-app/_parent/products/deployments/frontend/DeploymentProject 5.61 kB
frontend/dist-report/posthog-app/_parent/products/deployments/frontend/Deployments 9.35 kB
frontend/dist-report/posthog-app/_parent/products/early_access_features/frontend/EarlyAccessFeature 1.2 kB
frontend/dist-report/posthog-app/_parent/products/early_access_features/frontend/EarlyAccessFeatures 3.28 kB
frontend/dist-report/posthog-app/_parent/products/endpoints/frontend/EndpointScene 40.7 kB
frontend/dist-report/posthog-app/_parent/products/endpoints/frontend/EndpointsScene 22.4 kB
frontend/dist-report/posthog-app/_parent/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintsScene/ErrorTrackingIssueFingerprintsScene 7.48 kB
frontend/dist-report/posthog-app/_parent/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene 103 kB
frontend/dist-report/posthog-app/_parent/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene 27.2 kB
frontend/dist-report/posthog-app/_parent/products/feature_flags/frontend/FeatureFlagTemplatesScene 7.42 kB
frontend/dist-report/posthog-app/_parent/products/games/368Hedgehogs/368Hedgehogs 5.65 kB
frontend/dist-report/posthog-app/_parent/products/games/FlappyHog/FlappyHog 6.16 kB
frontend/dist-report/posthog-app/_parent/products/legal_documents/frontend/scenes/LegalDocumentNewScene 60.5 kB
frontend/dist-report/posthog-app/_parent/products/legal_documents/frontend/scenes/LegalDocumentsScene 5.35 kB
frontend/dist-report/posthog-app/_parent/products/links/frontend/LinkScene 25.2 kB
frontend/dist-report/posthog-app/_parent/products/links/frontend/LinksScene 4.58 kB
frontend/dist-report/posthog-app/_parent/products/live_debugger/frontend/LiveDebugger 19.5 kB
frontend/dist-report/posthog-app/_parent/products/logs/frontend/LogsScene 17.9 kB
frontend/dist-report/posthog-app/_parent/products/logs/frontend/scenes/LogsAlertDetailScene/LogsAlertDetailScene 17.3 kB
frontend/dist-report/posthog-app/_parent/products/logs/frontend/scenes/LogsAlertNotificationDetailScene/LogsAlertNotificationDetailScene 8.53 kB
frontend/dist-report/posthog-app/_parent/products/logs/frontend/scenes/LogsSamplingDetailScene/LogsSamplingDetailScene 5.34 kB
frontend/dist-report/posthog-app/_parent/products/logs/frontend/scenes/LogsSamplingNewScene/LogsSamplingNewScene 2.29 kB
frontend/dist-report/posthog-app/_parent/products/managed_migrations/frontend/ManagedMigration 14.9 kB
frontend/dist-report/posthog-app/_parent/products/mcp_analytics/frontend/MCPAnalyticsScene 40.6 kB
frontend/dist-report/posthog-app/_parent/products/mcp_analytics/frontend/MCPAnalyticsToolDetail 18.6 kB
frontend/dist-report/posthog-app/_parent/products/metrics/frontend/MetricsScene 16.2 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart 3.34 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart 3.18 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart 7.89 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart 4.45 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart 4.64 kB
frontend/dist-report/posthog-app/_parent/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart 4.38 kB
frontend/dist-report/posthog-app/_parent/products/replay_vision/frontend/observations/ReplayObservation 8.68 kB
frontend/dist-report/posthog-app/_parent/products/replay_vision/frontend/replay_scanners/ReplayScanner 35.4 kB
frontend/dist-report/posthog-app/_parent/products/replay_vision/frontend/replay_scanners/ReplayScannersScene 11.6 kB
frontend/dist-report/posthog-app/_parent/products/replay_vision/frontend/replay_scanners/ScannerTemplatesScene 4.63 kB
frontend/dist-report/posthog-app/_parent/products/revenue_analytics/frontend/RevenueAnalyticsScene 26.6 kB
frontend/dist-report/posthog-app/_parent/products/session_summaries/frontend/SessionGroupSummariesTable 5.09 kB
frontend/dist-report/posthog-app/_parent/products/session_summaries/frontend/SessionGroupSummaryScene 19.3 kB
frontend/dist-report/posthog-app/_parent/products/tasks/frontend/SlackTaskContextScene 8.91 kB
frontend/dist-report/posthog-app/_parent/products/tasks/frontend/TaskDetailScene 23.9 kB
frontend/dist-report/posthog-app/_parent/products/tasks/frontend/TaskTracker 14.7 kB
frontend/dist-report/posthog-app/_parent/products/tracing/frontend/TracingScene 60.6 kB
frontend/dist-report/posthog-app/_parent/products/user_interviews/frontend/UserInterview 9.35 kB
frontend/dist-report/posthog-app/_parent/products/user_interviews/frontend/UserInterviewResponse 7.83 kB
frontend/dist-report/posthog-app/_parent/products/user_interviews/frontend/UserInterviews 6.12 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewIndexScene 2.59 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewRunScene 44.8 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewRunsScene 7.36 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewSettingsScene 11.1 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewSnapshotHistoryScene 13.9 kB
frontend/dist-report/posthog-app/_parent/products/visual_review/frontend/scenes/VisualReviewSnapshotOverviewScene 19.6 kB
frontend/dist-report/posthog-app/_parent/products/workflows/frontend/TemplateLibrary/MessageTemplate 16.7 kB
frontend/dist-report/posthog-app/_parent/products/workflows/frontend/Workflows/WorkflowScene 104 kB
frontend/dist-report/posthog-app/_parent/products/workflows/frontend/WorkflowsScene 60.3 kB
frontend/dist-report/posthog-app/src/index 61.1 kB
frontend/dist-report/posthog-app/src/layout/panel-layout/ai-first/tabs/NavTabChat 7.26 kB
frontend/dist-report/posthog-app/src/lib/components/Cards/TextCard/TextCardMarkdownEditor 11.3 kB
frontend/dist-report/posthog-app/src/lib/components/MonacoDiffEditor 471 B
frontend/dist-report/posthog-app/src/lib/lemon-ui/LemonMarkdown/MermaidDiagram 2.29 kB
frontend/dist-report/posthog-app/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown 876 B
frontend/dist-report/posthog-app/src/lib/lemon-ui/Link/Link 359 B
frontend/dist-report/posthog-app/src/lib/monaco/CodeEditorInline 866 B
frontend/dist-report/posthog-app/src/lib/monaco/vimMode 211 kB
frontend/dist-report/posthog-app/src/lib/ui/Button/ButtonPrimitives 426 B
frontend/dist-report/posthog-app/src/queries/nodes/WebVitals/WebVitals 7.55 kB
frontend/dist-report/posthog-app/src/queries/nodes/WebVitals/WebVitalsPathBreakdown 4.12 kB
frontend/dist-report/posthog-app/src/queries/schema 856 kB
frontend/dist-report/posthog-app/src/scenes/activity/explore/EventsScene 3.32 kB
frontend/dist-report/posthog-app/src/scenes/activity/explore/SessionsScene 4.72 kB
frontend/dist-report/posthog-app/src/scenes/activity/live/LiveEventsTable 5.62 kB
frontend/dist-report/posthog-app/src/scenes/agentic/AgenticAuthorize 5.87 kB
frontend/dist-report/posthog-app/src/scenes/approvals/ApprovalDetail 16.6 kB
frontend/dist-report/posthog-app/src/scenes/approvals/changeRequestsLogic 918 B
frontend/dist-report/posthog-app/src/scenes/audit-logs/AdvancedActivityLogsScene 42.1 kB
frontend/dist-report/posthog-app/src/scenes/AuthenticatedShell 173 kB
frontend/dist-report/posthog-app/src/scenes/authentication/AccountConnected 3.36 kB
frontend/dist-report/posthog-app/src/scenes/authentication/AgenticAccountMismatch 2.77 kB
frontend/dist-report/posthog-app/src/scenes/authentication/CLIAuthorize 11.8 kB
frontend/dist-report/posthog-app/src/scenes/authentication/CLILive 4.4 kB
frontend/dist-report/posthog-app/src/scenes/authentication/credential-review/CredentialReview 3.98 kB
frontend/dist-report/posthog-app/src/scenes/authentication/EmailMFAVerify 3.4 kB
frontend/dist-report/posthog-app/src/scenes/authentication/InviteSignup 15.4 kB
frontend/dist-report/posthog-app/src/scenes/authentication/Login 10.2 kB
frontend/dist-report/posthog-app/src/scenes/authentication/Login2FA 5.11 kB
frontend/dist-report/posthog-app/src/scenes/authentication/passkeyLogic 858 B
frontend/dist-report/posthog-app/src/scenes/authentication/PasswordReset 4.74 kB
frontend/dist-report/posthog-app/src/scenes/authentication/PasswordResetComplete 3.38 kB
frontend/dist-report/posthog-app/src/scenes/authentication/signup/SignupContainer 28.6 kB
frontend/dist-report/posthog-app/src/scenes/authentication/signup/verify-email/VerifyEmail 5.16 kB
frontend/dist-report/posthog-app/src/scenes/authentication/TwoFactorReset 4.41 kB
frontend/dist-report/posthog-app/src/scenes/authentication/VercelConnect 5.37 kB
frontend/dist-report/posthog-app/src/scenes/authentication/VercelLinkError 2.64 kB
frontend/dist-report/posthog-app/src/scenes/billing/AuthorizationStatus 1.1 kB
frontend/dist-report/posthog-app/src/scenes/billing/Billing 867 B
frontend/dist-report/posthog-app/src/scenes/billing/BillingSection 21.2 kB
frontend/dist-report/posthog-app/src/scenes/cohorts/Cohort 28.4 kB
frontend/dist-report/posthog-app/src/scenes/cohorts/CohortCalculationHistory 6.61 kB
frontend/dist-report/posthog-app/src/scenes/cohorts/Cohorts 9.81 kB
frontend/dist-report/posthog-app/src/scenes/coupons/Coupons 1.1 kB
frontend/dist-report/posthog-app/src/scenes/dashboard/Dashboard 1.68 kB
frontend/dist-report/posthog-app/src/scenes/dashboard/dashboards/Dashboards 19.9 kB
frontend/dist-report/posthog-app/src/scenes/dashboard/dashboards/templates/DashboardTemplateCopyScene 6.09 kB
frontend/dist-report/posthog-app/src/scenes/data-management/DataManagementScene 1.02 kB
frontend/dist-report/posthog-app/src/scenes/data-management/definition/DefinitionEdit 17.3 kB
frontend/dist-report/posthog-app/src/scenes/data-management/definition/DefinitionView 24.4 kB
frontend/dist-report/posthog-app/src/scenes/data-management/MaterializedColumns/MaterializedColumns 12 kB
frontend/dist-report/posthog-app/src/scenes/data-management/variables/SqlVariableEditScene 7.63 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/batch-exports/BatchExportScene 61 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/DataPipelinesNewScene 2.72 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/DestinationsScene 3.1 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/event-filtering/EventFilterScene 22.3 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/legacy-plugins/LegacyPluginScene 21 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/TransformationsScene 2.34 kB
frontend/dist-report/posthog-app/src/scenes/data-pipelines/WebScriptsScene 2.96 kB
frontend/dist-report/posthog-app/src/scenes/data-warehouse/DataWarehouseScene 1.75 kB
frontend/dist-report/posthog-app/src/scenes/data-warehouse/editor/EditorScene 1.52 kB
frontend/dist-report/posthog-app/src/scenes/debug/DebugScene 20.3 kB
frontend/dist-report/posthog-app/src/scenes/debug/hog/HogRepl 7.75 kB
frontend/dist-report/posthog-app/src/scenes/experiments/Experiment 208 kB
frontend/dist-report/posthog-app/src/scenes/experiments/Experiments 20.9 kB
frontend/dist-report/posthog-app/src/scenes/experiments/SharedMetrics/SharedMetric 6.45 kB
frontend/dist-report/posthog-app/src/scenes/experiments/SharedMetrics/SharedMetrics 923 B
frontend/dist-report/posthog-app/src/scenes/exports/ExportsScene 4.45 kB
frontend/dist-report/posthog-app/src/scenes/feature-flags/FeatureFlag 144 kB
frontend/dist-report/posthog-app/src/scenes/feature-flags/FeatureFlags 1.12 kB
frontend/dist-report/posthog-app/src/scenes/groups/Group 15.6 kB
frontend/dist-report/posthog-app/src/scenes/groups/Groups 4.29 kB
frontend/dist-report/posthog-app/src/scenes/groups/GroupsNew 7.73 kB
frontend/dist-report/posthog-app/src/scenes/health-alerts/HealthAlertsScene 4.17 kB
frontend/dist-report/posthog-app/src/scenes/health/categoryDetail/HealthCategoryDetailScene 7.64 kB
frontend/dist-report/posthog-app/src/scenes/health/HealthScene 12.8 kB
frontend/dist-report/posthog-app/src/scenes/health/pipelineStatus/PipelineStatusScene 11.5 kB
frontend/dist-report/posthog-app/src/scenes/heatmaps/scenes/heatmap/HeatmapNewScene 5.41 kB
frontend/dist-report/posthog-app/src/scenes/heatmaps/scenes/heatmap/HeatmapRecordingScene 4.31 kB
frontend/dist-report/posthog-app/src/scenes/heatmaps/scenes/heatmap/HeatmapScene 6.94 kB
frontend/dist-report/posthog-app/src/scenes/heatmaps/scenes/heatmaps/HeatmapsScene 4.27 kB
frontend/dist-report/posthog-app/src/scenes/hog-functions/HogFunctionScene 55.3 kB
frontend/dist-report/posthog-app/src/scenes/inbox/InboxScene 63.4 kB
frontend/dist-report/posthog-app/src/scenes/insights/InsightQuickStart/InsightQuickStart 5.81 kB
frontend/dist-report/posthog-app/src/scenes/insights/InsightScene 34.8 kB
frontend/dist-report/posthog-app/src/scenes/insights/views/BoxPlot/BoxPlot 5.43 kB
frontend/dist-report/posthog-app/src/scenes/insights/views/CalendarHeatMap/CalendarHeatMap 4.87 kB
frontend/dist-report/posthog-app/src/scenes/insights/views/RegionMap/RegionMap 29.8 kB
frontend/dist-report/posthog-app/src/scenes/insights/views/WorldMap/WorldMap 5.16 kB
frontend/dist-report/posthog-app/src/scenes/instance/AsyncMigrations/AsyncMigrations 13.5 kB
frontend/dist-report/posthog-app/src/scenes/instance/DeadLetterQueue/DeadLetterQueue 5.77 kB
frontend/dist-report/posthog-app/src/scenes/instance/QueryPerformance/QueryPerformance 9 kB
frontend/dist-report/posthog-app/src/scenes/instance/SystemStatus/SystemStatus 17.4 kB
frontend/dist-report/posthog-app/src/scenes/IntegrationsRedirect/IntegrationsRedirect 1.11 kB
frontend/dist-report/posthog-app/src/scenes/marketing-analytics/MarketingAnalyticsScene 42.1 kB
frontend/dist-report/posthog-app/src/scenes/max/Max 1.06 kB
frontend/dist-report/posthog-app/src/scenes/models/ModelsScene 19.1 kB
frontend/dist-report/posthog-app/src/scenes/models/NodeDetailScene 17.1 kB
frontend/dist-report/posthog-app/src/scenes/moveToPostHogCloud/MoveToPostHogCloud 4.84 kB
frontend/dist-report/posthog-app/src/scenes/new-tab/NewTabScene 1.85 kB
frontend/dist-report/posthog-app/src/scenes/notebooks/NotebookCanvasScene 3.92 kB
frontend/dist-report/posthog-app/src/scenes/notebooks/NotebookPanel/NotebookPanel 5.98 kB
frontend/dist-report/posthog-app/src/scenes/notebooks/NotebookScene 9.29 kB
frontend/dist-report/posthog-app/src/scenes/notebooks/NotebooksScene 7.98 kB
frontend/dist-report/posthog-app/src/scenes/oauth/OAuthAuthorize 1.01 kB
frontend/dist-report/posthog-app/src/scenes/onboarding/coupon/OnboardingCouponRedemption 1.58 kB
frontend/dist-report/posthog-app/src/scenes/onboarding/Onboarding 792 kB
frontend/dist-report/posthog-app/src/scenes/onboarding/sdks/SdkDoctorScene 10.2 kB
frontend/dist-report/posthog-app/src/scenes/organization/ConfirmOrganization/ConfirmOrganization 4.91 kB
frontend/dist-report/posthog-app/src/scenes/organization/Create/Create 1.03 kB
frontend/dist-report/posthog-app/src/scenes/organization/Deactivated 1.51 kB
frontend/dist-report/posthog-app/src/scenes/organization/PendingDeletion 2.48 kB
frontend/dist-report/posthog-app/src/scenes/persons/PersonScene 20.3 kB
frontend/dist-report/posthog-app/src/scenes/persons/PersonsScene 6.12 kB
frontend/dist-report/posthog-app/src/scenes/PreflightCheck/PreflightCheck 5.95 kB
frontend/dist-report/posthog-app/src/scenes/product-tours/ProductTour 275 kB
frontend/dist-report/posthog-app/src/scenes/product-tours/ProductTours 5.06 kB
frontend/dist-report/posthog-app/src/scenes/project-homepage/ProjectHomepage 19.1 kB
frontend/dist-report/posthog-app/src/scenes/project/Create/Create 1.21 kB
frontend/dist-report/posthog-app/src/scenes/resource-transfer/ResourceTransfer 9.56 kB
frontend/dist-report/posthog-app/src/scenes/saved-insights/SavedInsights 1.04 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/detail/SessionRecordingDetail 2.14 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/file-playback/SessionRecordingFilePlaybackScene 4.85 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/kiosk/SessionRecordingsKiosk 10.3 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/player/snapshot-processing/DecompressionWorkerManager 329 B
frontend/dist-report/posthog-app/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistScene 5.49 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/SessionRecordings 1.15 kB
frontend/dist-report/posthog-app/src/scenes/session-recordings/settings/SessionRecordingsSettingsScene 2.35 kB
frontend/dist-report/posthog-app/src/scenes/sessions/SessionProfileScene 15.6 kB
frontend/dist-report/posthog-app/src/scenes/settings/SettingsScene 3.94 kB
frontend/dist-report/posthog-app/src/scenes/sites/Site 1.9 kB
frontend/dist-report/posthog-app/src/scenes/startups/StartupProgram 21.6 kB
frontend/dist-report/posthog-app/src/scenes/StripeConfirmInstall/StripeConfirmInstall 3.92 kB
frontend/dist-report/posthog-app/src/scenes/subscriptions/SubscriptionScene 14.4 kB
frontend/dist-report/posthog-app/src/scenes/subscriptions/SubscriptionsScene 5.23 kB
frontend/dist-report/posthog-app/src/scenes/surveys/forms/SurveyFormBuilder 1.93 kB
frontend/dist-report/posthog-app/src/scenes/surveys/Survey 1.39 kB
frontend/dist-report/posthog-app/src/scenes/surveys/Surveys 26.8 kB
frontend/dist-report/posthog-app/src/scenes/surveys/wizard/SurveyWizard 72.8 kB
frontend/dist-report/posthog-app/src/scenes/themes/CustomCssScene 3.94 kB
frontend/dist-report/posthog-app/src/scenes/toolbar-launch/ToolbarLaunch 2.85 kB
frontend/dist-report/posthog-app/src/scenes/Unsubscribe/Unsubscribe 2.04 kB
frontend/dist-report/posthog-app/src/scenes/web-analytics/SessionAttributionExplorer/SessionAttributionExplorerScene 7.01 kB
frontend/dist-report/posthog-app/src/scenes/web-analytics/WebAnalyticsScene 13.3 kB
frontend/dist-report/posthog-app/src/scenes/wizard/Wizard 4.83 kB
frontend/dist-report/posthog-app/src/sharedChunkAnchors 1.19 kB
frontend/dist-report/render-query/src/render-query/render-query 27.4 MB
frontend/dist-report/toolbar/src/toolbar/toolbar 15.7 MB

compressed-size-action

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 29, 2026

Comments Outside Diff (1)

  1. services/mcp/src/tools/exec.ts, line 162-188 (link)

    P2 Inconsistent response shape across search outcomes

    The search command returns three structurally different shapes: a plain array when normal matches are found with no gated tools, an object { matches, scope_gated_matches, hint } when gated matches are present, and an object { matches: [], hint } when nothing matches. The gated-present case is now a fourth variant of the second shape, but the core asymmetry (plain array vs. object) is a pre-existing design. An agent (or any code) that tries to access result.matches will get undefined when the response is a plain array and []/[...] otherwise — making the caller always have to detect the shape before reading the matches. This inconsistency was present before this PR (the no-match case already returned an object), but worth flagging as a future cleanup target if additional search-related fields are added.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: services/mcp/src/tools/exec.ts
    Line: 162-188
    
    Comment:
    **Inconsistent response shape across `search` outcomes**
    
    The `search` command returns three structurally different shapes: a plain array when normal matches are found with no gated tools, an object `{ matches, scope_gated_matches, hint }` when gated matches are present, and an object `{ matches: [], hint }` when nothing matches. The gated-present case is now a fourth variant of the second shape, but the core asymmetry (plain array vs. object) is a pre-existing design. An agent (or any code) that tries to access `result.matches` will get `undefined` when the response is a plain array and `[]`/`[...]` otherwise — making the caller always have to detect the shape before reading the matches. This inconsistency was present before this PR (the no-match case already returned an object), but worth flagging as a future cleanup target if additional search-related fields are added.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
services/mcp/src/tools/exec.ts:162-188
**Inconsistent response shape across `search` outcomes**

The `search` command returns three structurally different shapes: a plain array when normal matches are found with no gated tools, an object `{ matches, scope_gated_matches, hint }` when gated matches are present, and an object `{ matches: [], hint }` when nothing matches. The gated-present case is now a fourth variant of the second shape, but the core asymmetry (plain array vs. object) is a pre-existing design. An agent (or any code) that tries to access `result.matches` will get `undefined` when the response is a plain array and `[]`/`[...]` otherwise — making the caller always have to detect the shape before reading the matches. This inconsistency was present before this PR (the no-match case already returned an object), but worth flagging as a future cleanup target if additional search-related fields are added.

### Issue 2 of 2
services/mcp/src/mcp.ts:775-783
**`scopedTeams` not forwarded to `getScopeGatedTools` in the DO path**

`getScopeGatedTools` is called here without `scopedTeams`, but `getToolsForFeatures` uses `scopedTeams` to strip out tools that require `organization:*` scopes when a project-scoped API key is in use. In the hono path this is correct (`filterOptions` includes `scopedTeams`). In this DO path, if an API key has `scoped_teams` set and is also missing an `organization:*` scope, those org-level tools will appear in `scopeGatedTools` and the hint will tell the agent to "add org_admin scope" — but calling the tool would still fail at the backend because the token is project-scoped. The risk is partly mitigated by the DO path's `allTools` also omitting `scopedTeams`, so behavior is self-consistent within this path, but the misleading hint can still arise. `_apiKey?.scoped_teams` is available here and could be forwarded the same way it is in `request-state-resolver.ts`.

Reviews (1): Last reviewed commit: "fix(mcp): surface scope-gated tools in e..." | Re-trigger Greptile

Comment thread services/mcp/src/mcp.ts
Comment thread services/mcp/src/tools/exec.ts
@veria-ai
Copy link
Copy Markdown

veria-ai Bot commented May 29, 2026

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves MCP tool discoverability in single-exec mode by making the exec search command scope-aware, so tools that exist but are hidden due to missing API key scopes are surfaced with an actionable scope hint instead of being silently omitted.

Changes:

  • Add a getScopeGatedTools() helper to compute “feature-enabled but scope-filtered” tools and thread this through both MCP wiring paths.
  • Update exec search to return scope_gated_matches plus a hint listing missing scope(s) when relevant.
  • Update tool-search guidance and extend unit/hono tests + snapshots to cover the new behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/mcp/src/tools/toolDefinitions.ts Adds ScopeGatedTool + getScopeGatedTools() to compute tools filtered only by missing scopes.
services/mcp/src/tools/exec.ts Extends search output to include scope-gated matches and a missing-scope hint.
services/mcp/src/mcp.ts Computes and passes scopeGatedTools into createExecTool for the DO (mcp.ts) execution path.
services/mcp/src/hono/request-state-resolver.ts Adds scopeGatedTools to resolved request state and computes it alongside allTools.
services/mcp/src/hono/tool-executor.ts Passes state.scopeGatedTools into createExecTool for the Hono execution path.
services/mcp/src/templates/sections/tool-search.md Updates agent instructions to interpret scope_gated_matches as missing scopes (not missing tools).
services/mcp/tests/unit/exec.test.ts Adds unit coverage for search returning plain arrays vs scope-gated hint payloads.
services/mcp/tests/unit/snapshots/instructions/tools-instructions.txt Snapshot update reflecting the new scope_gated_matches guidance.
services/mcp/tests/unit/snapshots/instructions/exec-command-reference-full.txt Snapshot update reflecting the new scope_gated_matches guidance.
services/mcp/tests/unit/snapshots/exec-tool.json Snapshot update to exec tool command-reference text including the new guidance.
services/mcp/tests/hono/tool-executor.test.ts Updates test helper state to include scopeGatedTools.
services/mcp/tests/hono/tool-executor-metrics.test.ts Updates test helper state to include scopeGatedTools.
services/mcp/tests/hono/analytics.test.ts Updates test helper state to include scopeGatedTools.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/mcp/src/hono/request-state-resolver.ts
Rebased onto master. Surfaces scope-gated tools in the exec `search` command so an agent gets an actionable "add this scope" hint instead of concluding a tool is missing. Includes the review-feedback fixes: forward `scoped_teams` in the DO path, cap the search pattern length, and only compute scope-gated tools in single-exec mode.

Generated-By: PostHog Code
Task-Id: e8456582-7050-4ffb-9bae-d42084574eea
@Gilbert09 Gilbert09 force-pushed the tom/mcp-scope-gated-search branch from f7c9565 to f651279 Compare June 1, 2026 16:48
Copy link
Copy Markdown
Contributor

@skoob13 skoob13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This addresses the CLI mode (exec), but there is also the tools mode. I'm wondering if we should remove the scope filter and add a gate in the tool executor checking the scopes before calling an endpoint, so we can return a matching explanation prompt to agents.

Comment thread services/mcp/src/tools/exec.ts Outdated
Comment thread services/mcp/src/templates/sections/tool-search.md Outdated
Address review feedback: add OAuth re-authentication guidance to the
scope-gated search hint, and drop the redundant scope_gated_matches line
from the tool-search instructions (agents infer it from the hint). Update
affected instruction snapshots.

Generated-By: PostHog Code
Task-Id: f3013a13-4b55-479d-850c-e6cceda5314d
@Gilbert09 Gilbert09 merged commit e8c7e7f into master Jun 3, 2026
167 checks passed
@Gilbert09 Gilbert09 deleted the tom/mcp-scope-gated-search branch June 3, 2026 10:38
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented Jun 3, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-03 11:41 UTC Run
prod-us ✅ Deployed 2026-06-03 12:05 UTC Run
prod-eu ✅ Deployed 2026-06-03 12:09 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants