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

@context-pods/testing

v0.2.0

Published

Comprehensive testing and validation framework for Context-Pods MCP servers

Readme

@context-pods/testing

Comprehensive testing framework for MCP (Model Context Protocol) servers in the Context-Pods development suite.

npm version License: MIT

Overview

This package provides a complete testing solution for MCP servers, including:

  • Protocol compliance validation
  • Script wrapper testing
  • Integration testing utilities
  • Performance benchmarking
  • Test report generation

Installation

npm install --save-dev @context-pods/testing

Features

MCP Protocol Compliance Testing

Validate that your MCP server correctly implements the protocol:

import { validateMCPServer } from '@context-pods/testing';

const results = await validateMCPServer('./path/to/server', {
  checkTools: true,
  checkResources: true,
  checkProtocol: true,
  timeout: 30000,
});

console.log(results.isValid); // true/false
console.log(results.errors); // Array of validation errors

Script Wrapper Testing

Test wrapped scripts in multiple languages:

import { testScriptWrapper } from '@context-pods/testing';

const results = await testScriptWrapper('./my-script.py', {
  language: 'python',
  testCases: [
    {
      input: { arg1: 'value1' },
      expectedOutput: { result: 'expected' },
    },
  ],
});

Test Harness

Comprehensive testing harness for MCP communication:

import { TestHarness } from '@context-pods/testing';

const harness = new TestHarness({
  serverPath: './my-mcp-server',
  transport: 'stdio',
});

// Start the server
await harness.start();

// Test tool execution
const result = await harness.executeTool('my-tool', {
  param1: 'value1',
});

// Test resource fetching
const resource = await harness.fetchResource('resource://my-resource');

// Stop the server
await harness.stop();

Integration Testing

import { MCPTestSuite } from '@context-pods/testing';

const suite = new MCPTestSuite('My MCP Server Tests');

suite.addTest('Tool execution test', async (harness) => {
  const result = await harness.executeTool('calculate', {
    operation: 'add',
    a: 5,
    b: 3,
  });

  expect(result).toEqual({ result: 8 });
});

suite.addTest('Resource fetching test', async (harness) => {
  const resource = await harness.fetchResource('data://config');
  expect(resource.mimeType).toBe('application/json');
});

// Run all tests
const results = await suite.run();

Performance Benchmarking

import { benchmark } from '@context-pods/testing';

const results = await benchmark({
  serverPath: './my-mcp-server',
  iterations: 100,
  tools: ['tool1', 'tool2'],
  concurrent: 10,
});

console.log(results.averageResponseTime);
console.log(results.throughput);

Report Generation

Generate test reports in multiple formats:

import { generateReport } from '@context-pods/testing';

// HTML report
await generateReport(testResults, {
  format: 'html',
  outputPath: './test-report.html',
  includeGraphs: true,
});

// JUnit XML for CI/CD
await generateReport(testResults, {
  format: 'junit',
  outputPath: './junit.xml',
});

// Markdown for documentation
await generateReport(testResults, {
  format: 'markdown',
  outputPath: './test-results.md',
});

CLI Usage

The package includes a CLI for quick testing:

# Validate MCP compliance
npx @context-pods/testing validate ./my-server

# Test a wrapped script
npx @context-pods/testing test-wrapper ./script.py --language python

# Run a test suite
npx @context-pods/testing run ./test-suite.js

# Generate a report
npx @context-pods/testing report ./results.json --format html

Configuration

Create a .mcp-test.json file for test configuration:

{
  "defaultTimeout": 30000,
  "transport": "stdio",
  "validation": {
    "strict": true,
    "checkTools": true,
    "checkResources": true,
    "checkProtocol": true
  },
  "reporting": {
    "format": "html",
    "outputDir": "./test-reports"
  }
}

Writing Test Cases

Basic Test

import { describe, it, expect } from '@context-pods/testing';

describe('My MCP Server', () => {
  it('should execute the greeting tool', async (harness) => {
    const result = await harness.executeTool('greet', {
      name: 'World',
    });

    expect(result).toBe('Hello, World!');
  });
});

Advanced Test with Setup

import { TestSuite } from '@context-pods/testing';

const suite = new TestSuite({
  serverPath: './my-server',

  beforeAll: async (harness) => {
    // Global setup
    await harness.initialize();
  },

  beforeEach: async (harness) => {
    // Test-specific setup
    await harness.reset();
  },

  afterEach: async (harness) => {
    // Test cleanup
    await harness.cleanup();
  },

  afterAll: async (harness) => {
    // Global cleanup
    await harness.shutdown();
  },
});

Validation Schemas

The testing framework uses Zod schemas to validate MCP protocol compliance:

  • Tool definitions
  • Resource definitions
  • Request/response formats
  • Error handling
  • Protocol negotiation

Related Packages

License

MIT