feat: add per-tool customerContext parameter for dynamic customer scoping#129
Open
venotar wants to merge 2 commits into
Open
feat: add per-tool customerContext parameter for dynamic customer scoping#129venotar wants to merge 2 commits into
venotar wants to merge 2 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
customerContextas an optional string parameter to all 36 MCP tool schemas, enabling clients to dynamically scope API calls to a specific customer without relying on theCUSTOMER_CONTEXTenvironment variablecustomerContextPropertyspread; Zod-based tools get automatic injection viazodToMcpInputSchema()customerContextwith correct type and descriptionRefs #114
Test plan
customerContextSchema.test.tsverifies all 36 tools havecustomerContextas optional stringschema.test.tsaccounts for injected property without breaking existing assertionschangeCustomertool (which has its owncustomerContextwith 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
customerContextstring parameter to MCP toolinputSchemas to let clients scope API calls per request rather than relying on a global env var.Centralizes the schema definition via
CUSTOMER_CONTEXT_DESCRIPTION/customerContextPropertyfor hand-written schemas, and updateszodToMcpInputSchema()to injectcustomerContextinto generated JSON Schema output without changing Zod parsing.Adds/updates tests to enforce consistent
customerContextpresence/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.