Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/mcp-core/src/api-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ export class SentryApiService {
* @param params.organizationSlug Organization identifier
* @param params.projectSlug Project identifier (optional, scopes to specific project)
* @param params.query Sentry search query (e.g., "is:unresolved browser:chrome")
* @param params.sortBy Sort order ("user", "freq", "date", "new")
* @param params.sortBy Sort order ("user", "freq", "date", "new", "recommended")
* @param opts Request options
* @returns Array of issues with metadata and statistics
*
Expand Down Expand Up @@ -2826,7 +2826,7 @@ export class SentryApiService {
organizationSlug: string;
projectSlug?: string;
query?: string | null;
sortBy?: "user" | "freq" | "date" | "new";
sortBy?: "user" | "freq" | "date" | "new" | "recommended";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P2: recommended will not use the feature-flagged v2 scorer when projectSlug is present. listIssues() switches to the deprecated project issues endpoint below, but Sentry's recommendedrecommended_v2 mapping exists only in OrganizationGroupIndexEndpoint; ProjectGroupIndexEndpoint calls prep_search() directly. This makes the same sort behave differently for project-scoped requests. Could we use the organization issues endpoint for project-scoped searches too and pass a project filter/ID?

limit?: number;
},
opts?: RequestOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("OpenAI Provider Integration", () => {
// sort can be null or one of the valid values
expect(
result.sort === null ||
["date", "freq", "new", "user"].includes(result.sort),
["date", "freq", "new", "user", "recommended"].includes(result.sort),
).toBe(true);
},
);
Expand All @@ -121,7 +121,7 @@ describe("OpenAI Provider Integration", () => {
// sort being null is valid and tests the nullable field handling
expect(
result.sort === null ||
["date", "freq", "new", "user"].includes(result.sort),
["date", "freq", "new", "user", "recommended"].includes(result.sort),
).toBe(true);
},
);
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-core/src/toolDefinitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2044,9 +2044,9 @@
},
"sort": {
"type": "string",
"enum": ["date", "freq", "new", "user"],
"enum": ["date", "freq", "new", "user", "recommended"],
"default": "date",
"description": "Sort order: date (last seen), freq (frequency), new (first seen), user (user count)"
"description": "Sort order: date (last seen), freq (frequency), new (first seen), user (user count), recommended (Sentry's prioritized ranking)"
},
"projectSlugOrId": {
"anyOf": [
Expand Down
11 changes: 4 additions & 7 deletions packages/mcp-core/src/tools/catalog/search-issues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("search_issues", () => {
// Helper to create AI agent response
const mockAIResponse = (
query = "",
sort: "date" | "freq" | "new" | "user" | null = "date",
sort: "date" | "freq" | "new" | "user" | "recommended" | null = "date",
errorMessage?: string,
) => {
const output = errorMessage
Expand Down Expand Up @@ -527,12 +527,9 @@ describe("search_issues", () => {
});

it("should handle all sort options", async () => {
const sortOptions: Array<"date" | "freq" | "new" | "user"> = [
"date",
"freq",
"new",
"user",
];
const sortOptions: Array<
"date" | "freq" | "new" | "user" | "recommended"
> = ["date", "freq", "new", "user", "recommended"];

for (const sortOption of sortOptions) {
mockGenerateText.mockResolvedValue(mockAIResponse("", sortOption));
Expand Down
8 changes: 4 additions & 4 deletions packages/mcp-core/src/tools/catalog/search-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

function buildIssueSearchRepairPrompt(params: {
query: string;
sort: "date" | "freq" | "new" | "user";
sort: "date" | "freq" | "new" | "user" | "recommended";
}): string {
return [
"Fix this Sentry issue search request.",
Expand Down Expand Up @@ -77,10 +77,10 @@ export default defineTool({
.default("is:unresolved")
.describe("Natural language or Sentry issue search query syntax."),
sort: z
.enum(["date", "freq", "new", "user"])
.enum(["date", "freq", "new", "user", "recommended"])
.default("date")
.describe(
"Sort order: date (last seen), freq (frequency), new (first seen), user (user count)",
"Sort order: date (last seen), freq (frequency), new (first seen), user (user count), recommended (Sentry's prioritized ranking)",
),
projectSlugOrId: z
.string()
Expand Down Expand Up @@ -123,7 +123,7 @@ export default defineTool({
}

let query: string;
let sort: "date" | "freq" | "new" | "user";
let sort: "date" | "freq" | "new" | "user" | "recommended";
let explanation: string | undefined;

if (hasAgentProvider()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The AI agent has access to these shared agent tools from `../../agent-tools/`:
- ✅ Error feedback loop for self-correction
- ✅ 'Me' reference resolution via whoami tool
- ✅ Field discovery with custom tags
- ✅ Smart sort options (date, freq, new, user)
- ✅ Smart sort options (date, freq, new, user, recommended)
- ✅ Configurable result limits (1-100, default 10)
- ✅ Project-specific and organization-wide searches

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-core/src/tools/support/search-issues/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { systemPrompt } from "./config";
export const searchIssuesAgentOutputSchema = z.object({
query: z.string().describe("The Sentry issue search query"),
sort: z
.enum(["date", "freq", "new", "user"])
.enum(["date", "freq", "new", "user", "recommended"])
.nullable()
.describe("How to sort the results"),
explanation: z
Expand Down
2 changes: 2 additions & 0 deletions packages/mcp-core/src/tools/support/search-issues/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ SORTING RULES:
- freq: Event frequency
- new: First seen
- user: User count
- recommended: Sentry's prioritized ranking
- If the user asks to sort/rank by users or impact, set sort to user.
- If the user asks for most frequent/noisy issues, set sort to freq.
- If the user asks for what to look at/prioritize/triage first, set sort to recommended.
- Never put sort syntax inside query.

ME REFERENCES:
Expand Down
Loading