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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcp-testing-kit

v0.2.0

Published

The testing library you need to test your MCP servers

Downloads

194

Readme

mcp-testing-kit Coverage Status NPM Version

The testing library you need to test your MCP servers.

Overview

mcp-testing-kit provides utilities to test Model Context Protocol (MCP) servers. It allows you to connect to an MCP server instance, send requests, receive notifications, and assert server behavior in your tests.

Features

  • Works with any testing framework (vitest, jest etc)
  • Lightweight, provides "just enough" utils to test an MCP server.
  • Typescript

Installation

$ npm i -D mcp-testing-kit

Example

Suppose you have an MCP server defined in example/basic/src/index.ts:

// mcp-server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const server = new McpServer({ name: 'simple-mcp-server', version: '1.0.0' });

server.tool(
  'add',
  'Add two numbers MCP style',
  { 
    a: z.number().describe('first number'), 
    b: z.number().describe('second number') 
  },
  async ({ name }) => ({
    messages: [
      { role: 'user', content: { type: 'text', text: String(a + b) } }
    ]
  })
);

export default server;

You can write a test using mcp-testing-kit like this:

// mcp-server.test.js
import server from "../src/index.js";
// Use your favorite testing framework.
import { describe, it, expect, afterEach } from "vitest";
import { connect, close } from "../../../index.js";

describe("Basic MCP server", () => {
  afterEach(async () => {
    await close(server);
  });

  it("Should return correct sum when `sum` is called", async () => {
    // Connect to the server and create a mock client.
    const client = await connect(server);
    const result = await client.callTool("greeting-template", { a: 10, b: 2 });
    expect(result.content[0].text).toEqual("12");
  });
});

How it works

  • Creates a dummy transport layer to connect to the MCP Server directly instead of relying on HTTP/SSE.
  • Provides abstractions for invoking the tools/resources/prompts directly on the server.

API

connect(server: Server)

Connects to an MCP server instance and returns a client with the following methods:

| Method | Signature | Description | |--------|-----------|-------------| | listTools | (): Promise<ListToolsResult> | List all tools registered on the server. | | callTool | (tool: string, params?: any): Promise<any> | Call a tool by name with optional parameters. | | listResources | (): Promise<ListResourcesResult> | List all resources registered on the server. | | listPrompts | (): Promise<ListPromptsResult> | List all prompts registered on the server. | | getPrompt | (prompt: string, params?: any): Promise<any> | Get a prompt by name with optional parameters. | | onNotification | (cb: (message: JSONRPCMessage) => void): void | Register a callback for notifications from the server. | | onError | (cb: (message: JSONRPCMessage) => void): void | Register a callback for error messages from the server. | | onProgress | (cb: (message: JSONRPCMessage) => void): void | Register a callback for progress notifications from the server. | | sendToServer | (message: Request): Promise<any> | Send a raw JSON-RPC request to the server. |

close(server: Server)

Closes the MCP server instance.

More Examples

See example/basic for a full-featured MCP server and corresponding tests.

License

MIT