New Your team’s decisions, in one playbook every coding agent works from. Never answer your agent twice

create_mock_for_function

Generate a Jest manual mock file for a specific exported function. 3TG writes the mock to <srcDir>/__mocks__/<basename>.<ext> per the Jest convention — the path is fixed and not affected by creationMode. Use this when isolating a downstream test from a known dependency. AI enrichment is on by def...

SERVER3TG Test Generation SOURCEhttps://mcp.3tg.dev/mcp
Medium RISK CLASS
Category Write
Parameters 74 required
Recommended Rate-limitedsee the rule below
Registry record Grade D, identity unverified Pull the record →

This record as markdown: /tools/dev-3tg-mcp/create-mock-for-function.md

What create_mock_for_function does on 3TG Test Generation

AI agents use create_mock_for_function 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.

ParameterTypeRequiredDescription
clientId string Yes The 3tg.dev client ID.
fileName string Yes Path of the source file relative to the user's project root.
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.
functionName string Yes Name of the exported function to mock. Forwarded as `-f <functionName>`.

Parameters from the server's own tool schema.

Why create_mock_for_function is rated Medium

This tool creates and writes a new file to the project's mock directory structure. While file creation is reversible (files can be deleted), it modifies the project's file system state and could overwrite existing mock files if re-run. This makes it a Write operation rather than Read.

From the tool's definition The tool writes a mock file to disk at a fixed path `<srcDir>/__mocks__/<basename>.<ext>` per Jest convention. The description explicitly states it 'writes the mock' to a specific file system location.

Risk signalsAccepts file system path (fileName) · High parameter count (12 properties) · Admin/system-level operation

Questions about create_mock_for_function

What does the create_mock_for_function tool do? +

Generate a Jest manual mock file for a specific exported function. 3TG writes the mock to <srcDir>/__mocks__/<basename>.<ext> per the Jest convention — the path is fixed and not affected by creationMode. Use this when isolating a downstream test from a known dependency. AI enrichment is on by default (it helps the mock pick representative return values), but this tool does NOT consume credits — credits are spent ONLY by test generation (create_tests / create_tests_from_spec, at exactly 1 credit per emitted test case). Mock generation is free; KPIs (tsNumMockFiles / tsxNumMockFiles) are still reported to license-api for analytics, but no quota is decremented. 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.

What parameters does create_mock_for_function accept? +

create_mock_for_function accepts 7 parameters: clientId, fileName, settings, cliConfig, moduleType, sourceCode, functionName. Required: clientId, fileName, sourceCode, functionName. The full parameter table on this page comes from the server's own tool schema.

How do I enforce a policy on create_mock_for_function? +

Register the 3TG Test Generation MCP server in PolicyLayer and add a rule for create_mock_for_function: 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.

What risk level is create_mock_for_function? +

create_mock_for_function is a Write tool with medium risk. Write tools should be rate-limited to prevent accidental bulk modifications.

Can I rate-limit create_mock_for_function? +

Yes. Add a rate_limit block to the create_mock_for_function 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.

How do I block create_mock_for_function completely? +

Set action: deny in the PolicyLayer policy for create_mock_for_function. 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.

What MCP server provides create_mock_for_function? +

create_mock_for_function 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.

// THE MCP REGISTRY

PolicyLayer tracks 44,603 MCP servers and 515,000+ tools.

Every server has a live record: who publishes it, whether it answers without auth, its risk grade, every tool classified, the recommended policy. This page is one line of 3TG Test Generation's. Pull the full record:

Teams ship this data inside their own products. See what a licence covers →

// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.