Skip to content

ref(tools): Merge search/list tool pairs into unified tools#877

Draft
dcramer wants to merge 2 commits intomainfrom
dcramer/ref/merge-search-list-tools
Draft

ref(tools): Merge search/list tool pairs into unified tools#877
dcramer wants to merge 2 commits intomainfrom
dcramer/ref/merge-search-list-tools

Conversation

@dcramer
Copy link
Copy Markdown
Member

@dcramer dcramer commented Apr 3, 2026

Combines the 3 mutually exclusive search/list tool pairs into 3 unified tools:

  • search_issues absorbs list_issues
  • search_events absorbs list_events
  • search_issue_events absorbs list_issue_events

Each tool now accepts both direct Sentry query syntax (query, sort, etc.) and optional natural language search (naturalLanguageQuery). When naturalLanguageQuery is provided and an embedded agent provider is configured, the agent refines the intent into correct Sentry params. When omitted, the direct params are used as-is with no agent overhead.

Previously, every query was forced through the embedded agent when API keys were configured — even simple iteration like "go through these 10 issues and do X." This added unnecessary latency and cost. Now callers choose: use direct syntax for deterministic queries, or use NL for ambiguous intent that benefits from agent refinement.

The AGENT_DEPENDENT_TOOLS / SIMPLE_REPLACEMENT_TOOLS mutual exclusivity system in server.ts is removed. If naturalLanguageQuery is used without an agent provider, the handler throws a clear ConfigurationError directing users to the query parameter.

Net tool count drops by 3.

Combine search_issues+list_issues, search_events+list_events, and
search_issue_events+list_issue_events into single tools. Each tool now
accepts both direct Sentry query syntax (via query/sort params) and
optional natural language search (via naturalLanguageQuery param).

When naturalLanguageQuery is provided and an embedded agent provider is
configured, the agent refines the intent into correct Sentry params.
When omitted, the direct params are used as-is with no agent overhead.
This eliminates the mandatory agent round-trip for simple queries like
iterating through N issues.

Removes the AGENT_DEPENDENT_TOOLS/SIMPLE_REPLACEMENT_TOOLS mutual
exclusivity system from server.ts. The 3 list_* tools and their
directories are deleted. Tool count drops by 3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Missing env var teardown pollutes subsequent tests
    • Added proper save/restore for both OPENAI_API_KEY and ANTHROPIC_API_KEY in the finally blocks of all three test files, using delete for undefined values to properly unset environment variables.

Create PR

Or push these changes by commenting:

@cursor push 19c67815a0
Preview (19c67815a0)
diff --git a/packages/mcp-core/src/tools/search-events.test.ts b/packages/mcp-core/src/tools/search-events.test.ts
--- a/packages/mcp-core/src/tools/search-events.test.ts
+++ b/packages/mcp-core/src/tools/search-events.test.ts
@@ -703,7 +703,8 @@
   });
 
   it("should throw ConfigurationError when naturalLanguageQuery provided without agent", async () => {
-    const savedKey = process.env.OPENAI_API_KEY;
+    const savedOpenAIKey = process.env.OPENAI_API_KEY;
+    const savedAnthropicKey = process.env.ANTHROPIC_API_KEY;
     process.env.OPENAI_API_KEY = "";
     process.env.ANTHROPIC_API_KEY = "";
 
@@ -735,7 +736,18 @@
         ),
       ).rejects.toThrow(ConfigurationError);
     } finally {
-      process.env.OPENAI_API_KEY = savedKey;
+      if (savedOpenAIKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.OPENAI_API_KEY;
+      } else {
+        process.env.OPENAI_API_KEY = savedOpenAIKey;
+      }
+      if (savedAnthropicKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.ANTHROPIC_API_KEY;
+      } else {
+        process.env.ANTHROPIC_API_KEY = savedAnthropicKey;
+      }
     }
   });
 });

diff --git a/packages/mcp-core/src/tools/search-issue-events.test.ts b/packages/mcp-core/src/tools/search-issue-events.test.ts
--- a/packages/mcp-core/src/tools/search-issue-events.test.ts
+++ b/packages/mcp-core/src/tools/search-issue-events.test.ts
@@ -581,7 +581,8 @@
   });
 
   it("should throw ConfigurationError when naturalLanguageQuery provided without agent", async () => {
-    const savedKey = process.env.OPENAI_API_KEY;
+    const savedOpenAIKey = process.env.OPENAI_API_KEY;
+    const savedAnthropicKey = process.env.ANTHROPIC_API_KEY;
     process.env.OPENAI_API_KEY = "";
     process.env.ANTHROPIC_API_KEY = "";
 
@@ -604,7 +605,18 @@
         ),
       ).rejects.toThrow(ConfigurationError);
     } finally {
-      process.env.OPENAI_API_KEY = savedKey;
+      if (savedOpenAIKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.OPENAI_API_KEY;
+      } else {
+        process.env.OPENAI_API_KEY = savedOpenAIKey;
+      }
+      if (savedAnthropicKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.ANTHROPIC_API_KEY;
+      } else {
+        process.env.ANTHROPIC_API_KEY = savedAnthropicKey;
+      }
     }
   });
 });

diff --git a/packages/mcp-core/src/tools/search-issues.test.ts b/packages/mcp-core/src/tools/search-issues.test.ts
--- a/packages/mcp-core/src/tools/search-issues.test.ts
+++ b/packages/mcp-core/src/tools/search-issues.test.ts
@@ -169,7 +169,8 @@
   });
 
   it("should throw ConfigurationError when naturalLanguageQuery provided without agent", async () => {
-    const savedKey = process.env.OPENAI_API_KEY;
+    const savedOpenAIKey = process.env.OPENAI_API_KEY;
+    const savedAnthropicKey = process.env.ANTHROPIC_API_KEY;
     process.env.OPENAI_API_KEY = "";
     process.env.ANTHROPIC_API_KEY = "";
 
@@ -190,7 +191,18 @@
         ),
       ).rejects.toThrow(ConfigurationError);
     } finally {
-      process.env.OPENAI_API_KEY = savedKey;
+      if (savedOpenAIKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.OPENAI_API_KEY;
+      } else {
+        process.env.OPENAI_API_KEY = savedOpenAIKey;
+      }
+      if (savedAnthropicKey === undefined) {
+        // biome-ignore lint/performance/noDelete: Required to properly unset environment variable
+        delete process.env.ANTHROPIC_API_KEY;
+      } else {
+        process.env.ANTHROPIC_API_KEY = savedAnthropicKey;
+      }
     }
   });

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Save and restore both OPENAI_API_KEY and ANTHROPIC_API_KEY in the
ConfigurationError test teardown to prevent env var pollution across
test runs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dcramer dcramer deployed to Actions April 3, 2026 19:53 — with GitHub Actions Active
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.

1 participant