> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcpjam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating to SDK 10

> Upgrade @mcpjam/sdk from 9.x to 10: sign in or set an API key, declare multi-prompt tests, and check that a run starts. About 10 minutes.

SDK 10 changes how an eval run starts. Every eval run now needs an MCPJam login or an organization API key, even when you bring your own model key or turn off result uploads, and MCPJam takes a platform payment for each iteration before it runs. Your test code changes only if a test sends more than one prompt per iteration.

This guide upgrades from SDK 9. If you are on an older version, first follow [Migrating to SDK 9](https://docs.mcpjam.com/sdk/migrating-to-v9.md). SDK 11 and 12 add smaller changes; see [After SDK 10](#after-sdk-10).

## Before you start

* Node.js 22 or later (`node --version`). SDK 10 has the same requirement as SDK 9.
* An MCPJam account in the organization whose project the runs belong to.
* For CI, an organization API key (`sk_…`). Create one in MCPJam under **Settings → API keys**, or ask an organization admin.
* If you use `@mcpjam/cli`, `@mcpjam/vitest` or `@mcpjam/widget-react`, plan to upgrade them too, to CLI 6, `@mcpjam/vitest` 0.3 and `@mcpjam/widget-react` 0.3, the releases built on SDK 10.
* To finish on SDK 12 with CLI 7, Node.js `^22.23.4`, `^24.22.1` or `>=26.12.1`. CLI 6.1 and later need a narrower range than the SDK.

## What changes

| Area | SDK 9 | SDK 10 |
| - | - | - |
| Credentials | Needed only to upload results. | Needed for every eval run, including runs with your own model key and runs with uploads off. |
| Run start | Runs started locally. | Each run first records a start with MCPJam. If MCPJam can't be reached, nothing runs. |
| Payment | None. | MCPJam takes a platform payment before each iteration. |
| Multi-prompt tests | No declaration. | A test that sends more than one prompt per iteration declares `billableSteps`. |

## Upgrade

### 1. Update the packages

```bash theme={"theme":"css-variables"}
npm install @mcpjam/sdk@^10
```

If you use them, pin the CLI, the Vitest integration and `@mcpjam/widget-react` to the releases built on SDK 10, wherever CI installs them. Later releases run on SDK 11 or 12, so a version range would test a newer SDK than the one you're upgrading to. Commit the updated lockfile.

```bash theme={"theme":"css-variables"}
npm install -g @mcpjam/cli@6.0.0
npm install -D --save-exact @mcpjam/vitest@0.3.0
npm install --save-exact @mcpjam/widget-react@0.3.0
```

> [!TIP]
>
> `npm ls @mcpjam/sdk` shows only `10.x`.

### 2. Give the SDK a credential

On your own machine, sign in once with the CLI. The SDK reads the saved login. If you didn't install the CLI in the previous step, run it through `npx`:

```bash theme={"theme":"css-variables"}
npx -y @mcpjam/cli@6.0.0 cloud login
```

In CI, store the key as a secret and expose it as `MCPJAM_API_KEY` in the job that runs evals. In GitHub Actions:

```yaml theme={"theme":"css-variables"}
env:
  MCPJAM_API_KEY: ${{ secrets.MCPJAM_API_KEY }}
```

Runs go to your default project. To use another one, set `MCPJAM_PROJECT_ID` in the same job, or pass `mcpjam.project` in the run options.

You can also pass a key in code with the `mcpjam.apiKey` run option. The SDK uses the first credential it finds, in this order:

1. A credential passed in code.
2. `MCPJAM_API_KEY`.
3. The saved CLI login.

The top-level `apiKey` and `mcpjamAuth` run options also start a run. Pass only one of them. They don't turn on uploads by themselves, but if `MCPJAM_API_KEY` is also set, results still upload (see the warning below). A credential that is set but invalid fails the run. The SDK never falls back to the next one, and it never opens a browser to sign in during CI.

> [!WARNING]
>
> When `MCPJAM_API_KEY` or `mcpjam.apiKey` is set, the SDK uploads results to MCPJam. If you ran with uploads off on SDK 9, keep them off with `mcpjam: { enabled: false }` in the run options. The run still uses the key to start.

> [!TIP]
>
> With the CLI login, the login command finished without an error. With the environment variable, `test -n "$MCPJAM_API_KEY"` succeeds in the eval job. For every method, including a credential passed in code, [Run one test](#run-one-test) confirms access.

### 3. Declare tests that send more than one prompt

MCPJam charges each iteration for the number of prompts it declares. The default is one. If a test's `test` function calls `run()` more than once per iteration, set `billableSteps` to that number:

```typescript theme={"theme":"css-variables"}
const test = new EvalTest({
  id: "c_book_and_confirm",
  name: "books the venue, then confirms",
  billableSteps: 2, // two run() calls below
  test: async (executor) => {
    const booking = await executor.run("Book the venue for Friday.");
    const confirmation = await executor.run("Confirm the booking.", { context: booking });
    return booking.hasToolCall("book_venue") && confirmation.text.length > 0;
  },
});
```

Only count `run()` calls in your code. Tool calls and model steps inside one `run()` don't add prompts. Suite files and authored cases count their prompt steps for you.

> [!TIP]
>
> Every test whose `test` function calls `run()` more than once declares `billableSteps` equal to the number of calls.

### 4. Run one test

Take one test and the executor (`HostRunner` or `HostRuntime`) your suite already uses, and run it with one iteration to confirm the run starts and is paid. Pass the run options your suite already uses and change only `iterations`, so settings such as `mcpjam: { enabled: false }` still apply:

```typescript theme={"theme":"css-variables"}
const runOptions = { /* the options your suite passes to run() */ };
const result = await test.run(executor, { ...runOptions, iterations: 1 });
console.log(result.iterations, result.successes);
```

> [!TIP]
>
> The run finishes and logs `1` followed by `1` or `0`, with no `EvalRunStartError` or `EvalBillingError`.

### 5. Run your suite

Run your suite as you did on SDK 9. Assertions and results behave the same.

> [!TIP]
>
> The suite passes and fails the same cases as on SDK 9.

### 6. Move to the current version

SDK 11 and 12 need no code changes for most projects; see [After SDK 10](#after-sdk-10). To finish on the current version:

```bash theme={"theme":"css-variables"}
npm install @mcpjam/sdk@^12
npm install -g @mcpjam/cli@7.0.0
npm install -D --save-exact @mcpjam/vitest@0.3.2
npm install --save-exact @mcpjam/widget-react@0.4.2
```

Install only the packages you use. CLI 7 requires Node.js `^22.23.4`, `^24.22.1` or `>=26.12.1`; check `node --version` first. CLI 7 also removes `mcpjam cloud environments`: run evals with `mcpjam cloud eval run --server` instead. Commit the updated lockfile.

> [!TIP]
>
> `npm ls @mcpjam/sdk` shows only `12.x`, and your suite still passes.

## If something goes wrong

| Message | Cause | Fix |
| - | - | - |
| "Eval runs require an MCPJam login or API key…" | No credential was found. | Run `mcpjam cloud login`, or set `MCPJAM_API_KEY`. |
| "This MCPJam API key is invalid or retired…" | The key doesn't start with `sk_`, usually an older project key. | Create an `sk_` key in **Settings → API keys**. |
| "Your MCPJam credential is invalid or revoked…" | The key or login was rejected. | Replace a rejected key passed in code or in `MCPJAM_API_KEY` with a new `sk_` key. Removing it also works, because the SDK then falls back to the saved login. If the saved login was rejected, run `mcpjam cloud login` again. |
| "Your MCPJam login could not be refreshed…" | The saved CLI login expired. | Run `mcpjam cloud login` again. |
| "Choose one MCPJam credential: apiKey or mcpjamAuth." | Both run options were passed. | Remove one of them. |
| "Your MCPJam API key has expired…" | The key is past its expiry. | Create a new key in **Settings → API keys**. |
| "Your MCPJam account or key cannot access this project…" | The credential lacks access to the selected project. | Use a credential with access to that project, or choose a project in your organization. |
| "Could not reach MCPJam to start the eval…" | MCPJam didn't answer. The SDK retries briefly, then stops before running anything. | Check your network and try again. There is no offline mode. |
| "MCPJam refused this iteration payment…" | The organization is out of credits or over a limit. | Check credits and limits with an organization admin. Iterations that already finished keep their results. |
| "This eval exceeded its N declared prompts…" | A test called `run()` more times than `billableSteps` allows. | Raise `billableSteps` to the number of `run()` calls. |
| "Set billableSteps to a positive whole number." | `billableSteps` is 0, negative or not an integer. | Use a whole number of 1 or more. |

## What the run start sends

Before a run, the SDK sends MCPJam:

* Your credential.
* Any MCPJam API headers you configured.
* The project, the package version and which one started the run (SDK, CLI or Vitest), a run ID, and the planned number of iterations.
* Which model providers the run uses, and whether it uses a client profile.

It sends no prompts, model outputs, tool calls or server URLs. If MCPJam hosts the model, prompts still go through MCPJam to the model, as in SDK 9. Turning off analytics (`DO_NOT_TRACK`, `MCPJAM_TELEMETRY_DISABLED`) doesn't turn off this request. Results stay local unless uploads are on.

Retries of a failed iteration reuse its payment. If a test sends fewer prompts than it declared, the difference isn't refunded automatically.

## After SDK 10

Most projects need no changes for SDK 11 and 12. Check these if your code uses the APIs they name.

* **SDK 11:** a client's MCP Events delivery modes come from its saved setting. A client with no saved Events setting, or one that can't be read, now gets no delivery modes, and a vendor harness (`agentLoop` or `harness`) gets no events even with a saved setting. Also, `HOST_STYLE_EVENT_DELIVERY_MODES`, `hostStyleEventDeliveryModes` and `clearEventsHostSetting` were removed. `resolveHostEventDeliveryModes`, `subscribableModes` and `EventsSupportHost` changed too. If your code reads Events delivery modes, including through `subscribableModes`, save an explicit Events setting for each client you use.
  `MCPClientManager.executeTool` also stops and throws when it can't read the tool's schema (the `tools/list` request times out, is cancelled or disconnects), instead of sending the call anyway.
* **SDK 12:** the table that maps operations to plan features changed, and `OperationFeature` is now a single key or `null`. This affects code that calls `isOperationAvailable` or uses `PLATFORM_FEATURE_KEYS` or `OperationFeature`. Also, progressive tool discovery is now on in the ChatGPT, Cursor CLI, Grokbot and Notion client presets, so evals that use them can see a different set of tools. Turn it off in the client to keep the old behavior.

The full list is in the [SDK changelog](https://github.com/MCPJam/inspector/blob/main/sdk/CHANGELOG.md).

## Unchanged

Connecting servers, `HostRunner` and `HostRuntime`, `EvalTest` and `EvalSuite` assertions, matching options, reporting, and the minimum Node.js version work as in SDK 9.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.