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.

feat(evals): add MCP tool-routing regression tests

Khuram Niaz4256ea8f0b45
diff --git a/.gitignore b/.gitignore
index 07ad816..9af545c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,6 @@ CLAUDE.md
.vscode
AGENTS.md
.promptfoo/
+
+# Generated by evals/mcp-tools/generate-tools.ts
+evals/mcp-tools/tools.json
diff --git a/evals/mcp-tools/assertions.ts b/evals/mcp-tools/assertions.ts
new file mode 100644
index 0000000..856f609
--- /dev/null
+++ b/evals/mcp-tools/assertions.ts
@@ -0,0 +1,180 @@
+type AssertionResult = { pass: boolean; score: number; reason: string };
+type ToolCall = { name: string; args: Record<string, any> };
+type Context = { vars: Record<string, string> };
+
+// Shape of `output` varies: a bare tool_calls array, the whole assistant
+// message (reasoning models emit content AND tool_calls together), or either
+// of those stringified depending on caching. Normalize all of them, and treat
+// a genuine text-only reply as [] so assertions fail with a readable reason.
+function parseToolCalls(output: unknown): ToolCall[] {
+ let raw: any = output;
+ if (typeof raw === 'string') {
+ try {
+ raw = JSON.parse(raw);
+ } catch {
+ return [];
+ }
+ }
+ if (!raw) return [];
+ if (!Array.isArray(raw) && Array.isArray(raw.tool_calls)) {
+ raw = raw.tool_calls;
+ }
+ const list = Array.isArray(raw) ? raw : [raw];
+ return list
+ .map((c: any) => {
+ const fn = c?.function ?? c;
+ if (!fn?.name) return null;
+ let args: Record<string, any> = {};
+ if (typeof fn.arguments === 'string') {
+ try {
+ args = JSON.parse(fn.arguments);
+ } catch {
+ args = {};
+ }
+ } else if (fn.arguments && typeof fn.arguments === 'object') {
+ args = fn.arguments;
+ }
+ return { name: fn.name, args };
+ })
+ .filter(Boolean) as ToolCall[];
+}
+
+function describe(calls: ToolCall[]): string {
+ return calls.length ? calls.map((c) => c.name).join(' + ') : 'no tool call (model replied with text)';
+}
+
+function expectSingle(output: unknown, expected: string): AssertionResult & { calls: ToolCall[] } {
+ const calls = parseToolCalls(output);
+ if (calls.length !== 1) {
+ return {
+ pass: false,
+ score: 0,
+ reason: `Expected exactly 1 call to ${expected}, got ${calls.length}: ${describe(calls)}`,
+ calls,
+ };
+ }
+ if (calls[0].name !== expected) {
+ return {
+ pass: false,
+ score: 0,
+ reason: `Expected ${expected}, got ${calls[0].name}`,
+ calls,
+ };
+ }
+ return { pass: true, score: 1, reason: `Routed to ${expected}`, calls };
+}
+
+function expectNone(output: unknown, forbidden: string[]): AssertionResult {
+ const calls = parseToolCalls(output);
+ const hit = calls.find((c) => forbidden.includes(c.name));
+ return hit
+ ? { pass: false, score: 0, reason: `Called forbidden tool ${hit.name}; expected one of the alternatives` }
+ : { pass: true, score: 1, reason: `Avoided ${forbidden.join('/')} (called: ${describe(calls)})` };
+}
+
+function expectAnyOf(output: unknown, allowed: string[]): AssertionResult {
+ const calls = parseToolCalls(output);
+ const hit = calls.find((c) => allowed.includes(c.name));
+ return hit
+ ? { pass: true, score: 1, reason: `Routed to ${hit.name}` }
+ : { pass: false, score: 0, reason: `Expected one of ${allowed.join('/')}, got ${describe(calls)}` };
+}
+
+// Single posting -> add_job, not the batch tool and not N sequential calls.
+export function assertRoutesToAddJob(output: unknown): AssertionResult {
+ const { pass, score, reason } = expectSingle(output, 'add_job');
+ return { pass, score, reason };
+}
+
+// The description says "copied in full — do not summarize". Guard against the
+// model helpfully condensing the posting before saving it, which is what
+// downgrades a job to `partial` completeness and suppresses the match offer.
+export function assertDescriptionNotSummarized(
+ output: unknown,
+ context: Context,
+): AssertionResult {
+ const calls = parseToolCalls(output);
+ const source = context?.vars?.jobPosting ?? '';
+ const sent = calls
+ .flatMap((c) => (c.name === 'add_jobs_batch' ? (c.args.jobs ?? []) : [c.args]))
+ .map((a: any) => String(a?.jobDescription ?? ''))
+ .join('\n');
+ if (!sent) {
+ return { pass: false, score: 0, reason: 'No jobDescription was sent at all' };
+ }
+ const ratio = sent.length / Math.max(source.length, 1);
+ return ratio >= 0.6
+ ? { pass: true, score: 1, reason: `jobDescription kept ${(ratio * 100).toFixed(0)}% of source length` }
+ : {
+ pass: false,
+ score: 0,
+ reason: `jobDescription looks summarized: ${sent.length} chars vs ${source.length} in source (${(ratio * 100).toFixed(0)}%)`,
+ };
+}
+
+// Several postings in one message -> one add_jobs_batch, not N add_job calls.
+export function assertRoutesToAddJobsBatch(output: unknown): AssertionResult {
+ const result = expectSingle(output, 'add_jobs_batch');
+ if (!result.pass) return { pass: false, score: 0, reason: result.reason };
+ const jobs = result.calls[0].args.jobs;
+ if (!Array.isArray(jobs) || jobs.length !== 3) {
+ return {
+ pass: false,
+ score: 0,
+ reason: `Expected jobs[] of length 3, got ${Array.isArray(jobs) ? jobs.length : typeof jobs}`,
+ };
+ }
+ return { pass: true, score: 1, reason: 'Routed to add_jobs_batch with 3 items' };
+}
+
+// Editing a tracked job must never go through the create path.
+export function assertRoutesToUpdatePath(output: unknown): AssertionResult {
+ const forbidden = expectNone(output, ['add_job', 'add_jobs_batch']);
+ if (!forbidden.pass) return forbidden;
+ return expectAnyOf(output, ['update_job', 'find_job']);
+}
+
+// Re-running a saved search: either check first with find_job, or add with
+// upsert:true. Blindly calling add_job with neither is the regression.
+export function assertDedupeAware(output: unknown): AssertionResult {
+ const calls = parseToolCalls(output);
+ if (calls.some((c) => c.name === 'find_job')) {
+ return { pass: true, score: 1, reason: 'Checked with find_job first' };
+ }
+ const add = calls.find((c) => c.name === 'add_job' || c.name === 'add_jobs_batch');
+ if (!add) {
+ return { pass: false, score: 0, reason: `Expected find_job or an add with upsert, got ${describe(calls)}` };
+ }
+ const items = add.name === 'add_jobs_batch' ? (add.args.jobs ?? []) : [add.args];
+ const allUpsert = items.length > 0 && items.every((i: any) => i?.upsert === true);
+ return allUpsert
+ ? { pass: true, score: 1, reason: `${add.name} called with upsert:true` }
+ : { pass: false, score: 0, reason: `${add.name} called without upsert:true and without a find_job check` };
+}
+
+// The two-call flow: after add_job returns a match directive, the agent must
+// keep going rather than stopping at the confirmation text. review_resume
+// counts — the directive asks for a comparison against the default resume and
+// that is the only tool exposing it, so fetching it first is correct, not a
+// misroute. Re-adding the job, or replying with prose, is the regression.
+export function assertFollowsMatchDirective(output: unknown): AssertionResult {
+ const forbidden = expectNone(output, ['add_job', 'add_jobs_batch']);
+ if (!forbidden.pass) return forbidden;
+ return expectAnyOf(output, ['save_match_result', 'save_match_results_batch', 'review_resume']);
+}
+
+// A title-only posting carries no basis for a score; the directive withholds
+// the offer, and the agent must not invent one anyway.
+export function assertNoFabricatedMatch(output: unknown): AssertionResult {
+ return expectNone(output, ['save_match_result', 'save_match_results_batch']);
+}
+
+export function assertRoutesToAddQuestion(output: unknown): AssertionResult {
+ const { pass, score, reason } = expectSingle(output, 'add_question');
+ return { pass, score, reason };
+}
+
+export function assertRoutesToReviewResume(output: unknown): AssertionResult {
+ const { pass, score, reason } = expectSingle(output, 'review_resume');
+ return { pass, score, reason };
+}
diff --git a/evals/mcp-tools/fixtures/three-postings.txt b/evals/mcp-tools/fixtures/three-postings.txt
new file mode 100644
index 0000000..79ba076
--- /dev/null
+++ b/evals/mcp-tools/fixtures/three-postings.txt
@@ -0,0 +1,22 @@
+Found these three today:
+
+1) Staff Platform Engineer — Helio Systems
+https://boards.greenhouse.io/heliosystems/jobs/4411920
+Remote (Canada). Full-time. $175k–$205k.
+Own the internal developer platform: build tooling, CI/CD, and the Kubernetes
+substrate the product teams deploy onto. Requires 8+ years of infrastructure
+engineering, deep Go or Rust, and prior platform-team leadership.
+
+2) Senior Data Engineer — Marlow Analytics
+https://jobs.lever.co/marlowanalytics/8c21f0ad-7b4e-4b9a-9d21-6f0a2c3e1b55
+Hybrid, Toronto ON. Full-time. $150k–$180k.
+Build and operate batch and streaming pipelines on Spark and Kafka feeding the
+customer-facing analytics product. Requires 5+ years in data engineering,
+strong Python and SQL, and dimensional modelling experience.
+
+3) Backend Engineer, Payments — Cindergate
+https://cindergate.com/careers/backend-payments
+Onsite, Calgary AB. Full-time. $130k–$160k.
+Work on ledgering, reconciliation, and payout orchestration for a high-volume
+payments platform. Requires 4+ years backend experience, PostgreSQL depth, and
+familiarity with double-entry accounting concepts.
diff --git a/evals/mcp-tools/fixtures/title-only.txt b/evals/mcp-tools/fixtures/title-only.txt
new file mode 100644
index 0000000..5226028
--- /dev/null
+++ b/evals/mcp-tools/fixtures/title-only.txt
@@ -0,0 +1,2 @@
+Senior Product Designer at Vantage Loop
+https://vantageloop.com/careers/senior-product-designer
diff --git a/evals/mcp-tools/generate-tools.ts b/evals/mcp-tools/generate-tools.ts
new file mode 100644
index 0000000..1287c4b
--- /dev/null
+++ b/evals/mcp-tools/generate-tools.ts
@@ -0,0 +1,9 @@
+import { writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { getTools } from './tools';
+
+// promptfoo's `tools:` loader imports TS files but comes back with an empty
+// module namespace, so the tool array is materialized to JSON first. Run by
+// the eval:mcp-tools script on every invocation — tools.json is generated,
+// never hand-edited, so it cannot drift from route.ts.
+writeFileSync(join(__dirname, 'tools.json'), JSON.stringify(getTools(), null, 2) + '\n');
diff --git a/evals/mcp-tools/prompt.ts b/evals/mcp-tools/prompt.ts
new file mode 100644
index 0000000..bad94a6
--- /dev/null
+++ b/evals/mcp-tools/prompt.ts
@@ -0,0 +1,42 @@
+// Deliberately thin. The point of these evals is that the TOOL DESCRIPTIONS
+// carry the routing, so the system prompt must not do that work for them —
+// don't add hints like "use add_jobs_batch for multiple jobs" here.
+const SYSTEM_PROMPT =
+ 'You are a helpful assistant connected to the user\'s JobSync account through its MCP tools. ' +
+ 'Use the available tools to carry out the user\'s request. Do not ask for confirmation.';
+
+type Message = Record<string, unknown>;
+
+// vars.priorTool/priorArgs/priorResult replay a completed tool round-trip so a
+// case can assert what the model does NEXT (e.g. follows the match directive
+// add_job hands back).
+export default function prompt({ vars }: { vars: Record<string, string> }): Message[] {
+ const messages: Message[] = [
+ { role: 'system', content: SYSTEM_PROMPT },
+ { role: 'user', content: vars.userMessage },
+ ];
+
+ if (vars.priorTool) {
+ messages.push({
+ role: 'assistant',
+ content: null,
+ // DeepSeek rejects a replayed assistant turn in thinking mode unless
+ // reasoning_content comes back with it; harmless on other providers.
+ reasoning_content: vars.priorReasoning ?? 'Saving the posting the user supplied.',
+ tool_calls: [
+ {
+ id: 'call_prior',
+ type: 'function',
+ function: { name: vars.priorTool, arguments: vars.priorArgs ?? '{}' },
+ },
+ ],
+ });
+ messages.push({
+ role: 'tool',
+ tool_call_id: 'call_prior',
+ content: vars.priorResult ?? '',
+ });
+ }
+
+ return messages;
+}
diff --git a/evals/mcp-tools/promptfooconfig.yaml b/evals/mcp-tools/promptfooconfig.yaml
new file mode 100644
index 0000000..1610ebd
--- /dev/null
+++ b/evals/mcp-tools/promptfooconfig.yaml
@@ -0,0 +1,121 @@
+description: MCP tool-routing regression tests — which tool the agent picks, and with what args
+
+# These rows exercise TOOL SELECTION only. No MCP server is attached and no
+# handler runs: the tools are declared statically from the same Zod shapes and
+# descriptions route.ts registers, so the model chooses and promptfoo asserts on
+# the raw tool_calls. Nothing touches the database and no PAT is needed.
+# Handler behaviour (dedupe, scopes, rate limits) stays in __tests__/mcp*.spec.ts.
+
+providers:
+ - id: openai:chat:deepseek-v4-flash
+ config:
+ apiBaseUrl: https://api.deepseek.com
+ apiKeyEnvar: DEEPSEEK_API_KEY
+ showThinking: false
+ temperature: 0
+ max_tokens: 8192
+ tool_choice: auto
+ tools: file://./tools.json
+
+prompts:
+ - file://./prompt.ts
+
+tests:
+ - description: Single posting with a full JD - routes to add_job, not batch
+ vars:
+ jobPosting: file://../job-match/fixtures/backend-job.txt
+ userMessage: |
+ Save this job posting to JobSync:
+
+ {{jobPosting}}
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertRoutesToAddJob
+ - type: javascript
+ value: file://./assertions.ts:assertDescriptionNotSummarized
+
+ - description: Three postings in one message - routes to add_jobs_batch, one call
+ vars:
+ jobPosting: file://./fixtures/three-postings.txt
+ # "None are tracked yet" isolates batching from deduping — otherwise the
+ # model spends its turn on parallel find_job probes and never reaches the
+ # add, which tests find_job's description rather than add_jobs_batch's.
+ userMessage: |
+ Add all of these to JobSync. None of them are tracked yet, so don't bother
+ checking for duplicates.
+
+ {{jobPosting}}
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertRoutesToAddJobsBatch
+
+ - description: Editing a tracked job - never routes to the create path
+ vars:
+ # The URL is supplied so find_job is actionable — without any handle on
+ # the job, asking the user for one is legitimate, not a routing failure.
+ userMessage: >
+ The Northwind Cloud senior backend role I saved last week lists the salary
+ wrong. It should be $185k-$210k, not $160k-$190k. Fix it — the posting is
+ at https://northwindcloud.com/careers/senior-backend-engineer
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertRoutesToUpdatePath
+
+ - description: Re-running a saved search - checks find_job or sets upsert
+ vars:
+ jobPosting: file://../job-match/fixtures/backend-job.txt
+ userMessage: |
+ This is my daily automated search run. Save this posting - it may already
+ be tracked from a previous run.
+
+ {{jobPosting}}
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertDedupeAware
+
+ - description: Follows the match directive after add_job
+ vars:
+ userMessage: |
+ Save this job posting to JobSync, then do whatever it asks you to do next.
+
+ Senior Backend Engineer at Northwind Cloud. Remote, North America.
+ Requires 7+ years backend, Go, Kubernetes, AWS, PostgreSQL, and
+ distributed systems design experience. $160k-$190k.
+ priorTool: add_job
+ priorArgs: '{"company":"Northwind Cloud","jobTitle":"Senior Backend Engineer","jobDescription":"Senior Backend Engineer at Northwind Cloud. Remote, North America. Requires 7+ years backend, Go, Kubernetes, AWS, PostgreSQL, and distributed systems design experience. $160k-$190k."}'
+ priorResult: >
+ Job created (id: cm4x9j2k70001abcd1234efgh). Company "Northwind Cloud" matched
+ an existing record; job title "Senior Backend Engineer" was created.
+ MATCH DIRECTIVE: this posting has a full description. Produce a job-fit match
+ analysis against the user's default resume, then call save_match_result with
+ jobId cm4x9j2k70001abcd1234efgh.
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertFollowsMatchDirective
+
+ - description: Title-only posting - no fabricated match result
+ vars:
+ jobPosting: file://./fixtures/title-only.txt
+ userMessage: |
+ Save this and score how well it fits me:
+
+ {{jobPosting}}
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertNoFabricatedMatch
+
+ - description: Interview question - routes to add_question, not add_job
+ vars:
+ userMessage: >
+ They asked me this in the Northwind screen today, save it for prep:
+ "Walk me through how you'd design a rate limiter for a multi-tenant API."
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertRoutesToAddQuestion
+
+ - description: Resume review request - routes to review_resume first
+ vars:
+ userMessage: Can you review my resume and tell me where it's weak?
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertRoutesToReviewResume
diff --git a/evals/mcp-tools/tools.ts b/evals/mcp-tools/tools.ts
new file mode 100644
index 0000000..7113a9a
--- /dev/null
+++ b/evals/mcp-tools/tools.ts
@@ -0,0 +1,41 @@
+import { z } from 'zod';
+import { MCP_TOOL_DESCRIPTIONS } from '../../src/lib/mcp/toolDescriptions';
+import {
+ McpAddJobInputShape,
+ McpFindJobInputShape,
+ McpUpdateJobInputShape,
+ McpAddQuestionInputShape,
+ McpSaveMatchResultInputShape,
+ McpAddJobsBatchInputShape,
+ McpSaveMatchResultsBatchInputShape,
+ McpReviewResumeInputShape,
+ McpSaveResumeReviewInputShape,
+} from '../../src/models/mcp.schema';
+
+// Same raw shapes route.ts hands the MCP SDK, so the model sees the parameter
+// schema and .describe() text the real server advertises. io:'input' keeps the
+// pre-transform side (status stays an enum despite its preprocess wrapper).
+const SHAPES: Record<string, z.ZodRawShape> = {
+ add_job: McpAddJobInputShape,
+ find_job: McpFindJobInputShape,
+ update_job: McpUpdateJobInputShape,
+ add_question: McpAddQuestionInputShape,
+ save_match_result: McpSaveMatchResultInputShape,
+ add_jobs_batch: McpAddJobsBatchInputShape,
+ save_match_results_batch: McpSaveMatchResultsBatchInputShape,
+ review_resume: McpReviewResumeInputShape,
+ save_resume_review: McpSaveResumeReviewInputShape,
+};
+
+export function getTools() {
+ return Object.entries(SHAPES).map(([name, shape]) => ({
+ type: 'function',
+ function: {
+ name,
+ description: MCP_TOOL_DESCRIPTIONS[name as keyof typeof MCP_TOOL_DESCRIPTIONS],
+ parameters: z.toJSONSchema(z.object(shape), { io: 'input' }),
+ },
+ }));
+}
+
+export default getTools;
diff --git a/package.json b/package.json
index c06e40a..8a8da89 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"eval:job-match": "promptfoo eval --config evals/job-match/promptfooconfig.yaml",
"eval:automation-match": "promptfoo eval --config evals/job-match/automation.promptfooconfig.yaml",
"eval:resume-import": "promptfoo eval --config evals/resume-import/promptfooconfig.yaml",
+ "eval:mcp-tools": "tsx evals/mcp-tools/generate-tools.ts && promptfoo eval --config evals/mcp-tools/promptfooconfig.yaml",
"eval:all": "promptfoo eval --config evals/promptfooconfig.yaml",
"eval:view": "promptfoo view"
},
diff --git a/src/app/api/mcp/route.ts b/src/app/api/mcp/route.ts
index 04f58a4..9050e30 100644
--- a/src/app/api/mcp/route.ts
+++ b/src/app/api/mcp/route.ts
@@ -1,6 +1,7 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
import { resolveMcpToken } from "@/lib/mcp/auth";
+import { MCP_TOOL_DESCRIPTIONS } from "@/lib/mcp/toolDescriptions";
import {
McpAddJobInputShape,
McpAddJobSchema,
@@ -58,7 +59,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"add_job",
- "Add a job application to JobSync. Resolves or creates company, job title, location, and source by name. Returns a transparency report of what was matched vs. created.",
+ MCP_TOOL_DESCRIPTIONS.add_job,
McpAddJobInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -86,7 +87,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"find_job",
- "Look up whether a job posting URL is already saved in JobSync. Call this before add_job when re-running a search, so an already-tracked posting is updated instead of duplicated.",
+ MCP_TOOL_DESCRIPTIONS.find_job,
McpFindJobInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -109,7 +110,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"update_job",
- "Correct or enrich a job previously added through MCP. Only the fields you supply change. Supplying a fuller jobDescription re-classifies the posting and requests a fresh match analysis — use this instead of re-adding with allowDuplicate.",
+ MCP_TOOL_DESCRIPTIONS.update_job,
McpUpdateJobInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -132,7 +133,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"add_question",
- "Add an entry to the Question Bank. Resolves or creates tags by name. Returns a transparency report of what was matched vs. created.",
+ MCP_TOOL_DESCRIPTIONS.add_question,
McpAddQuestionInputShape,
async (rawInput) => {
if (!auth.scopes.includes("questions:write")) {
@@ -160,7 +161,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"save_match_result",
- "Persist a job-fit match analysis (produced by you, the agent) against a job previously created with add_job. Call this after add_job hands you a match directive.",
+ MCP_TOOL_DESCRIPTIONS.save_match_result,
McpSaveMatchResultInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -188,7 +189,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"add_jobs_batch",
- "Add several jobs in one call. Same per-item behaviour as add_job (including upsert and the match directive); returns one labelled result per item. Use this for scheduled runs instead of N sequential add_job calls.",
+ MCP_TOOL_DESCRIPTIONS.add_jobs_batch,
McpAddJobsBatchInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -211,7 +212,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"save_match_results_batch",
- "Persist several job-fit match analyses in one call. Same per-item behaviour as save_match_result; returns one labelled result per item.",
+ MCP_TOOL_DESCRIPTIONS.save_match_results_batch,
McpSaveMatchResultsBatchInputShape,
async (rawInput) => {
if (!auth.scopes.includes("jobs:write")) {
@@ -239,7 +240,7 @@ async function handler(req: Request): Promise<Response> {
// one without also backfilling existing tokens.
server.tool(
"review_resume",
- "Fetch the user's default resume so you can review it. Returns the normalized resume text plus a directive — produce the review yourself, then call save_resume_review with the result.",
+ MCP_TOOL_DESCRIPTIONS.review_resume,
McpReviewResumeInputShape,
async () => {
return handleReviewResume(userId);
@@ -248,7 +249,7 @@ async function handler(req: Request): Promise<Response> {
server.tool(
"save_resume_review",
- "Persist a resume review (produced by you, the agent) against the resume previously handed to you by review_resume. Call this after review_resume hands you a review directive.",
+ MCP_TOOL_DESCRIPTIONS.save_resume_review,
McpSaveResumeReviewInputShape,
async (rawInput) => {
const parsed = McpSaveResumeReviewSchema.safeParse(rawInput);
diff --git a/src/lib/mcp/toolDescriptions.ts b/src/lib/mcp/toolDescriptions.ts
new file mode 100644
index 0000000..8a32751
--- /dev/null
+++ b/src/lib/mcp/toolDescriptions.ts
@@ -0,0 +1,26 @@
+// Tool descriptions are prompt surface, not documentation: the agent routes
+// between add_job / update_job / add_jobs_batch on this text alone. Kept out
+// of route.ts so evals/mcp-tools can assert against the exact strings the
+// server registers instead of a copy that silently drifts.
+export const MCP_TOOL_DESCRIPTIONS = {
+ add_job:
+ "Add a job application to JobSync. Resolves or creates company, job title, location, and source by name. Returns a transparency report of what was matched vs. created.",
+ find_job:
+ "Look up whether a job posting URL is already saved in JobSync. Call this before add_job when re-running a search, so an already-tracked posting is updated instead of duplicated.",
+ update_job:
+ "Correct or enrich a job previously added through MCP. Only the fields you supply change. Supplying a fuller jobDescription re-classifies the posting and requests a fresh match analysis — use this instead of re-adding with allowDuplicate.",
+ add_question:
+ "Add an entry to the Question Bank. Resolves or creates tags by name. Returns a transparency report of what was matched vs. created.",
+ save_match_result:
+ "Persist a job-fit match analysis (produced by you, the agent) against a job previously created with add_job. Call this after add_job hands you a match directive.",
+ add_jobs_batch:
+ "Add several jobs in one call. Same per-item behaviour as add_job (including upsert and the match directive); returns one labelled result per item. Use this for scheduled runs instead of N sequential add_job calls.",
+ save_match_results_batch:
+ "Persist several job-fit match analyses in one call. Same per-item behaviour as save_match_result; returns one labelled result per item.",
+ review_resume:
+ "Fetch the user's default resume so you can review it. Returns the normalized resume text plus a directive — produce the review yourself, then call save_resume_review with the result.",
+ save_resume_review:
+ "Persist a resume review (produced by you, the agent) against the resume previously handed to you by review_resume. Call this after review_resume hands you a review directive.",
+} as const;
+
+export type McpToolName = keyof typeof MCP_TOOL_DESCRIPTIONS;