Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add cyanheads/mcp-ts-core --skill add-testgit clone --depth 1 https://github.com/cyanheads/mcp-ts-coreWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/cyanheads/mcp-ts-core/add-test)<a href="https://agentmods.dev/skills/cyanheads/mcp-ts-core/add-test"><img src="https://agentmods.dev/badge/skills/cyanheads/mcp-ts-core/add-test/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/cyanheads/mcp-ts-core/add-test"><img src="https://agentmods.dev/badge/skills/cyanheads/mcp-ts-core/add-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00041 | $0.04000 |
| Opus 5.5 | $0.00016 | $0.01600 |
| Sonnet 5.5 | $0.00008 | $0.00800 |
| Haiku 4.5 | $0.00004 | $0.00400 |
Grade A, and why
add-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
This is a copy
100% identical to add-test — 7 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 324 lines — stays where its author put it; the contents beside it link to each section on GitHub.
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:
framework-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 testto verify - Run
bun run devcheckto 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 |
Available on any mock context (tenant 'default' unless { tenantId } says otherwise). It runs the production storage path, so use storage-legal keys (cache/v1/abc, never cache:v1:abc) and assert TTL expiry with fake timers. |
ctx.requestInput / ctx.inputs |
Two rounds. First round: assert the handler throws the input-required signal (.rejects.toSatisfy(isInputRequiredSignal)), or catch it and assert on error.result.inputRequests. Second round: seed createMockContext({ inputResponses }) and assert the handler completes. Cover the decline/cancel branch too. A consent gate that redeems a ctx.state record also needs that record written into the second round's context, and a replay case showing the spent record asks again (see api-testing § Mock inputs). |
ctx.clientCapabilities |
When the handler asks only if the client declared a capability, seed createMockContext({ clientCapabilities }) with and without it and assert it asks in one case and falls through in the other. Seeding it also filters inputResponses to the declared kinds, as production does. |
ctx.signal |
Pass createMockContext({ signal: controller.signal }) and assert a long loop stops early rather than running to completion. |
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. |
| Error recovery on both surfaces | Use runToolContract with a fake I/O boundary. Assert the structured reason/hint and the text content; any candidates, IDs or field names the hint tells the caller to use must be present in text too. A hint saying “choose a listed value” is unusable if the list exists only in custom error data. |
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 | Preserve real payload variants: omitted fields, explicit nulls, and identity flags or IDs present when display names are absent. Assert normalization uses the available evidence, output validates, and format() preserves unknown values instead of inventing facts. |
| Runtime package identity | For a built-server handshake, compare the advertised version with package.json; a hardcoded release number makes every version bump fail an unrelated integration test. |
| 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 |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · +3 lines 1f728bf686d3
- 21d ago Changed 290612698262
- 27d ago Changed · +3 lines 41e580d90746
- 1mo ago Changed d4147ffbf280
- 1mo ago First seen · 318 lines · 41 tokens per session scan A 9ff05d2f4834
add-test is a skill published in the GitHub repository cyanheads/mcp-ts-core (152 stars, last pushed today), licensed Apache-2.0. It adds 41 tokens to every session and 4,000 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to add-test, differing in 7 lines, and is treated as a copy.
Other skills, from other repositories
api-testing
Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.
add-test
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.
api-testing
Testing patterns for MCP tool/resource handlers using createMockContext and Vitest. Covers mock context options, handler testing, McpError assertions, format testing, Vitest config setup, and test isolation conventions.
add-test
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.
add-test
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.
add-test
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.