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

@mcp-contracts/test

v0.5.0

Published

Contract conformance testing for MCP servers

Readme

@mcp-contracts/test

Contract conformance testing for MCP servers. Verify that a live server matches its .mcpc.json contract — schema conformance, boundary inputs, and behavioral assertions.

Install

npm install @mcp-contracts/test

CLI

Test any MCP server against a contract:

# Stdio server
mcp-test run contract.mcpc.json --command node --args server.js

# HTTP server
mcp-test run contract.mcpc.json --url http://localhost:3000/mcp

# With options
mcp-test run contract.mcpc.json --command node --args server.js \
  --allow-extra-tools \
  --skip-tools dangerous_tool \
  --format terminal

Exit codes: 0 = all pass, 1 = failures, 2 = error.

Library Usage

import {
  runContractTests,
  formatTestTerminal,
} from "@mcp-contracts/test";

const report = await runContractTests({
  contract,
  contractPath: "contract.mcpc.json",
  server: { transport: "stdio", command: "node", args: ["server.js"] },
});

console.log(formatTestTerminal(report));
// 57 tests: 57 passed (0.1s)

Schema Conformance

Compares live server schemas against the contract using the diff engine. Any breaking or warning deviation is a failure.

import { connectToServer, closeConnection } from "@mcp-contracts/test";
import { runSchemaConformance } from "@mcp-contracts/test";

const connection = await connectToServer({
  transport: "stdio",
  command: "node",
  args: ["server.js"],
});

const results = await runSchemaConformance(connection, contract, {
  allowExtraTools: true,
  ignoreDescriptions: false,
  skipTools: ["internal_tool"],
});

await closeConnection(connection);

Boundary Input Testing

Auto-generates edge case inputs from each tool's JSON Schema and verifies the server handles them gracefully (no crashes or timeouts).

import { runBoundaryTests } from "@mcp-contracts/test";

const results = await runBoundaryTests(connection, contract, {
  maxStringSize: 10000,
  callTimeoutMs: 5000,
  skipTools: ["slow_tool"],
  customInputs: {
    create_contact: [{ name: "", email: "not-an-email" }],
  },
});

Generated test categories: empty strings, special characters, oversized payloads, zero/negative numbers, missing optional fields, missing required fields, min/max boundary values.

Behavioral Assertions

User-defined predicate functions that validate tool outputs:

import { runPredicateAssertions } from "@mcp-contracts/test";

const results = await runPredicateAssertions(connection, [
  {
    toolName: "get_contact",
    description: "Returns a contact with an ID",
    input: { id: "c_001" },
    assert: (result) => {
      if (!result.text) return false;
      const data = JSON.parse(result.text);
      return typeof data.id === "string";
    },
  },
]);

LLM-as-Judge

The judge interface is pluggable — bring your own LLM client:

import { runJudgeAssertions } from "@mcp-contracts/test";

const results = await runJudgeAssertions(connection, [
  {
    toolName: "search_contacts",
    description: "Returns relevant results",
    input: { query: "Jane" },
    expectation: "Results should contain contacts matching 'Jane'",
    judge: async ({ output, expectation }) => {
      // Use any LLM client here
      const response = await myLLM.evaluate(output.text, expectation);
      return { pass: response.matches, reason: response.explanation };
    },
  },
]);

Vitest/Jest Integration

Custom matchers for existing test suites:

import { expect, describe, it, beforeAll, afterAll } from "vitest";
import { setupMatchers, createTestServer } from "@mcp-contracts/test/matchers";

setupMatchers(expect);

const server = createTestServer({
  transport: "stdio",
  command: "node",
  args: ["server.js"],
});

beforeAll(() => server.connect());
afterAll(() => server.disconnect());

describe("contract", () => {
  it("conforms to contract", async () => {
    await expect(server.config).toConformToContract(contract);
  });

  it("handles boundary inputs", async () => {
    await expect(server.config).toHandleBoundaryInputs(contract);
  });
});

Output Formats

All three output formats are supported:

import {
  formatTestJson,
  formatTestTerminal,
  formatTestMarkdown,
} from "@mcp-contracts/test";

formatTestTerminal(report); // Colored terminal output
formatTestJson(report);     // Pretty-printed JSON
formatTestMarkdown(report); // GitHub-compatible markdown

mcp-contracts is an open-source project (MIT license). It's community tooling for the MCP ecosystem, not affiliated with Anthropic or the MCP project. Contributions and feedback are welcome.

License

MIT