extending-function-params

A set of coding instructions for adding or changing parameters accepted by a function.

In plain words
What is it for?
Use it when adding parameters to a TypeScript function, including validation, optional values, null handling, and documentation.
Why use it?
It keeps the parameter definition, function code, and instructions shown to the agent in sync.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/commercetools/commerce-mcp/extending-function-params
Clone the repo
git clone --depth 1 https://github.com/commercetools/commerce-mcp

Made for: Cursor.

Per session 600 This file is loaded in full into every session.
When invoked 600 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00600 $0.00600
Opus 5 $0.00300 $0.00300
Sonnet 5 $0.00120 $0.00120
Haiku 4.5 $0.00060 $0.00060

Measured yesterday against content hash 3c7de024b27d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

extending-function-params 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 yesterday.

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.

Origin

This is a copy

100% identical to extending-function-params — 0 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.

.cursor/rules/extending-function-params.mdc · 87 lines

What it actually says


description: Description: Steps to add or update parameters passed into a function globs: alwaysApply: false

Always follow these steps in order:

  1. Parameter Schema Update:

    • Locate the parameters file (usually typescript/src/shared/(namespace)/parameters.ts)
    • Add new parameters to the Zod schema
    • For each parameter:
      • Define the correct type (e.g., z.number(), z.array(z.string()))
      • Add appropriate validations (e.g., .min(), .max())
      • Mark as .optional() if not required
      • Add .describe() with clear documentation
      • Include examples in the description for complex types
  2. Function Implementation Update:

    • Locate the function file (usually typescript/src/shared/(namespace)/functions.ts)
    • Add new parameters to the queryArgs object
    • Use spread operator with null checks for optional params
    • Format: ...(params.newParam && {newParam: params.newParam})
    • Remove any outdated comments
  3. Documentation Update:

    • Locate the prompts file (usually named typescript/src/shared/(namespace)/prompts.ts)
    • Update the function's prompt string
    • For each parameter add:
      • Parameter name
      • Type information
      • Optional/required status
      • Default value if any
      • Valid range if applicable
      • Example usage for complex types
  4. Test Coverage Update:

    • Locate the test file (usually typescript/src/shared/(namespace)/test/functions.test.ts)
    • Add/update test cases:
      • Test with default parameters
      • Test with all new parameters
      • Test error scenarios
    • Verify all parameters are correctly passed to the API
    • Ensure proper mock setup and assertions
  5. Verification:

    • Ensure all files are consistent with each other
    • Parameter types match between schema and tests
    • Examples in prompts match test cases
    • All optional parameters handle undefined cases
    • Error handling is properly tested

Example: When adding 'offset' parameter:

  1. In parameters.ts:

    offset: z
      .number()
      .int()
      .min(0)
      .optional()
      .describe('The number of items to skip before starting to collect the result set.')
    
  2. In functions.ts:

    queryArgs: {
      ...(params.offset && {offset: params.offset}),
    }
    
  3. In prompts.ts:

    - offset (int, optional): The number of items to skip before starting to collect the result set.
    
  4. In functions.test.ts:

    it('should list products with all query parameters', async () => {
      const params = {
        offset: 40,
        // other params...
      };
      // test implementation
    });
    
Changes

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.

  1. yesterday First seen · 87 lines · 600 tokens per session scan A 3c7de024b27d

Subscribe to this mod's changes

extending-function-params is a cursor rule published in the GitHub repository commercetools/commerce-mcp (4 stars, last pushed 21d ago), licensed MIT. It adds 600 tokens to every session, about $0.0030 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to extending-function-params, differing in 0 lines, and is treated as a copy.