defprod-create-mcp-tests

Generates Vitest integration tests for MCP-surface user stories via the Model Context Protocol SDK.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/defprod1/defprod-skills --skill defprod-create-mcp-tests-defprod1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: defprod-create-mcp-tests
Source: https://github.com/defprod1/defprod-skills/tree/main/skills/defprod-create-mcp-tests
Command: npx skills add https://github.com/defprod1/defprod-skills --skill defprod-create-mcp-tests-defprod1

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @modelcontextprotocol/sdk, vitest.

What problem does it solve? Writing integration tests for an MCP server by hand is repetitive and error-prone: each user story's acceptance criteria must map to individual test cases, the harness must connect over streamable HTTP or SSE, and fixture users with API keys must be provisioned and cleaned up. This Skill automates that entire workflow against stories defined in DefProd. ## Core Features & Use Cases - Per-AC test generation: Creates one spec file per in-scope story and one test('ACn: ...') per acceptance criterion, exercised through the official @modelcontextprotocol/sdk client against a running MCP server. - Surface-aware filtering: Selects stories whose surface is mcp (explicit or inferred from the MCP-… story-key prefix) and skips UI, REST, and CLI stories with a logged reason. - Harness verification and reporting: Validates the Vitest config, MCP client helpers, and fixture-user provisioning, then runs the suite and produces a coverage summary classifying failures as test faults or product faults. - Use Case: Given a DefProd product with an MCP area containing ten stories, invoke the skill to generate ten spec files, run them with Vitest, and receive a per-story pass/fail coverage table with untestable criteria documented. ## Quick Start Ask your agent to run /defprod-create-mcp-tests with your product name and the MCP area key to generate and run integration tests for all MCP stories in that area.

Frequently Asked Questions about defprod-create-mcp-tests

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

FAQPage Schema
How do I generate integration tests for an MCP server?

Invoke the skill with a product name and area key; it fetches the area's user stories from DefProd, filters for MCP-surface stories, and writes one Vitest spec per story with one test per acceptance criterion using the official MCP SDK client.

How do I test MCP tools with the Model Context Protocol SDK?

Connect a client via StreamableHTTPClientTransport to the /mcp endpoint, then call client.callTool with the tool name and arguments. Tool errors return in the result envelope as isError: true rather than thrown exceptions, so assert on the result shape.

Does this skill support SSE transport for MCP testing?

Yes, it provides an SSE client helper connecting to /mcp/sse and /mcp/messages, but SSE is used only when an acceptance criterion explicitly requires it. Streamable HTTP is the default transport for tool-call tests.

Can I use this skill for REST API or UI stories?

No, it only targets stories whose surface is mcp, set explicitly or inferred from the MCP- story-key prefix. Stories on other surfaces are skipped with a log line directing you to the sibling API, UI, or CLI test skills.

Why do MCP tests need a fixture user and API key?

The MCP server forwards an API key to authenticate tool calls, so each test provisions a throwaway user and key through the backend signup and createApiKey flow. Cleanup happens via direct database deletion in a finally block.

What happens when an acceptance criterion is untestable via MCP?

Criteria like documentation completeness or file-on-disk checks that cannot be exercised through the MCP harness get no test() call. They are documented in the spec file header with the reason and listed in the final coverage summary.