Skip to content

Commit d6f20a7

Browse files
Merge pull request #285 from manoj-k04/PMAA-100-disable-runpercyscan
fix(percy): disable runPercyScan
2 parents 19b3676 + e566787 commit d6f20a7

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

src/tools/percy-sdk.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { trackMCP } from "../index.js";
22
import { BrowserStackConfig } from "../lib/types.js";
33
import { fetchPercyChanges } from "./review-agent.js";
44
import { addListTestFiles } from "./list-test-files.js";
5-
import { runPercyScan } from "./run-percy-scan.js";
5+
// PMAA-100: runPercyScan tool temporarily disabled due to plaintext token leak in tool output.
6+
// import { runPercyScan } from "./run-percy-scan.js";
67
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
78
import { SetUpPercyParamsShape } from "./sdk-utils/common/schema.js";
89
import { updateTestsWithPercyCommands } from "./add-percy-snapshots.js";
@@ -21,7 +22,8 @@ import {
2122
import { UpdateTestFileWithInstructionsParams } from "./percy-snapshot-utils/constants.js";
2223

2324
import {
24-
RunPercyScanParamsShape,
25+
// PMAA-100: kept commented so the registration block below is easy to restore once the proper fix lands.
26+
// RunPercyScanParamsShape,
2527
FetchPercyChangesParamsShape,
2628
ManagePercyBuildApprovalParamsShape,
2729
} from "./sdk-utils/common/schema.js";
@@ -133,19 +135,22 @@ export function registerPercyTools(
133135
},
134136
);
135137

136-
tools.runPercyScan = server.tool(
137-
"runPercyScan",
138-
"Run a Percy visual test scan. Example prompts : Run this Percy build/scan. Never run percy scan/build without this tool",
139-
RunPercyScanParamsShape,
140-
async (args) => {
141-
try {
142-
trackMCP("runPercyScan", server.server.getClientVersion()!, config);
143-
return runPercyScan(args, config);
144-
} catch (error) {
145-
return handleMCPError("runPercyScan", server, config, error);
146-
}
147-
},
148-
);
138+
// PMAA-100: runPercyScan temporarily disabled — fetched Percy token was being
139+
// returned in plaintext within tool output (see HackerOne #3576387). Re-enable
140+
// once the token is replaced with a placeholder in run-percy-scan.ts.
141+
// tools.runPercyScan = server.tool(
142+
// "runPercyScan",
143+
// "Run a Percy visual test scan. Example prompts : Run this Percy build/scan. Never run percy scan/build without this tool",
144+
// RunPercyScanParamsShape,
145+
// async (args) => {
146+
// try {
147+
// trackMCP("runPercyScan", server.server.getClientVersion()!, config);
148+
// return runPercyScan(args, config);
149+
// } catch (error) {
150+
// return handleMCPError("runPercyScan", server, config, error);
151+
// }
152+
// },
153+
// );
149154

150155
tools.fetchPercyChanges = server.tool(
151156
"fetchPercyChanges",

tests/tools/percySdk.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
22
import { registerPercyTools } from "../../src/tools/percy-sdk";
33
import { setUpPercyHandler, simulatePercyChangeHandler } from "../../src/tools/sdk-utils/handler";
44
import { updateTestsWithPercyCommands } from "../../src/tools/add-percy-snapshots";
5-
import { runPercyScan } from "../../src/tools/run-percy-scan";
5+
// PMAA-100: runPercyScan registration disabled — restore import alongside the test.
6+
// import { runPercyScan } from "../../src/tools/run-percy-scan";
67
import { fetchPercyChanges } from "../../src/tools/review-agent";
78
import { approveOrDeclinePercyBuild } from "../../src/tools/review-agent-utils/percy-approve-reject";
89

@@ -13,9 +14,10 @@ vi.mock("../../src/tools/sdk-utils/handler", () => ({
1314
vi.mock("../../src/tools/add-percy-snapshots", () => ({
1415
updateTestsWithPercyCommands: vi.fn(),
1516
}));
16-
vi.mock("../../src/tools/run-percy-scan", () => ({
17-
runPercyScan: vi.fn(),
18-
}));
17+
// PMAA-100: runPercyScan registration disabled — restore mock alongside the test.
18+
// vi.mock("../../src/tools/run-percy-scan", () => ({
19+
// runPercyScan: vi.fn(),
20+
// }));
1921
vi.mock("../../src/tools/review-agent", () => ({
2022
fetchPercyChanges: vi.fn(),
2123
}));
@@ -64,7 +66,8 @@ describe("Percy SDK Tools", () => {
6466
expect(toolNames).toContain("expandPercyVisualTesting");
6567
expect(toolNames).toContain("addPercySnapshotCommands");
6668
expect(toolNames).toContain("listTestFiles");
67-
expect(toolNames).toContain("runPercyScan");
69+
// PMAA-100: runPercyScan registration disabled — restore once the token leak is fixed.
70+
// expect(toolNames).toContain("runPercyScan");
6871
expect(toolNames).toContain("fetchPercyChanges");
6972
expect(toolNames).toContain("managePercyBuildApproval");
7073
});
@@ -118,14 +121,15 @@ describe("Percy SDK Tools", () => {
118121
expect(result.content[0].text).toContain("Commands added");
119122
});
120123

121-
it("runPercyScan - SUCCESS", async () => {
122-
(runPercyScan as any).mockResolvedValue({
123-
content: [{ type: "text", text: "Percy scan started" }],
124-
});
125-
126-
const result = await handlers["runPercyScan"]({ projectName: "test" });
127-
expect(result.content[0].text).toContain("Percy scan");
128-
});
124+
// PMAA-100: runPercyScan registration disabled — restore once the token leak is fixed.
125+
// it("runPercyScan - SUCCESS", async () => {
126+
// (runPercyScan as any).mockResolvedValue({
127+
// content: [{ type: "text", text: "Percy scan started" }],
128+
// });
129+
//
130+
// const result = await handlers["runPercyScan"]({ projectName: "test" });
131+
// expect(result.content[0].text).toContain("Percy scan");
132+
// });
129133

130134
it("fetchPercyChanges - SUCCESS", async () => {
131135
(fetchPercyChanges as any).mockResolvedValue({

0 commit comments

Comments
 (0)