Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

MCP Server Testing

БесплатноБез исполняемых скриптовНе проверен

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

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

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:
Полный SKILL.md на GitHub

Установить MCP Server Testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл MCP Server Testing?

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.

Как установить скилл MCP Server Testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл MCP Server Testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить MCP Server Testing с