# create_spec_for_function

Generate a functional-requirements spec (.3tg.md) scoped to a single exported function or React component. Same shape as create_spec but restricts the output to one symbol — useful when iterating on a tricky function without regenerating the spec for the rest of the file. IMPORTANT — never hand-author a .3tg.md yourself. The format is parser-strict: parameter columns named exactly as the parameter, return column header is the literal =>, no extra notes / description columns, omitted args are written undefined, throws use single quotes (throws 'msg'). Always call this tool to emit the scaffold; the user can then edit rows. Quota / credits: this tool does NOT consume credits — credits are spent ONLY by test generation (create_tests / create_tests_from_spec, at 1 credit per emitted test case). Spec generation is free. 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.

Agent View of the PolicyLayer registry record for `create_spec_for_function`. HTML page: https://policylayer.com/tools/dev-3tg-mcp/create-spec-for-function

## Facts

- Tool: `create_spec_for_function`
- Server: 3TG Test Generation (`https://mcp.3tg.dev/mcp`) — https://policylayer.com/tools/dev-3tg-mcp.md
- Homepage: https://github.com/https://mcp.3tg.dev/mcp
- Risk category: Write (Medium risk)
- Registry record: grade D, identity unverified
- Server auth posture: open
- Server rate-limited: no
- Parameters: 7 (4 required)
- Recommended policy verdict: Rate-limited

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `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 | no | Subset of .3tg/settings.json relevant to this tool. |
| `cliConfig` | object | no | 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 | no | 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 or React component to scope the spec to. Forwarded to 3TG as `-f <functionName>`. Use `default` for default exports. |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "create_spec_for_function",
    "arguments": {
      "clientId": "<clientId>",
      "fileName": "<fileName>",
      "sourceCode": "<sourceCode>",
      "functionName": "<functionName>"
    }
  }
}
```

## Why create_spec_for_function is rated Medium

The tool creates or generates a specification document scoped to a function or component. While it produces structured output that gets written to a file, the operation is reversible (specs can be regenerated or deleted), there are no side effects on external systems, no code execution occurs, and no data is destructively modified.

From the tool's own definition: "Tool generates and creates a functional-requirements spec file (`.3tg.md`). The description states it generates output and the name contains `create_`. This is a content generation tool that produces new files/specifications."

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

## Use case

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

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches 3TG Test Generation:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "create_spec_for_function": {
      "limits": [
        {
          "counter": "create_spec_for_function_rate",
          "window": "minute",
          "max": 30,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on 3TG Test Generation (9)

- `get_client_info` — Read — https://policylayer.com/tools/dev-3tg-mcp/get-client-info.md
- `help` — Read — https://policylayer.com/tools/dev-3tg-mcp/help.md
- `validate_config` — Read — https://policylayer.com/tools/dev-3tg-mcp/validate-config.md
- `validate_spec` — Read — https://policylayer.com/tools/dev-3tg-mcp/validate-spec.md
- `create_agent_instructions` — Write — https://policylayer.com/tools/dev-3tg-mcp/create-agent-instructions.md
- `create_mock_for_function` — Write — https://policylayer.com/tools/dev-3tg-mcp/create-mock-for-function.md
- `create_spec` — Write — https://policylayer.com/tools/dev-3tg-mcp/create-spec.md
- `create_tests` — Write — https://policylayer.com/tools/dev-3tg-mcp/create-tests.md
- `create_tests_from_spec` — Write — https://policylayer.com/tools/dev-3tg-mcp/create-tests-from-spec.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=dev-3tg-mcp · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/dev-3tg-mcp
