Skip to content

feat: add per-tool customerContext parameter for dynamic customer scoping#129

Open
venotar wants to merge 2 commits into
mainfrom
feat/per-tool-customer-context
Open

feat: add per-tool customerContext parameter for dynamic customer scoping#129
venotar wants to merge 2 commits into
mainfrom
feat/per-tool-customer-context

Conversation

@venotar

@venotar venotar commented Mar 20, 2026

Copy link
Copy Markdown

Summary

  • Adds customerContext as an optional string parameter to all 36 MCP tool schemas, enabling clients to dynamically scope API calls to a specific customer without relying on the CUSTOMER_CONTEXT environment variable
  • Inline JSON tools use a shared customerContextProperty spread; Zod-based tools get automatic injection via zodToMcpInputSchema()
  • Parameter is injected into JSON Schema output only (not Zod parsing), preventing leakage into API request bodies
  • Cross-cutting test validates all registered tools expose customerContext with correct type and description

Refs #114

Test plan

  • All 447 existing tests pass across 26 test files
  • New customerContextSchema.test.ts verifies all 36 tools have customerContext as optional string
  • Updated schema.test.ts accounts for injected property without breaking existing assertions
  • changeCustomer tool (which has its own customerContext with different semantics) is not overwritten

🤖 Generated with Claude Code


Note

Medium Risk
Broad, cross-cutting schema changes across many MCP tools may affect client tool discovery/validation and request shaping, though the parameter is additive and covered by new tests.

Overview
Adds a new optional customerContext string parameter to MCP tool inputSchemas to let clients scope API calls per request rather than relying on a global env var.

Centralizes the schema definition via CUSTOMER_CONTEXT_DESCRIPTION/customerContextProperty for hand-written schemas, and updates zodToMcpInputSchema() to inject customerContext into generated JSON Schema output without changing Zod parsing.

Adds/updates tests to enforce consistent customerContext presence/description across tools and to relax schema-structure comparisons to account for the injected property.

Written by Cursor Bugbot for commit 02e8c01. This will update automatically on new commits. Configure here.

Omar Buhidma and others added 2 commits March 20, 2026 13:31
…ping

Add customerContext as an optional string parameter to all 36 MCP tool
schemas, allowing clients to scope API calls to a specific customer
without relying on the CUSTOMER_CONTEXT environment variable.

Implementation uses two mechanisms:
- Inline JSON tools: spread customerContextProperty into inputSchema
- Zod-based tools: auto-inject in zodToMcpInputSchema() output

The parameter is injected into JSON Schema only (not Zod parsing), so it
never leaks into API request bodies via handler destructuring.

Includes cross-cutting test verifying all registered tools expose
customerContext with correct type and description.

Refs #114

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant