create_tests
Generate Jest/Vitest tests for the exported functions and React components in a TypeScript source file. Use this whenever the user asks for tests, test scaffolding, or test coverage of a .ts or .tsx file. Returns the generated test (and any companion .3tg.md / __mocks__) file contents, with paths...
This record as markdown: /tools/dev-3tg-mcp/create-tests.md
What create_tests does on 3TG Test Generation
AI agents use create_tests to create or update resources in 3TG Test Generation, usually the action step of a workflow, after the agent has gathered context. Every call changes real data in your 3TG Test Generation environment.
| Parameter | Type | Required | Description |
|---|---|---|---|
clientId | string | Yes | The 3tg.dev client ID — sent as authentication to license-api for quota verification before generation and quota consumption / KPI recording after a successful |
fileName | string | Yes | Path of the source file relative to the user's project root, e.g. "src/foo/bar.ts". Used as both the 3TG positional argument and the sandbox-side location. |
settings | object | — | Subset of .3tg/settings.json relevant to this tool. |
cliConfig | object | — | Optional per-request 3TG CLI config. The agent assembles this from TWO disk locations and merges them (per-source wins on conflict) before forwarding the merged |
moduleType | string | — | Optional Node module type of the consumer project — the value of the `type` field in the project root's `package.json`. The agent reads that one field (only) an |
sourceCode | string | Yes | Full UTF-8 contents of the source file. |
Parameters from the server's own tool schema.
Why create_tests is rated Medium
The tool creates new test files and companion files in the user's `.3tg/` mirror directory. While it consumes credits for each test case generated, the core action is reversible file creation/writing (tests can be deleted or regenerated), not destructive or irreversible. It does not execute arbitrary code, delete data, move money, or trigger external side effects beyond file I/O.
From the tool's definition Tool generates test files (.ts, .tsx, .3tg.md, __mocks__) and returns file contents; description states 'Returns the generated test (and any companion .3tg.md / __mocks__) file contents'. This is file creation/modification — a Write operation.
Risk signalsAccepts file system path (fileName) · High parameter count (11 properties) · Admin/system-level operation
Attacks that exploit this kind of access
The rule that runs create_tests safely
PolicyLayer is an MCP gateway: it sits between your AI agents and 3TG Test Generation, and checks every tool call against a rule you set before the call runs. Nothing changes on the server itself. For create_tests, this is the rule to start with:
create_tests stays usable, but capped: an agent stuck in a loop can't make hundreds of changes a minute. Everything else on the server is denied unless you say otherwise.
The button opens the PolicyLayer dashboard: create your workspace, connect 3TG Test Generation, apply this rule, and every create_tests call is checked against it from then on.
Questions about create_tests
Generate Jest/Vitest tests for the exported functions and React components in a TypeScript source file. Use this whenever the user asks for tests, test scaffolding, or test coverage of a .ts or .tsx file. Returns the generated test (and any companion .3tg.md / __mocks__) file contents, with paths already translated to the user's .3tg/ mirror convention. Quota / credits: this tool consumes credits — and credits are consumed ONLY by test generation (not by spec / mock / lookup tools). The accounting is exactly 1 credit per generated test case (i.e. per test(...) / it(...) block 3TG emits inside the returned .test.ts / .test.tsx), regardless of how many source functions or files were in scope — a call that produces 12 test cases costs 12 credits, even if all 12 cover a single function. Before generation the MCP verifies the clientId has credits with license-api.coding-creed.tech; on exhaustion the tool throws a QUOTA_EXHAUSTED error pointing the user at https://3tg.dev. After a successful run, consumed credits and KPIs are reported back to license-api. Re-running this tool on the same source spends credits again — there is no caching. When the previous call returned enrichment.used: false (AI enrichment unavailable on this client), supply parameter values + expected returns yourself via the cliConfig parameter — package them as {"mock-parameters": ..., "function-returns": ...} (same shape AI enrichment would produce) and pass them on a retry call. Do NOT autonomously write .3tg/config.3tg.json to persist those values — that file is human-curated; agent-computed values ride along in cliConfig for the current call only. (Explicit user requests to edit the file are fine — handle those normally.) See the cliConfig parameter description below for the full pattern. CRITICAL POST-CALL ACTION — write returned files to disk: The MCP server does NOT touch the user's filesystem. It returns the generated file CONTENTS in the response's files array. After this tool returns, you MUST iterate over files and write each entry's content verbatim to its path using your native file-write capability (e.g. Write / edit_file / create_file — whatever your client exposes). Create parent directories as needed. Returned paths are project-root-relative and already translated to the .3tg/ mirror convention where applicable (e.g. specs land under .3tg/<source-path>.3tg.md; tests / mocks travel through unchanged). Write each path verbatim. Do NOT claim "Generated test file: <path>" unless you have actually written the file. The user will assume the MCP wrote it and waste time looking for a non-existent file. If you can't write for some reason (permission denied, no write capability in this client), return the contents inline in your message so the user can copy-paste them. Never report success silently when the write didn't happen. It is categorised as a Write tool in the 3TG Test Generation MCP Server, which means it can create or modify data. Consider rate limits to prevent runaway writes.
create_tests accepts 6 parameters: clientId, fileName, settings, cliConfig, moduleType, sourceCode. Required: clientId, fileName, sourceCode. The full parameter table on this page comes from the server's own tool schema.
Register the 3TG Test Generation MCP server in PolicyLayer and add a rule for create_tests: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches 3TG Test Generation. Nothing to install.
create_tests is a Write tool with medium risk. Write tools should be rate-limited to prevent accidental bulk modifications.
Yes. Add a rate_limit block to the create_tests rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the PolicyLayer policy for create_tests. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
create_tests is provided by the 3TG Test Generation MCP server (https://mcp.3tg.dev/mcp). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.
More on 3TG Test Generation, and thousands of servers like it.
This server
Across the catalogue