taliawedged117/census-mcp-server/add-test
Claude Code and agent skill by taliawedged117/census-mcp-server
- community
Checking that the SKILL.md file is still in the repository.
Scaffold a test file for an existing tool, resource, or service. Use when the user asks to add tests, improve coverage, or when a definition exists without a matching test file.
Install
npx vskill@latest install taliawedged117/census-mcp-server/add-testSKILL.md
The same SKILL.md was published earlier as ficaviolaodorata520/met-museum-mcp-server/add-test.
Context
Tests use Vitest and createMockContext from @cyanheads/mcp-ts-core/testing. If the repo already has tests, match the existing layout. If the repo has no existing tests, create a root tests/ directory that mirrors the src/ structure (e.g. tests/mcp-server/tools/definitions/echo.tool.test.ts for src/mcp-server/tools/definitions/echo.tool.ts).
For the full createMockContext API and testing patterns, read:
skills/api-testing/SKILL.md
Steps
- Identify the target — which tool, resource, or service needs tests
- Read the source file — understand the handler's logic, input/output schemas, error paths, and which
ctxfeatures it uses - Create the test file in the repo's existing test layout — search for existing
*.test.tsfiles to confirm whether tests are colocated with source or under a roottests/directory - Write test cases covering happy path, error paths, and edge cases
- Run `bun run test` to verify
- Run `bun run devcheck` to verify lint, types, and MCP definitions
Determining What to Test
Read the handler and identify:
| Aspect | Test Strategy | |
|---|---|---|
| Happy path | Valid input → expected output. Include at least one. | |
| Input variations | Optional fields omitted, defaults applied, boundary values | |
| Error paths | Invalid state, missing resources, service failures → correct error thrown | |
| `ctx.state` usage | Use createMockContext({ tenantId: 'test' }) to enable storage | |
| `ctx.elicit` / `ctx.sample` | Mock with vi.fn(), also test the absent case (undefined) | |
| `ctx.progress` | Use createMockContext({ progress: true }) for task tools | |
| `ctx.fail` (typed contract) | Definitions with errors[] need fail attached to the mock ctx — createMockContext({ errors: myTool.errors }) does it for you. Assert on data.reason (stable per-contract entry), not just code. | |
| `format` function | Test separately if defined — it's pure, no ctx needed. Verify it renders the IDs and fields the model needs, not just a count or title. For projection-style tools, test non-default field selections. | |
| Sparse upstream payloads | For third-party API integrations, build a fixture with omitted fields. Assert normalized output still validates and format() preserves unknown values instead of inventing facts. | |
| Form-client payloads | If handler has optional fields: test with empty-string inner values (form clients send "" instead of undefined). Assert handler doesn't break or produce invalid output. | |
| Auth scopes | Not tested at handler level (framework enforces) — skip |
Templates
Tool test
Resource test
Service test
If you need to test the accessor's "not initialized" guard, do it in a separate isolated-module test (vi.resetModules() before importing the service module). Don't mix that assertion into a suite that already calls init{{ServiceClass}}() in beforeEach().
Task tool test
For tools with task: true, use createMockContext({ progress: true }):
Prompt test
Fuzz Testing
For schema-heavy or input-validation-critical handlers, the framework ships fuzz helpers that generate valid + adversarial inputs from your Zod schemas via fast-check and assert handler invariants (no crashes, no prototype pollution, no stack-trace leaks):
Available helpers from @cyanheads/mcp-ts-core/testing/fuzz: fuzzTool, fuzzResource, fuzzPrompt, zodToArbitrary (custom property-based tests), adversarialArbitrary and ADVERSARIAL_STRINGS (targeted injection sets). Returns a FuzzReport you can assert against. Options: numRuns, numAdversarial, seed (reproducibility), timeout, ctx (MockContextOptions for stateful handlers).
Generating Tests from Schemas
When scaffolding tests for an existing handler, use the Zod schemas to generate meaningful test cases:
- Read `input` schema — identify required fields, optional fields with defaults, constrained types (enums, min/max, patterns)
- Read `output` schema — know what shape to assert against
- Happy path — construct the simplest valid input, assert output matches schema
- Defaults — omit optional fields, verify defaults are applied in the output
- Boundaries — if the schema has
.min(),.max(),.length(), test at the boundaries - Error paths — trace the handler logic for throw conditions, construct inputs that trigger each
- Sparse upstream fixtures — if the handler/service wraps a third-party API, add at least one fixture where upstream omits optional fields entirely. Assert that the output still validates and that
format()renders uncertainty honestly (Not available, omitted badge, etc.) instead of fabricating values.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/add-test/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/taliawedged117/census-mcp-server/add-test)