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-cloudflare/src/test-utils/fetch-mock-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ export function registerFetchMockInterceptors(fetchMock: FetchMockLike) {
// ===== Autofix =====
pool
.intercept({
path: "/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-41/autofix/",
path: "/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-41/autofix/?mode=explorer",
})
.reply(200, { autofix: null }, { headers: JSON_HEADERS })
.persist();

pool
.intercept({
path: "/api/0/organizations/sentry-mcp-evals/issues/PEATED-A8/autofix/",
path: "/api/0/organizations/sentry-mcp-evals/issues/PEATED-A8/autofix/?mode=explorer",
})
.reply(200, autofixStateFixture, { headers: JSON_HEADERS })
.persist();
Expand Down
62 changes: 6 additions & 56 deletions packages/mcp-core/src/api-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import {
TagListSchema,
ApiErrorSchema,
ClientKeyListSchema,
type AutofixExplorerStepSchema,
AutofixExplorerRunStateSchema,
type AutofixStepSchema,
AutofixRunSchema,
AutofixRunStateSchema,
TraceMetaSchema,
Expand All @@ -61,7 +60,6 @@ import { createApiError, ApiNotFoundError, ApiValidationError } from "./errors";
import { USER_AGENT } from "../version";
import type { SentryProtocol } from "../types";
import type {
AutofixExplorerRunState,
AutofixRun,
AutofixRunState,
ClientKey,
Expand Down Expand Up @@ -2569,60 +2567,12 @@ export class SentryApiService {
return await this.requestJSON(apiUrl, undefined, opts);
}

// POST https://us.sentry.io/api/0/issues/5485083130/autofix/
async startAutofix(
{
organizationSlug,
issueId,
eventId,
instruction = "",
}: {
organizationSlug: string;
issueId: string;
eventId?: string;
instruction?: string;
},
opts?: RequestOptions,
): Promise<AutofixRun> {
const body = await this.requestJSON(
`/organizations/${organizationSlug}/issues/${issueId}/autofix/`,
{
method: "POST",
body: JSON.stringify({
event_id: eventId,
instruction,
}),
},
opts,
);
return AutofixRunSchema.parse(body);
}

// GET https://us.sentry.io/api/0/issues/5485083130/autofix/
async getAutofixState(
{
organizationSlug,
issueId,
}: {
organizationSlug: string;
issueId: string;
},
opts?: RequestOptions,
): Promise<AutofixRunState> {
const body = await this.requestJSON(
`/organizations/${organizationSlug}/issues/${issueId}/autofix/`,
undefined,
opts,
);
return AutofixRunStateSchema.parse(body);
}

// POST https://us.sentry.io/api/0/issues/5485083130/autofix/?mode=explorer
//
// Explorer mode advances the run one logical step at a time. A new run is
// created when `runId` is omitted (allowed only for `step: "root_cause"`);
// later steps must reuse the original run via `runId`.
async startAutofixExplorer(
async startAutofix(
{
organizationSlug,
issueId,
Expand All @@ -2633,7 +2583,7 @@ export class SentryApiService {
}: {
organizationSlug: string;
issueId: string;
step: z.infer<typeof AutofixExplorerStepSchema>;
step: z.infer<typeof AutofixStepSchema>;
runId?: number;
userContext?: string;
insertIndex?: number;
Expand Down Expand Up @@ -2662,7 +2612,7 @@ export class SentryApiService {
}

// GET https://us.sentry.io/api/0/issues/5485083130/autofix/?mode=explorer
async getAutofixExplorerState(
async getAutofixState(
{
organizationSlug,
issueId,
Expand All @@ -2671,13 +2621,13 @@ export class SentryApiService {
issueId: string;
},
opts?: RequestOptions,
): Promise<AutofixExplorerRunState> {
): Promise<AutofixRunState> {
const body = await this.requestJSON(
`/organizations/${organizationSlug}/issues/${issueId}/autofix/?mode=explorer`,
undefined,
opts,
);
return AutofixExplorerRunStateSchema.parse(body);
return AutofixRunStateSchema.parse(body);
}

/**
Expand Down
10 changes: 4 additions & 6 deletions packages/mcp-core/src/api-client/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from "@sentry/mcp-server-mocks";
import { describe, expect, it } from "vitest";
import {
AutofixExplorerRunStateSchema,
AutofixRunSchema,
AutofixRunStateSchema,
ClientKeySchema,
EventSchema,
FlamegraphSchema,
Expand Down Expand Up @@ -614,11 +614,9 @@ describe("AutofixRunSchema", () => {
});
});

describe("AutofixExplorerRunStateSchema", () => {
describe("AutofixRunStateSchema", () => {
it("parses the explorer fixture with typed blocks and artifacts", () => {
const state = AutofixExplorerRunStateSchema.parse(
autofixStateExplorerFixture,
);
const state = AutofixRunStateSchema.parse(autofixStateExplorerFixture);

expect(state.autofix?.status).toBe("completed");
expect(state.autofix?.run_id).toBe(21831);
Expand All @@ -631,7 +629,7 @@ describe("AutofixExplorerRunStateSchema", () => {
});

it("defaults missing blocks arrays to []", () => {
const state = AutofixExplorerRunStateSchema.parse({
const state = AutofixRunStateSchema.parse({
autofix: {
run_id: 1,
status: "processing",
Expand Down
Loading
Loading