ref(tools): Merge search/list tool pairs into unified tools#877
Draft
ref(tools): Merge search/list tool pairs into unified tools#877
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Combines the 3 mutually exclusive search/list tool pairs into 3 unified tools:
search_issuesabsorbslist_issuessearch_eventsabsorbslist_eventssearch_issue_eventsabsorbslist_issue_eventsEach tool now accepts both direct Sentry query syntax (
query,sort, etc.) and optional natural language search (naturalLanguageQuery). WhennaturalLanguageQueryis 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_TOOLSmutual exclusivity system inserver.tsis removed. IfnaturalLanguageQueryis used without an agent provider, the handler throws a clearConfigurationErrordirecting users to thequeryparameter.Net tool count drops by 3.