Skip to content

Commit 0c13801

Browse files
sentry-junior[bot]codexdcramer
committed
fix(tools): Preserve snapshot image URL fallback
Co-Authored-By: OpenAI Codex <codex@openai.com> Co-Authored-By: David Cramer <david@sentry.io>
1 parent 77ab0a6 commit 0c13801

4 files changed

Lines changed: 45 additions & 43 deletions

File tree

packages/mcp-core/src/tools/catalog/get-snapshot-image.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export default defineTool({
8686
params.imageIdentifier,
8787
params.imageResolution,
8888
{
89-
nextSteps: "snapshot-tools",
9089
experimentalMode: context.experimentalMode ?? false,
9190
availableToolNames: context.availableToolNames,
9291
directToolNames: context.directToolNames,

packages/mcp-core/src/tools/catalog/get-snapshot.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,28 @@ describe("get_snapshot", () => {
160160
expect(result).not.toContain("skipped.png");
161161
});
162162

163+
it("preserves the selectedSnapshot URL fallback when the image tool is unavailable", async () => {
164+
setupSnapshotMock();
165+
166+
const result = await getSnapshot.handler(
167+
{
168+
organizationSlug: "sentry",
169+
snapshotId: "231949",
170+
showUnmodified: false,
171+
regionUrl: null,
172+
},
173+
{
174+
...getServerContext(),
175+
availableToolNames: new Set(),
176+
directToolNames: new Set(),
177+
},
178+
);
179+
180+
expect(result).toContain(
181+
'get_sentry_resource(url="https://sentry.sentry.io/preprod/snapshots/231949/?selectedSnapshot=<image_file_name>")',
182+
);
183+
});
184+
163185
it("throws on missing explicit params", async () => {
164186
await expect(
165187
callHandler({

packages/mcp-core/src/tools/catalog/get-snapshot.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export default defineTool({
104104
{
105105
showUnmodified: params.showUnmodified,
106106
listImagesWhenNoDiffs: true,
107-
nextSteps: "snapshot-tools",
108107
experimentalMode: context.experimentalMode ?? false,
109108
availableToolNames: context.availableToolNames,
110109
directToolNames: context.directToolNames,

packages/mcp-core/src/tools/support/snapshots/handlers.ts

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ function fullResolutionHint({
9090
})}`;
9191
}
9292

93-
function getSnapshotImagePreviewFallback(): string {
94-
return "Use the Sentry tool `get_sentry_resource`";
93+
function getSnapshotImagePreviewFallback(snapshotUrl: string): string {
94+
const separator = snapshotUrl.includes("?") ? "&" : "?";
95+
return `Use the Sentry tool \`get_sentry_resource(url="${snapshotUrl}${separator}selectedSnapshot=<image_file_name>")\``;
9596
}
9697

9798
function formatSnapshotImageFullResolutionStep({
@@ -212,7 +213,6 @@ export async function fetchSnapshotImage(
212213
imageIdentifier: string,
213214
imageResolution: SnapshotImageResolution,
214215
options: {
215-
nextSteps?: "snapshot-tools" | "resource-url";
216216
experimentalMode?: boolean;
217217
availableToolNames?: ReadonlySet<string>;
218218
directToolNames?: ReadonlySet<string>;
@@ -337,7 +337,6 @@ export async function fetchSnapshotSummary(
337337
options: {
338338
showUnmodified?: boolean;
339339
listImagesWhenNoDiffs?: boolean;
340-
nextSteps?: "snapshot-tools" | "resource-url";
341340
experimentalMode?: boolean;
342341
availableToolNames?: ReadonlySet<string>;
343342
directToolNames?: ReadonlySet<string>;
@@ -494,46 +493,29 @@ export async function fetchSnapshotSummary(
494493
}
495494
}
496495

497-
if (options.nextSteps === "resource-url") {
498-
const separator = resolvedSnapshotUrl.includes("?") ? "&" : "?";
499-
const selectedImageUrl = `${resolvedSnapshotUrl}${separator}selectedSnapshot=<image_file_name>`;
500-
sections.push(
501-
`\n## Next Steps\n\n- To view a specific image preview, use \`get_sentry_resource(url="${selectedImageUrl}")\`\n${formatSnapshotImageFullResolutionStep(
502-
{
503-
organizationSlug,
504-
snapshotId,
505-
imageIdentifier: "<image_file_name>",
506-
experimentalMode: options.experimentalMode ?? false,
507-
availableToolNames: options.availableToolNames,
508-
directToolNames: options.directToolNames,
509-
},
510-
)}`,
511-
);
512-
} else {
513-
sections.push(
514-
`\n## Next Steps\n\n- ${formatToolCallInstruction({
515-
toolName: "get_snapshot_image",
516-
arguments: {
517-
organizationSlug,
518-
snapshotId,
519-
imageIdentifier: "<image_file_name>",
520-
},
496+
sections.push(
497+
`\n## Next Steps\n\n- ${formatToolCallInstruction({
498+
toolName: "get_snapshot_image",
499+
arguments: {
500+
organizationSlug,
501+
snapshotId,
502+
imageIdentifier: "<image_file_name>",
503+
},
504+
experimentalMode: options.experimentalMode ?? false,
505+
availableToolNames: options.availableToolNames,
506+
directToolNames: options.directToolNames,
507+
fallbackInstruction: getSnapshotImagePreviewFallback(resolvedSnapshotUrl),
508+
})} to view a specific image preview\n${formatSnapshotImageFullResolutionStep(
509+
{
510+
organizationSlug,
511+
snapshotId,
512+
imageIdentifier: "<image_file_name>",
521513
experimentalMode: options.experimentalMode ?? false,
522514
availableToolNames: options.availableToolNames,
523515
directToolNames: options.directToolNames,
524-
fallbackInstruction: getSnapshotImagePreviewFallback(),
525-
})} to view a specific image preview\n${formatSnapshotImageFullResolutionStep(
526-
{
527-
organizationSlug,
528-
snapshotId,
529-
imageIdentifier: "<image_file_name>",
530-
experimentalMode: options.experimentalMode ?? false,
531-
availableToolNames: options.availableToolNames,
532-
directToolNames: options.directToolNames,
533-
},
534-
)}`,
535-
);
536-
}
516+
},
517+
)}`,
518+
);
537519

538520
return sections.join("\n");
539521
}

0 commit comments

Comments
 (0)