Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix: build the MCP review directive from the shared user prompt

Khuram Niazf12636c1bd02
diff --git a/__tests__/mcpReviewResume.spec.ts b/__tests__/mcpReviewResume.spec.ts
index 8b325a9..68bfdff 100644
--- a/__tests__/mcpReviewResume.spec.ts
+++ b/__tests__/mcpReviewResume.spec.ts
@@ -3,6 +3,7 @@ import { getDefaultResumeForUser } from "@/lib/jobs/getDefaultResumeForUser";
import { preprocessResume } from "@/lib/ai/tools/preprocessing";
import { checkMcpRateLimit } from "@/lib/mcp/rate-limit";
import { APP_CONSTANTS } from "@/lib/constants";
+import { buildResumeReviewPrompt } from "@/lib/ai/prompts/resume-review";
vi.mock("@/lib/jobs/getDefaultResumeForUser", () => ({
getDefaultResumeForUser: vi.fn(),
@@ -41,6 +42,26 @@ describe("handleReviewResume", () => {
"SCORES: overall=<0-100> impact=<0-100> clarity=<0-100> ats=<0-100>",
);
expect(text).toContain('"resumeId": "resume-1"');
+ // The serialization disclaimer lives only in buildResumeReviewPrompt.
+ // Without it an MCP review docks ATS points for the "##" markers the app
+ // itself inserted — the one gap MCP had that chat did not.
+ expect(text).toContain("artifacts of this serialization");
+ expect(text).toContain("<resume>");
+ expect(text).toContain("</resume>");
+ expect(text).not.toContain("DEFAULT RESUME (normalized):");
+ });
+
+ it("emits the shared user prompt verbatim, so the three surfaces cannot drift", async () => {
+ (getDefaultResumeForUser as any).mockResolvedValue({ id: "resume-1" });
+ (preprocessResume as any).mockResolvedValue({
+ success: true,
+ data: { normalizedText: longResumeText, metadata: {}, isValid: true },
+ });
+
+ const result = await handleReviewResume("user-1");
+ expect(result.content[0].text).toContain(
+ buildResumeReviewPrompt(longResumeText),
+ );
});
it("returns a note when no default resume is set", async () => {
diff --git a/src/lib/mcp/tools/reviewResume.ts b/src/lib/mcp/tools/reviewResume.ts
index 780af95..ff1d660 100644
--- a/src/lib/mcp/tools/reviewResume.ts
+++ b/src/lib/mcp/tools/reviewResume.ts
@@ -2,11 +2,15 @@ import { APP_CONSTANTS } from "@/lib/constants";
import { checkMcpRateLimit } from "@/lib/mcp/rate-limit";
import { getDefaultResumeForUser } from "@/lib/jobs/getDefaultResumeForUser";
import { preprocessResume } from "@/lib/ai/tools/preprocessing";
-import { RESUME_REVIEW_SYSTEM_PROMPT } from "@/lib/ai/prompts/resume-review";
+import {
+ RESUME_REVIEW_SYSTEM_PROMPT,
+ buildResumeReviewPrompt,
+} from "@/lib/ai/prompts/resume-review";
-// Do not restate the SCORES line format or the "##" section list here —
-// RESUME_REVIEW_SYSTEM_PROMPT already fully specifies both. Restating them
-// would create two sources that can drift.
+// Do not restate the SCORES line format, the "##" section list or the
+// serialization disclaimer here — the shared system prompt and user-prompt
+// builder specify all three. Restating any of them creates a second source
+// that can drift.
function buildReviewDirective(
resumeId: string,
normalizedResumeText: string,
@@ -14,8 +18,8 @@ function buildReviewDirective(
return (
`Act as the reviewer described below and produce a review of the ` +
`resume shown here.\n\n` +
- `DEFAULT RESUME (normalized):\n${normalizedResumeText}\n\n` +
`${RESUME_REVIEW_SYSTEM_PROMPT}\n\n` +
+ `${buildResumeReviewPrompt(normalizedResumeText)}\n\n` +
`Then call save_resume_review with the full SCORES line + markdown body ` +
`you just produced as the "reviewText" argument (not as a chat message):\n` +
` { "resumeId": "${resumeId}", "reviewText": "<the full SCORES line + markdown body>" }`