← MCPJamCONTENT HISTORY

Update to MCPJam

Snapshot Nov 20, 2026 · 07:41 UTC · version 1.0.1

Collection source: downloaded plugin package.

WHAT CHANGED

First saved snapshot

No earlier snapshot is available to establish a change.

Save MCPJam and check future changes in Following.

Up to 3 plugins free · no card required.

Compare saved observations

Download comparison JSON
Full technical diff · 0 changed fields
Full snapshot data
{
  "description": "Convert MCPJam Explore-generated test cases into @mcpjam/sdk eval tests. Produces one test per case, exactly matching the user's prompts and expectations.",
  "included_files": [],
  "name": "explore-to-sdk-evals",
  "skill_md_contents": "---\nname: explore-to-sdk-evals\ndescription: Convert MCPJam Explore-generated test cases into @mcpjam/sdk eval tests. Produces one test per case, exactly matching the user's prompts and expectations.\n---\n\n# explore-to-sdk-evals\n\n## 1. Purpose\n\nThis skill converts **pre-existing MCPJam** Explore **test cases** (in the same document above, under `## Explore-generated test cases`)  into runnable `@mcpjam/sdk` eval tests.\n\n**Rules:**\n\n- **Generate exactly the cases provided** — do not invent new cases, do not skip any, do not reword user prompts (use the exact query text from each case’s fenced block).\n- The brief above already includes `## Tools`, resources/prompts if any, suggested scenarios, and `## Explore-generated test cases` — parse titles, prompts, negative flags, expected tool-call shapes, and expected output from there.\n- For full SDK API (advanced validators, suite patterns, error handling), see the `create-mcp-eval` skill in the MCPJam SDK or package documentation — this file stays minimal.\n\n---\n\n## 2. Framework detection\n\nBefore emitting imports, inspect the target repo:\n\n1. Read **`package.json`**: `scripts` and `devDependencies` for **`jest`** or **`vitest`**.\n2. Look for **`jest.config.*`**, **`vitest.config.*`**, or **`vite.config.*`** that references Vitest.\n\n**Apply:**\n\n\n| Condition                               | Imports / runner                                                                                                                     |\n| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |\n| Jest present                            | `describe`, `it`, `expect`, `beforeAll`, `afterAll` from `@jest/globals` (or rely on Jest globals); use `ts-jest` if TypeScript. |\n| Vitest present (no Jest)                | `import { describe, it, expect, beforeAll, afterAll } from \"vitest\"`                                                                 |\n| Neither present                         | **Default to Vitest** in generated scaffold (mention adding dep).                                                                    |\n| User explicitly wants no test framework | Use `EvalTest` / `EvalSuite` `.run()` in a plain `async function main()` script with manual assertions — no `describe`/`it`.     |\n\n\n---\n\n## 3. Quick API reference (Explore flows only)\n\n```typescript\nimport { MCPClientManager, HostRunner, createEvalRunReporter } from \"@mcpjam/sdk\";\nimport {\n  matchNoToolCalls,\n  matchToolCallWithPartialArgs,\n  matchToolArgument,\n  matchToolArgumentWith,\n} from \"@mcpjam/sdk\";\n```\n\n**Connection**\n\n- `const manager = new MCPClientManager();`\n- HTTP: `await manager.connectToServer(SERVER_ID, { url: MCP_SERVER_URL });`\n- Stdio: `await manager.connectToServer(SERVER_ID, { command: \"node\", args: [\"./server.js\"] });`\n- `const tools = await manager.getToolsForAiSdk([SERVER_ID]);`\n- `await manager.disconnectAllServers();` in `afterAll`\n\n**Agent**\n\n- `new HostRunner({ tools, model: MODEL, apiKey: LLM_API_KEY, maxSteps: 8, mcpClientManager: manager })` — pass the **same** `MCPClientManager` instance you used for `connectToServer` / `getToolsForAiSdk`. **`mcpClientManager` is required** for `widgetSnapshots` on reported results (MCP App HTML capture via `readResource`), which powers **MCP App replay in MCPJam eval traces**. Omitting it still runs tools correctly but traces in the app will have **no embedded widget replay**.\n- **`apiKey` and `model` must match the LLM provider the user chose** (see §5); there is no default assumption that the key is an OpenAI key.\n- `await runner.run(caseQuery)` — use **verbatim** `caseQuery` from Explore; for slow MCP + multi-step chains use `{ timeoutMs }` (or `timeout`) so the prompt does not abort before tools finish (see §6).\n- Multi-turn only if a **single** Explore case clearly requires follow-up in one narrative; otherwise one prompt per `it()` (see §4c)\n\n**Result inspection**\n\n- `result.hasToolCall(\"tool_name\")`\n- `result.toolsCalled()` — `string[]`\n- `result.getToolCalls()` — for validators\n\n**Validators**\n\n- Negative: `matchNoToolCalls(result.toolsCalled())`\n- Partial args: `matchToolCallWithPartialArgs(\"tool\", { key: value }, result.getToolCalls())` — use only when those values are **real literals** from Explore, not placeholders (§4).\n- Single-arg exact / predicate: `matchToolArgument`, `matchToolArgumentWith` (see `create-mcp-eval` / SDK validators).\n\n**Optional MCPJam upload**\n\n- `createEvalRunReporter({ suiteName, apiKey, strict: true, mcpClientManager: manager, serverNames: [SERVER_ID], ... })` — pass the **same** connected **`MCPClientManager`** as for `HostRunner` so uploads include **`serverReplayConfigs`** (HTTP MCP only; stdio connections do not produce replayable server config in the SDK). That is what sets `hasServerReplayConfig` in MCPJam and enables **Replay this run** / **server-side MCP replay** in the UI.\n- `await reporter.recordFromPrompt(result, { caseTitle, passed, expectedToolCalls?, isNegativeTest? })`\n- `await reporter.finalize()` in `afterAll` **before** `disconnectAllServers()` (with timeout). `finalize` calls `getServerReplayConfigs()` on the manager; disconnecting first clears client state and uploads **without** replay metadata. **`finalize()` can throw** (network, DNS, 401) even when all eval assertions passed. For best-effort upload: wrap in **try/catch**, log a warning, and continue; or gate uploads on something like `MCPJAM_REPORTING=1` so local/CI runs do not go red purely on reporting.\n- **UI replay still needs LLM keys in MCPJam Settings** for whatever `provider` the suite uses (e.g. OpenRouter); the app does not store provider API keys on the run.\n\n---\n\n## 4. Per-case translation\n\nUse the **Explore case title** as the human-readable basis for `it(\"...\")` description (sanitize quotes if needed). Use the **exact** user prompt from the ``` fenced block as `runner.run(\\`...)` argument.\n\n**Placeholder values in `tool_name({ ... })` lines:** Explore often shows **illustrative** arguments — e.g. `create_view({ elements: \"\" })` usually means **“this argument key exists / this shape,”** not “the value must be the empty string.” Blindly passing `{ elements: \"\" }` into `matchToolCallWithPartialArgs` will fail on real calls. **Prefer `hasToolCall(\"tool_name\")`** when the brief does not state a concrete literal. When you need stricter checks: use **`matchToolArgumentWith(\"tool\", \"key\", predicate, calls)`** (e.g. “present and non-empty”), or **`matchToolArgument`** only when Explore documents an **actual** expected value. Reserve `matchToolCallWithPartialArgs` for **real literals** listed in the case, not for `\"\"`, `\"...\"`, or other stand-ins.\n\n### 4a. Positive (expected tool calls, not negative)\n\nFor each expected tool line like ``tool_name({arg: val})``:\n\n```typescript\nit(\"Explore case title here\", async () => {\n  const result = await runner.run(`paste exact query from Explore`);\n  expect(result.hasToolCall(\"tool_name\")).toBe(true);\n  // Only when Explore lists real literals — not placeholders (see §4 intro).\n  // expect(\n  //   matchToolCallWithPartialArgs(\"tool_name\", { arg: literalVal }, result.getToolCalls()),\n  // ).toBe(true);\n  if (reporter) {\n    await reporter.recordFromPrompt(result, {\n      caseTitle: \"Explore case title here\",\n      passed: result.hasToolCall(\"tool_name\"),\n      expectedToolCalls: [{ toolName: \"tool_name\" }],\n    });\n  }\n}, 90_000);\n```\n\n### 4b. Negative test (**`Negative test:`** / NEG-style case)\n\n```typescript\nit(\"Explore case title here\", async () => {\n  const result = await runner.run(`paste exact query from Explore`);\n  expect(matchNoToolCalls(result.toolsCalled())).toBe(true);\n  if (reporter) {\n    await reporter.recordFromPrompt(result, {\n      caseTitle: \"Explore case title here\",\n      passed: matchNoToolCalls(result.toolsCalled()),\n      isNegativeTest: true,\n    });\n  }\n}, 90_000);\n```\n\n### 4c. Multiple expected tools in one Explore case\n\nPrefer **one** `it()` that asserts all listed tools (unless the case text explicitly describes a conversation turn — then use `context: r1` for the second `prompt`).\n\n```typescript\nit(\"Explore case title\", async () => {\n  const result = await runner.run(`exact query`);\n  expect(result.hasToolCall(\"first_tool\")).toBe(true);\n  expect(result.hasToolCall(\"second_tool\")).toBe(true);\n  // Optional: arg checks only for real literals (§4) — else hasToolCall is enough\n}, 90_000);\n```\n\nDo **not** merge two separate Explore cases into one `it()` — **one Explore case → one `it()`** unless the plan above explicitly allows multi-tool-in-one-case as above.\n\n---\n\n## 5. Scaffold template\n\n### 5a. Required environment variables — ask the user before generating code\n\n**Do not emit the full scaffold until the user has supplied values (or explicit env var names) for everything needed to run the evals locally and in CI.**\n\n1. **Prompt the user** for each required variable below. If they prefer names only, use placeholders like `process.env.ANTHROPIC_API_KEY` and document those names in a short comment or README snippet in the same response — but the skill’s default is to **confirm what must be set**, not to guess secrets.\n\n\n| Concern                | Typical env vars (examples only — not exhaustive)                                                                                                               | Notes                                                                                                                                                                                            |\n| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| MCP reachability       | `MCP_SERVER_URL`, or stdio `command` / `args` from the brief                                                                                                    | Always align with the brief’s `Connection:` / `Connection (stdio):`.                                                                                                                             |\n| LLM credential         | **Provider-specific** — e.g. `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `AZURE_OPENAI_API_KEY`, or a key your codebase already uses | **`OPENAI_API_KEY` is one option, not the assumed default.** Ask which provider and model they use, then wire `apiKey` and `EVAL_MODEL` (or equivalent) to **that** provider’s SDK expectations. |\n| Model string           | `EVAL_MODEL` or provider’s convention                                                                                                                           | Must match the chosen provider’s model id format.                                                                                                                                                |\n| Optional MCPJam upload | `MCPJAM_API_KEY` (an `sk_…` key from Settings → API keys; optional `MCPJAM_PROJECT_ID`)                                                                                                                                                | Omit reporter wiring if not provided.                                                                                                                                                            |\n\n\n1. **Never imply OpenAI-only copy:** avoid phrasing like “paste your OpenAI key” unless the user already said OpenAI. Default language: **“which LLM provider and API key env var are you using?”**\n2. Same rule as `create-mcp-eval`: **ask** which LLM provider, model, and env var name before generating code; **never silently default** to a single vendor.\n3. **Required assistant output (before codegen):** After the user answers, echo an explicit **env contract** so the model cannot “skip” to OpenAI-flavored code without mirroring what was agreed:\n\n```text\nEnv contract (confirmed — use in generated file):\n- provider: <e.g. anthropic | openai | google | azure | other>\n- EVAL_MODEL: <exact model id string>\n- LLM API key env var: <e.g. ANTHROPIC_API_KEY>\n- MCP: <MCP_SERVER_URL and any other vars, or stdio command source>\n- Optional reporting: MCPJAM_API_KEY present? <yes|no>; fail run on finalize error, or try/catch + warn; optional gate MCPJAM_REPORTING=1? <as agreed>\n```\n\nDo not generate the eval file until this block is filled from **user-provided** choices (not inferred defaults).\n\n### 5b. Template (after env contract is clear)\n\nUse **connection** from the brief blockquote (`Connection:` or `Connection (stdio):`) for `MCP_SERVER_URL` or the joined command string.\n\n```typescript\n// ─── Config ─────────────────────────────────────────────────────────────────\nconst MCP_SERVER_URL = process.env.MCP_SERVER_URL ?? \"<from brief>\";\n// Replace <PROVIDER_ENV> with the env var the user named (e.g. ANTHROPIC_API_KEY, not only OPENAI_API_KEY).\nconst LLM_API_KEY = process.env.<PROVIDER_ENV>!;\nconst MODEL = process.env.EVAL_MODEL ?? \"<provider/model>\";\nconst SERVER_ID = \"<server id from brief # MCP Server Brief: name>\";\nconst MCPJAM_API_KEY = process.env.MCPJAM_API_KEY;\n// See §5c: put `import \"dotenv/config\"` first in this file (or use Vitest setupFiles) so\n// RUN_LLM_TESTS sees .env in workers — config-only dotenv is unreliable.\nconst RUN_LLM_TESTS = Boolean(LLM_API_KEY && MCP_SERVER_URL);\n```\n\n**Hooks and `RUN_LLM_TESTS`:** File-level **`beforeAll` / `afterAll` run even when a later `describe` is `.skip`ped** (Vitest does this; **Jest can behave similarly** depending on suite structure). That can still hit the MCP when you meant “no API key → skip everything.” **Nest `beforeAll` / `afterAll` inside the same `describe` block** that is toggled with `(RUN_LLM_TESTS ? describe : describe.skip)`, so skipped suites do not connect. (Alternative: a single file-level `beforeAll` that starts with `if (!RUN_LLM_TESTS) return;` — but nesting is clearer.)\n\n```typescript\n(RUN_LLM_TESTS ? describe : describe.skip)(\"Explore cases\", () => {\n  let manager: MCPClientManager;\n  let runner: HostRunner;\n  let reporter: ReturnType<typeof createEvalRunReporter> | undefined;\n\n  beforeAll(async () => {\n    manager = new MCPClientManager();\n    await manager.connectToServer(SERVER_ID, { url: MCP_SERVER_URL });\n    const tools = await manager.getToolsForAiSdk([SERVER_ID]);\n    runner = new HostRunner({\n      tools,\n      model: MODEL,\n      apiKey: LLM_API_KEY,\n      maxSteps: 8,\n      mcpClientManager: manager,\n    });\n    if (MCPJAM_API_KEY) {\n      reporter = createEvalRunReporter({\n        suiteName: \"Explore-exported evals\",\n        apiKey: MCPJAM_API_KEY,\n        strict: true,\n        serverNames: [SERVER_ID],\n        mcpClientManager: manager,\n        expectedIterations: <count Explore cases with reporter records>,\n      });\n    }\n  }, 120_000);\n\n  afterAll(async () => {\n    if (reporter?.getAddedCount()) {\n      try {\n        await reporter.finalize();\n      } catch (e) {\n        console.warn(\"MCPJam reporter finalize failed (non-fatal):\", e);\n      }\n    }\n    await manager?.disconnectAllServers();\n  }, 120_000);\n\n  // one it() per Explore case — §4\n});\n```\n\nSet **`expectedIterations`** to the exact number of `recordFromPrompt` / iteration records you emit (same contract as `create-mcp-eval`). Teams that want **no upload attempts** unless explicitly enabled can guard `createEvalRunReporter` with e.g. `MCPJAM_REPORTING=1`. Omit the **try/catch** around `finalize` if reporting failures must fail the run; **document** the choice in the env contract (§5a.4).\n\n### 5c. `.env` files and Vitest workers\n\n`RUN_LLM_TESTS = Boolean(process.env…)` at **module top level** often runs **before** `process.env` is populated if **`dotenv` only loads inside `vitest.config.ts`** (config runs in a different context than test workers; evals then look “always skipped”).\n\n**Mitigations (pick one or combine):**\n\n- Add `import \"dotenv/config\"` (or project equivalent) as the **first import** in the eval test file so workers see secrets before `RUN_LLM_TESTS` is computed.\n- Set Vitest `test.setupFiles` (or **`setupFiles`**) to a small module that loads `.env` before any test file body runs.\n- In CI, inject secrets via the runner env (no `.env`); locally, prefer **setupFiles** over relying on config-time dotenv alone.\n\nOptionally: **fail loudly** in dev when vars are missing (`throw` or `describe` with one `it` that explains what to export) instead of only `describe.skip`, if that matches the team’s expectation.\n\n---\n\n## 6. Operational reminders\n\n- **Default `it(..., 90_000)` per test.** Use `120_000`–`180_000` and a matching **`runner.run(..., { timeoutMs: ... })`** when the brief implies **streaming, animation, slow MCP, or long multi-tool** runs (wall-clock often exceeds 90s end-to-end). Raise **`beforeAll` / `afterAll` hook timeouts** in Vitest if hooks approach default limits (`hookTimeout` in config or per-hook timeout argument).\n- `await` every `runner.prompt`, `reporter.record*`, `reporter.finalize`, `connectToServer`, `disconnectAllServers`.\n- **One reporter per file**; **`finalize()` in `afterAll`** with a generous timeout — call **`finalize()` before `disconnectAllServers()`** so replay config is still available from the manager (§3, §5b). Treat upload as **non-fatal** when agreed (§3, §5b).\n- **`mcpClientManager` on `createEvalRunReporter`:** pass the connected `manager` here **in addition to** `HostRunner` — uploads need this to attach **`serverReplayConfigs`** (`hasServerReplayConfig`); the runner’s field alone does not populate the report payload (§3).\n- **MCPJam UI replay** uses stored MCP replay plus **your Settings API keys** for the suite’s LLM providers; keys are not stored on the run.\n- `maxSteps: 8` on `HostRunner` unless the Explore case implies a longer tool chain.\n- **`mcpClientManager` on `HostRunner`:** pass the connected `manager` whenever results are reported to MCPJam so `widgetSnapshots` (MCP App HTML) are captured; without it, uploaded traces only have messages + spans.\n- Wrap LLM suites with **`(RUN_LLM_TESTS ? describe : describe.skip)`** and **nest lifecycle hooks inside that `describe`** (§5b) so skipped runs do not connect to the MCP.\n- If the user has not yet listed required env vars, **stop and ask** for them (§5a) before producing runnable files; emit the **env contract** block (§5a.4) before codegen.\n\n---\n\n## 7. Explicit non-goal\n\nFull `@mcpjam/sdk` encyclopedia, project greenfield setup, and long-form templates — use the **`create-mcp-eval`** skill for that."
}

SHA-256 of public snapshot: f75ae8138f6aee1c3dec098b6ef7b0140057c89baeef6e57af9a2dcc79a6ed59