npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcpeak/runner

v0.11.3

Published

Declarative test runner for MCP servers with assertions and structured reports

Readme

English · 한국어

@mcpeak/runner

Runs declarative MCP test suites in order and provides assertion results along with structured events and reports.

  • Owners: @seodduu @endl24 @sunghoon0303 (① MCP server testing part)
  • Dependency: @mcpeak/core

Writing a suite

defineMcpSuite validates the suite at runtime while preserving TypeScript literal types. When you receive a suite as external JSON or as generated output, use validateMcpSuite.

import { defineMcpSuite } from "@mcpeak/runner";

export const suite = defineMcpSuite({
  schemaVersion: 1,
  id: "weather-server",
  name: "날씨 MCP 서버 테스트",
  defaultTimeoutMs: 10_000,
  cases: [
    {
      id: "weather-tool-exists",
      name: "날씨 조회 툴을 제공한다",
      operation: { type: "listTools" },
      assertions: [{ type: "toolExists", tool: "get_weather" }],
    },
    {
      id: "weather-call-succeeds",
      name: "서울 날씨를 정상적으로 조회한다",
      operation: {
        type: "callTool",
        tool: "get_weather",
        input: { city: "서울" },
      },
      assertions: [
        { type: "isError", expected: false },
        {
          type: "structuredContentMatchesSchema",
          schema: {
            type: "object",
            required: ["temperature"],
            properties: { temperature: { type: "number" } },
          },
        },
      ],
    },
  ],
});

listTools can take toolExists, and callTool can take isError, bodyMatchesSchema, and structuredContentMatchesSchema. The last assertion leaves the existing text body extraction rule unchanged and checks only ToolResult.raw.structuredContent against the saved contract. Suites and run results are processed in suite order, and RunnerReport and RunnerEvent can be passed to JSON.stringify.

Execution and shutdown lifecycle

runSuite never closes the client injected into it. The side that starts the run must provide an idempotent shutdown controller holding exactly the same object as the client, and complete the shutdown with finalizeRunnerExecution.

import {
  finalizeRunnerExecution,
  runSuite,
  type McpClientShutdownController,
  type RunnerEvent,
} from "@mcpeak/runner";
import { suite } from "./weather-suite.js";

declare const shutdown: McpClientShutdownController;

const onEvent = (event: RunnerEvent) => {
  console.log(JSON.stringify(event));
};

const execution = runSuite({
  client: shutdown.client,
  suite,
  onEvent,
  redaction: {
    sensitiveKeys: ["sessionId"],
    sensitiveValues: [process.env.WEATHER_API_KEY ?? ""],
  },
  payloadLimits: {
    maxCaseBytes: 65_536,
    maxReportBytes: 1_048_576,
  },
  drainTimeoutMs: 5_000,
});

const report = await finalizeRunnerExecution({ execution, shutdown });

A case's timeoutMs takes priority if present; otherwise the suite's defaultTimeoutMs is used, and if neither is set, Runner's 10 second fallback. A timeout or an abort from an external AbortSignal stops the execution of the remaining cases.

execution.drain is a non-rejecting result that waits for pending MCP operations. The default deadline is 5_000ms, and the result is { status: "settled" } or { status: "deadlineExceeded", pendingOperations: 1 }. After drain completes, graceful close and force close are each limited independently, by default to 2_000ms. The controller must implement actual transport layer shutdown: process exit or kill for stdio, request abort or socket destroy for HTTP. Keep rejection handlers for MCP operations that finish late or reject in place for the lifetime of the controller.

drainTimeoutMs must be a finite integer in 1..60_000. closeTimeoutMs and forceCloseTimeoutMs must each be a finite integer in 1..10_000. Zero, non-finite numbers, negative numbers, and decimals throw a synchronous RangeError before the run.

Observed data and follow-up repair

Observer events and reports recursively mask default sensitive keys (authorization, cookie, password, secret, token, and so on). Callers can add sensitiveKeys and sensitiveValues. The default limits are 65,536 bytes per case and 1,048,576 bytes per report. Runner never saves events or reports automatically.

A RunnerReport keeps the sanitized suite and diagnostics of failed cases. So it can be converted into JSON-safe sanitized repair input and used in a follow-up repair flow that goes through user review. The original MCP calls use separately kept input, so no secrets are exposed in observer data.

Currently out of scope

  • generate provider or repair validator implementation
  • JUnit output and a Vitest adapter
  • Parallel execution

Compatibility with the previous API

createMcpTest(config, body) and toContainTool(result, name) are deprecated shims kept for minor version compatibility. They keep their existing signatures and the not implemented error as they are, and will not be removed before a major release. In new code, use the declarative defineMcpSuite and runSuite.