api-testing

Automate MCP tool and resource handler tests with Vitest and mock contexts.

148|28|Updated Mar 20, 2025
One-click install
npx skills add https://github.com/cyanheads/mcp-ts-core --skill api-testing-cyanheads
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-testing
Source: https://github.com/cyanheads/mcp-ts-core/tree/main/skills/api-testing
Command: npx skills add https://github.com/cyanheads/mcp-ts-core --skill api-testing-cyanheads

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests target MCP tool/resource handlers to ensure correct behavior under a variety of mock contexts and error scenarios, enabling reliable, repeatable validation of tooling logic. These patterns cover mock context options, handler testing, MCP error assertions, formatting checks, and test isolation conventions to guide consistent test authoring.

Core Features & Use Cases

  • Provides a standardized mock context setup with Vitest-driven tests for MCP tooling components.
  • Demonstrates comprehensive testing patterns for unit and integration tests, including handler invocation, error handling, and formatting verification.
  • Includes guidelines for test isolation, fixture reuse, and deterministic test execution across MCP projects.

Quick Start

Install dependencies and run vitest to execute the MCP testing patterns and mock-context based tests.

Frequently Asked Questions about api-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test MCP tool handlers with mock context in Vitest?

Testing MCP tool handlers involves using mock context utilities within Vitest to automate unit and integration tests. This setup provides deterministic validation by standardizing mock contexts, verifying handler invocation, and checking error handling and formatting.

What is the best way to isolate MCP resource handler tests for repeatable validation?

The best way to isolate MCP resource handler tests is by applying test isolation conventions and reusing test fixtures. Using Vitest with mock context utilities ensures deterministic and repeatable validation of your tooling logic.

Do I need a TypeScript project layout to run MCP testing utilities?

Yes, a TypeScript project layout is required along with Vitest and the MCP testing utilities from @cyanheads/mcp-ts-core. These dependencies enable deterministic test execution and reusable fixtures for MCP tooling components.

How do I assert MCP errors and verify formatting in unit tests?

You assert MCP errors and verify formatting by applying specific testing patterns within your Vitest suite. These patterns guide consistent test authoring by covering mock context options, handler invocation, and formatting checks.

Can I use these mock context testing patterns for MCP integration tests?

Yes, the mock context testing patterns support both unit and integration tests for MCP tooling components. They provide comprehensive testing coverage including handler invocation, error handling, and formatting verification using Vitest.