MCP Server Testing
БесплатноБез исполняемых скриптовНе проверенComprehensive testing patterns for Model Context Protocol servers including tool validation, transport testing, schema verification, and end-to-end MCP…
от 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
- Transport-layer isolation -- Test stdio and SSE transports independently before testing full server behavior to isolate transport-specific bugs from business logic issues.
- Schema-first validation -- Every MCP tool must have its input and output schemas validated against the JSON Schema specification before testing functional behavior.
- Stateful conversation testing -- MCP servers maintain session state; tests must verify correct behavior across multi-turn interactions including context window management and resource lifecycle.
- 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.
- Tool invocation fidelity -- Validate that tool calls produce deterministic results for identical inputs, handle edge cases gracefully, and respect timeout constraints.
- Resource lifecycle management -- Test resource creation, reading, updating, subscription, and cleanup to ensure no resource leaks occur during server operation.
- 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:
Установить 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-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic