Skip to content

prune unsupported properties from mcp schema for google#56

Merged
j4ys0n merged 1 commit into
mainfrom
ptc
Mar 13, 2026
Merged

prune unsupported properties from mcp schema for google#56
j4ys0n merged 1 commit into
mainfrom
ptc

Conversation

@j4ys0n
Copy link
Copy Markdown
Contributor

@j4ys0n j4ys0n commented Mar 13, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 13, 2026 19:14
@j4ys0n
Copy link
Copy Markdown
Contributor Author

j4ys0n commented Mar 13, 2026

Automated review 🤖

Summary of Changes
Version bumped from 1.11.3 to 1.11.4. A new static ALLOWED_SCHEMA_KEYS set was introduced in GoogleMapper to whitelist supported JSON Schema properties for Google’s MCP tool parameter schemas. During schema normalization in mapToProviderParams, all keys not in this set are now stripped from tool parameter schemas, including unsupported fields like optional and examples. Unit test added to verify pruning behavior.

Key Changes & Positives

  • Introduces explicit schema whitelisting via ALLOWED_SCHEMA_KEYS, improving robustness against unsupported schema extensions from upstream tools 🟢.
  • Pruning logic applied consistently via Object.fromEntries(filter(...)), ensuring deterministic schema reduction in src/core/mapping/google.mapper.ts lines 286–288.
  • New unit test confirms optional and examples are removed while required fields (type, description) remain in tests/unit/core/mapping/google.mapper.spec.ts lines 245–283.

Potential Issues & Recommendations

  1. Issue / Risk: The nullable key is included in ALLOWED_SCHEMA_KEYS, but Google’s Function Calling API does not support nullable; this may cause runtime validation errors when generating tool calls.
    Impact: Tool registration could fail for schemas using nullable, especially if generated from OpenAPI specs or TypeScript union types.
    Recommendation: Remove nullable from ALLOWED_SCHEMA_KEYS and add handling for null types (e.g., convert to anyOf with null branch) or document limitation.
    Status: 🔴 Problem

  2. Issue / Risk: propertyOrdering is included in ALLOWED_SCHEMA_KEYS, but Google’s Function Calling API does not recognize this field per public documentation.
    Impact: Pruned schema may still include unsupported metadata, risking silent ignored fields or future API rejections.
    Recommendation: Verify propertyOrdering support; if unsupported, remove from whitelist.
    Status: 🟡 Needs review

Language/Framework Checks

  • TypeScript usage of Set for O(1) key lookup is appropriate and performant in google.mapper.ts lines 40–62.
  • Schema pruning preserves valid Google-compatible keys (type, description, enum, etc.) while removing non-standard ones (optional, examples) as verified by test in google.mapper.spec.ts.

Security & Privacy
No security or privacy implications identified—schema pruning affects only metadata, not user data or credentials.

Build/CI & Ops
Version bump to 1.11.4 in package.json line 3 indicates a patch release; ensure changelog updated to reflect schema pruning behavior.

Tests
New test validates pruning of optional and examples keys, but no test covers edge cases like nested anyOf/oneOf with unsupported keys or nullable handling. Add tests for nested schema pruning and nullable behavior.

Approval Recommendation
Request changes

  • Remove nullable and propertyOrdering from ALLOWED_SCHEMA_KEYS pending verification of Google API support.
  • Add unit tests for nested schema pruning and nullable type handling.

@j4ys0n j4ys0n merged commit 0312dd1 into main Mar 13, 2026
3 checks passed
@j4ys0n j4ys0n deleted the ptc branch March 13, 2026 19:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens Google tool/function parameter schema mapping by stripping schema keys that the Google GenAI FunctionDeclaration schema doesn’t support, preventing provider-side validation errors.

Changes:

  • Add an allow-list based pruning step to GoogleMapper.cleanSchemaForGoogle() so only supported schema keywords are sent to Google.
  • Add a unit test asserting that non-Google keys (e.g., optional, examples) are removed from tool parameter schemas.
  • Bump package version 1.11.31.11.4.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/core/mapping/google.mapper.ts Prunes cleaned JSON Schema objects down to Google-supported keys before building function declarations.
tests/unit/core/mapping/google.mapper.spec.ts Adds coverage ensuring unsupported schema keys are stripped from tool parameter definitions.
package.json Patch version bump for release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

'minLength',
'minProperties',
'minimum',
'nullable',
Comment on lines +286 to +292
const prunedSchema = Object.fromEntries(
Object.entries(cleanedSchema).filter(([key]) => GoogleMapper.ALLOWED_SCHEMA_KEYS.has(key))
)

visited.delete(schema); // Clean up visited set for this path

return cleanedSchema;
return prunedSchema;
Comment thread package.json
{
"name": "@missionsquad/rosetta-ai",
"version": "1.11.3",
"version": "1.11.4",
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.

2 participants