Skip to main content
This guide walks you through installing the SDK, connecting to an MCP server, and running your first evaluation.

Prerequisites

  • Node.js 18+
  • An LLM API key (Anthropic, OpenAI, etc.)

Installation

Step 1: Connect to an MCP Server

@modelcontextprotocol/server-everything is a reference MCP server with sample tools like add, echo, and longRunningOperation.
If you’re connecting to an OAuth-protected HTTP server and already have a refresh token, pass refreshToken and clientId instead of a static access token:
The SDK will exchange the refresh token for an access token and automatically refresh it when needed.

Step 2: Execute Tools Directly

Call tools without an LLM—useful for unit tests:

Step 3: Create a HostRunner

Connect an LLM to your MCP tools:

Step 4: Run Prompts

Step 5: Write a Test

Step 6: Run Statistical Evaluations

Complete Example

Generate evals from the Inspector

You can also generate eval code directly from the MCPJam Inspector:
  1. Connect your MCP server in the Inspector
  2. Click the menu on the server card
  3. Select Copy markdown for evals
  4. Paste the copied markdown into an LLM (Claude, ChatGPT, etc.)
  5. The LLM will generate eval test code using @mcpjam/sdk
Copy markdown for evals menu option
The copied markdown is a ready-to-use prompt that includes your server’s capabilities and the full @mcpjam/sdk API reference, so the LLM has everything it needs to write your eval tests.
To save results to the MCPJam Evals dashboard, set MCPJAM_API_KEY to an MCPJam API key (sk_…) from Settings → API keys and add a mcpjam: { suiteName: "…" } block to run(). The retired project API keys (mcpjam_…) no longer work — see Saving Results.

Next Steps

Connecting to Servers

STDIO vs HTTP servers

Testing with LLMs

Prompting and result inspection

Running Evals

Statistical evaluations

API Reference

Complete API docs