diff --git a/ast-grep-rule-tests/no-expand-top-level-tools-test.yml b/ast-grep-rule-tests/no-expand-top-level-tools-test.yml new file mode 100644 index 000000000..ae175cb89 --- /dev/null +++ b/ast-grep-rule-tests/no-expand-top-level-tools-test.yml @@ -0,0 +1,55 @@ +id: no-expand-top-level-tools +valid: + - | + export const TOP_LEVEL_TOOL_NAMES = [ + "find_organizations", + "find_projects", + "update_issue", + "search_errors", + "search_logs", + "search_traces", + "search_metrics", + "search_profiles", + "search_replays", + "analyze_issue_with_seer", + "search_issues", + "get_sentry_resource", + ...CATALOG_INFRASTRUCTURE_TOOL_NAMES, + ] as const; + - | + export const EXPERIMENTAL_TOP_LEVEL_TOOL_NAMES = TOP_LEVEL_TOOL_NAMES; +invalid: + - | + export const TOP_LEVEL_TOOL_NAMES = [ + "find_organizations", + "find_projects", + "update_issue", + "search_errors", + "search_logs", + "search_traces", + "search_metrics", + "search_profiles", + "search_replays", + "find_dropped_events", + "analyze_issue_with_seer", + "search_issues", + "get_sentry_resource", + ...CATALOG_INFRASTRUCTURE_TOOL_NAMES, + ] as const; + - | + export const TOP_LEVEL_TOOL_NAMES = [ + "find_organizations", + "find_projects", + "update_issue", + "search_errors", + "search_logs", + "search_traces", + "search_metrics", + "search_profiles", + "search_replays", + "analyze_issue_with_seer", + "search_issues", + "get_sentry_resource", + ...CATALOG_INFRASTRUCTURE_TOOL_NAMES, + ...EXTRA_TOOL_NAMES, + ] as const; diff --git a/ast-grep-rules/no-expand-top-level-tools.yml b/ast-grep-rules/no-expand-top-level-tools.yml new file mode 100644 index 000000000..565399dac --- /dev/null +++ b/ast-grep-rules/no-expand-top-level-tools.yml @@ -0,0 +1,39 @@ +id: no-expand-top-level-tools +language: TypeScript +severity: error +message: Do not change the default top-level MCP tool list. +note: | + Every tool in TOP_LEVEL_TOOL_NAMES ships in the default tools/list payload. + Many harnesses still load every listed tool definition into the context + window up front, so each addition is noise for every session. Keep new tools + deferred: they stay reachable through search_sentry_tools and + execute_sentry_tool. Restricted until tool search is standard in every + mainstream harness, which likely happens by 2027. If the list truly must + change, update the allowed list in this rule in the same PR so the change is + reviewed explicitly. +rule: + kind: lexical_declaration + has: + kind: variable_declarator + has: + field: name + regex: ^TOP_LEVEL_TOOL_NAMES$ + not: + pattern: | + const TOP_LEVEL_TOOL_NAMES = [ + "find_organizations", + "find_projects", + "update_issue", + "search_errors", + "search_logs", + "search_traces", + "search_metrics", + "search_profiles", + "search_replays", + "analyze_issue_with_seer", + "search_issues", + "get_sentry_resource", + ...CATALOG_INFRASTRUCTURE_TOOL_NAMES + ] as const +files: + - packages/mcp-core/src/tools/surfaces.ts diff --git a/packages/mcp-core/src/server.test.ts b/packages/mcp-core/src/server.test.ts index 3b685213a..d0a99a772 100644 --- a/packages/mcp-core/src/server.test.ts +++ b/packages/mcp-core/src/server.test.ts @@ -119,7 +119,6 @@ async function callRegisteredTool( const DEFAULT_DIRECT_TOOL_NAMES = [ "analyze_issue_with_seer", "execute_sentry_tool", - "find_dropped_events", "find_organizations", "find_projects", "get_sentry_resource", diff --git a/packages/mcp-core/src/toolDefinitions.json b/packages/mcp-core/src/toolDefinitions.json index 14cdea45f..3165f01c0 100644 --- a/packages/mcp-core/src/toolDefinitions.json +++ b/packages/mcp-core/src/toolDefinitions.json @@ -2187,7 +2187,7 @@ }, "requiredScopes": ["event:read"], "skills": ["inspect"], - "surface": "direct" + "surface": "catalog" }, { "name": "find_dsns", diff --git a/packages/mcp-core/src/tools/surfaces.ts b/packages/mcp-core/src/tools/surfaces.ts index b5f6d89e6..755f60ea6 100644 --- a/packages/mcp-core/src/tools/surfaces.ts +++ b/packages/mcp-core/src/tools/surfaces.ts @@ -14,6 +14,11 @@ export const CATALOG_INFRASTRUCTURE_TOOL_NAMES = [ export const WRAPPER_TOOL_NAMES = [] as const; +// Locked by ast-grep-rules/no-expand-top-level-tools.yml. Every name here ships +// in the default tools/list payload, and many harnesses still load every listed +// tool into the context window up front. New tools stay deferred behind +// search_sentry_tools/execute_sentry_tool. Restricted until tool search is +// standard in every mainstream harness, which likely happens by 2027. export const TOP_LEVEL_TOOL_NAMES = [ "find_organizations", "find_projects", @@ -24,7 +29,6 @@ export const TOP_LEVEL_TOOL_NAMES = [ "search_metrics", "search_profiles", "search_replays", - "find_dropped_events", "analyze_issue_with_seer", "search_issues", "get_sentry_resource", diff --git a/plugins/sentry-mcp-experimental/agents/sentry-mcp.md b/plugins/sentry-mcp-experimental/agents/sentry-mcp.md index eebfb87b7..37705a4f0 100644 --- a/plugins/sentry-mcp-experimental/agents/sentry-mcp.md +++ b/plugins/sentry-mcp-experimental/agents/sentry-mcp.md @@ -12,7 +12,6 @@ mcpServers: allowedTools: - analyze_issue_with_seer - execute_sentry_tool - - find_dropped_events - find_organizations - find_projects - get_sentry_resource diff --git a/plugins/sentry-mcp/agents/sentry-mcp.md b/plugins/sentry-mcp/agents/sentry-mcp.md index eebfb87b7..37705a4f0 100644 --- a/plugins/sentry-mcp/agents/sentry-mcp.md +++ b/plugins/sentry-mcp/agents/sentry-mcp.md @@ -12,7 +12,6 @@ mcpServers: allowedTools: - analyze_issue_with_seer - execute_sentry_tool - - find_dropped_events - find_organizations - find_projects - get_sentry_resource