add-test — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited add-test (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Tests use Vitest and createMockContext from @cyanheads/mcp-ts-core/testing. Test files are colocated with their source: foo.tool.ts gets foo.tool.test.ts in the same directory.
For the full createMockContext API and testing patterns, read:
skills/api-testing/SKILL.md
ctx features it usesRead 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 |
| `format` function | Test separately if defined — it's pure, no ctx needed |
| Auth scopes | Not tested at handler level (framework enforces) — skip |
/**
* @fileoverview Tests for {{TOOL_NAME}} tool.
* @module mcp-server/tools/definitions/{{TOOL_NAME}}.test
*/
import { describe, expect, it } from 'vitest';
import { createMockContext } from '@cyanheads/mcp-ts-core/testing';
import { {{TOOL_EXPORT}} } from './{{tool-name}}.tool.js';
describe('{{TOOL_EXPORT}}', () => {
it('returns expected output for valid input', async () => {
const ctx = createMockContext();
const input = {{TOOL_EXPORT}}.input.parse({
// valid input matching the Zod schema
});
const result = await {{TOOL_EXPORT}}.handler(input, ctx);
expect(result).toMatchObject({
// expected output shape
});
});
it('throws on invalid state', async () => {
const ctx = createMockContext();
const input = {{TOOL_EXPORT}}.input.parse({
// input that triggers an error path
});
await expect({{TOOL_EXPORT}}.handler(input, ctx)).rejects.toThrow();
});
it('formats output correctly', () => {
const output = { /* mock output matching the output schema */ };
const blocks = {{TOOL_EXPORT}}.format!(output);
expect(blocks).toHaveLength(1);
expect(blocks[0].type).toBe('text');
});
});/**
* @fileoverview Tests for {{RESOURCE_NAME}} resource.
* @module mcp-server/resources/definitions/{{RESOURCE_NAME}}.test
*/
import { describe, expect, it } from 'vitest';
import { createMockContext } from '@cyanheads/mcp-ts-core/testing';
import { {{RESOURCE_EXPORT}} } from './{{resource-name}}.resource.js';
describe('{{RESOURCE_EXPORT}}', () => {
it('returns data for valid params', async () => {
const ctx = createMockContext({ tenantId: 'test-tenant' });
const params = {{RESOURCE_EXPORT}}.params.parse({
// valid params matching the Zod schema
});
const result = await {{RESOURCE_EXPORT}}.handler(params, ctx);
expect(result).toBeDefined();
});
it('throws when resource not found', async () => {
const ctx = createMockContext({ tenantId: 'test-tenant' });
const params = {{RESOURCE_EXPORT}}.params.parse({
// params for a non-existent resource
});
await expect({{RESOURCE_EXPORT}}.handler(params, ctx)).rejects.toThrow();
});
it('lists available resources', async () => {
const listing = await {{RESOURCE_EXPORT}}.list!();
expect(listing.resources).toBeInstanceOf(Array);
expect(listing.resources.length).toBeGreaterThan(0);
for (const r of listing.resources) {
expect(r).toHaveProperty('uri');
expect(r).toHaveProperty('name');
}
});
});/**
* @fileoverview Tests for {{SERVICE_NAME}} service.
* @module services/{{domain}}/{{SERVICE_NAME}}.test
*/
import { beforeEach, describe, expect, it } from 'vitest';
import { createMockContext } from '@cyanheads/mcp-ts-core/testing';
import { init{{ServiceClass}}, get{{ServiceClass}} } from './{{service-name}}-service.js';
describe('{{ServiceClass}}', () => {
beforeEach(() => {
// Re-initialize with fresh config/storage per suite
init{{ServiceClass}}(mockConfig, mockStorage);
});
it('performs the expected operation', async () => {
const ctx = createMockContext({ tenantId: 'test-tenant' });
const service = get{{ServiceClass}}();
const result = await service.doWork('input', ctx);
expect(result).toBeDefined();
});
it('throws when not initialized', () => {
// Reset the singleton — this is the only case where accessing
// the module internals is acceptable
expect(() => get{{ServiceClass}}()).toThrow(/not initialized/);
});
});For tools with task: true, use createMockContext({ progress: true }):
it('reports progress during execution', async () => {
const ctx = createMockContext({ progress: true });
const input = {{TOOL_EXPORT}}.input.parse({ count: 3, delayMs: 10 });
await {{TOOL_EXPORT}}.handler(input, ctx);
const progress = ctx.progress as ContextProgress & {
_total: number;
_completed: number;
_messages: string[];
};
expect(progress._total).toBe(3);
expect(progress._completed).toBe(3);
});
it('respects cancellation', async () => {
const controller = new AbortController();
const ctx = createMockContext({ progress: true, signal: controller.signal });
const input = {{TOOL_EXPORT}}.input.parse({ count: 100, delayMs: 10 });
// Abort after a short delay
setTimeout(() => controller.abort(), 50);
const result = await {{TOOL_EXPORT}}.handler(input, ctx);
// Should have stopped early
expect(result.finalCount).toBeGreaterThan(0);
});When scaffolding tests for an existing handler, use the Zod schemas to generate meaningful test cases:
.min(), .max(), .length(), test at the boundariessrc/.../{{name}}.test.ts (colocated with source)@fileoverview and @module header present.rejects.toThrow())format function tested if definedcreateMockContext options match handler's ctx usage (tenantId, progress, elicit, sample)beforeEach if handler depends on a service singletonnpm test passesbun run devcheck passes~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.