Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

MCP Server Testing

FreeNo executable scriptsNot checked

Comprehensive testing patterns for Model Context Protocol servers including tool validation, transport testing, schema verification, and end-to-end MCP…

PramodDuttaby PramodDutta★ 253 GitHub stars

About this skill

MCP Server Testing Skill

You are an expert in testing Model Context Protocol (MCP) servers. When the user asks you to write tests for MCP servers, validate MCP tools, test transport layers, or verify MCP integrations, follow these detailed instructions to produce comprehensive, production-ready test suites.

Core Principles

  1. Transport-layer isolation -- Test stdio and SSE transports independently before testing full server behavior to isolate transport-specific bugs from business logic issues.
  2. Schema-first validation -- Every MCP tool must have its input and output schemas validated against the JSON Schema specification before testing functional behavior.
  3. Stateful conversation testing -- MCP servers maintain session state; tests must verify correct behavior across multi-turn interactions including context window management and resource lifecycle.
  4. Error boundary coverage -- Test every error code defined in the MCP specification including parse errors, invalid requests, method not found, invalid params, and internal errors.
  5. Tool invocation fidelity -- Validate that tool calls produce deterministic results for identical inputs, handle edge cases gracefully, and respect timeout constraints.
  6. Resource lifecycle management -- Test resource creation, reading, updating, subscription, and cleanup to ensure no resource leaks occur during server operation.
  7. Protocol compliance verification -- Ensure all JSON-RPC 2.0 message formats, capability negotiation, and protocol version handshakes conform to the MCP specification.

Project Structure

tests/
  mcp/
    unit/
      tools/
        tool-schema.test.ts
        tool-execution.test.ts
        tool-error-handling.test.ts
      resources/
        resource-read.test.ts
        resource-subscribe.test.ts
        resource-templates.test.ts
      prompts/
        prompt-list.test.ts
        prompt-get.test.ts
        prompt-arguments.test.ts
    integration/
      transport/
        stdio-transport.test.ts
        sse-transport.test.ts
        streamable-http.test.ts
      session/
        initialization.test.ts
        capability-negotiation.test.ts
        multi-turn.test.ts
      lifecycle/
        server-startup.test.ts
        graceful-shutdown.test.ts
        reconnection.test.ts
    e2e/
      full-flow.test.ts
      concurrent-clients.test.ts
      error-recovery.test.ts
    fixtures/
      mock-tools.ts
      mock-resources.ts
      sample-requests.ts
      sample-responses.ts
    helpers/
      mcp-test-client.ts
      transport-factory.ts
      assertion-helpers.ts
  config/
    vitest.mcp.config.ts

MCP Test Client Helper

// tests/helpers/mcp-test-client.ts
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
import { spawn, ChildProcess } from 'child_process';

interface MCPTestClientOptions {
  transport: 'stdio' | 'sse';
  serverCommand?: string;
  serverArgs?: string[];
  serverUrl?: string;
  timeout?: number;
}

export class MCPTestClient {
  private client: Client;
  private serverProcess: ChildProcess | null = null;
  private transport: StdioClientTransport | SSEClientTransport;

  constructor(private options: MCPTestClientOptions) {
    this.client = new Client(
      { name: 'mcp-test-client', version: '1.0.0' },
      { capabilities: {} }
    );
  }

  async connect(): Promise<void> {
    if (this.options.transport === 'stdio') {
      const command = this.options.serverCommand || 'node';
      const args = this.options.serverArgs || ['dist/index.js'];

      this.transport = new StdioClientTransport({
        command,
        args,
        env: { ...process.env, NODE_ENV: 'test' },
      });
    } else {
      const url = this.options.serverUrl || 'http://localhost:3001/sse';
      this.transport = new SSEClientTransport(new URL(url));
    }

    await this.client.connect(this.transport);
  }

  async listTools(): Promise<any> {
    return this.client.request({ method: 'tools/list' }, {} as any);
  }

  async callTool(name: string, args: Record<string, unknown>): Promise<any> {
    return this.client.request(
      {
        method: 'tools/call',
        params: { name, arguments: args },
      },
      {} as any
    );
  }

  async listResources(): Promise<any> {
    return this.client.request({ method: 'resources/list' }, {} as any);
  }

  async readResource(uri: string): Promise<any> {
    return this.client.request(
      {
        method: 'resources/read',
        params: { uri },
      },
      {} as any
    );
  }

  async listPrompts(): Promise<any> {
    return this.client.request({ method: 'prompts/list' }, {} as any);
  }

  async getPrompt(name: string, args?: Record<string, string>): Promise<any> {
    return this.client.request(
      {
        method: 'prompts/get',
        params:
Full SKILL.md on GitHub

Install MCP Server Testing in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the MCP Server Testing skill do?

Comprehensive testing patterns for Model Context Protocol servers including tool validation, transport testing, schema verification, and end-to-end MCP integration testing with stdio and SSE transports.

How do I install the MCP Server Testing skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the MCP Server Testing skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare MCP Server Testing with