Skip to content

Add type compatibility test between SDK and spec types #729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

ochafik
Copy link
Contributor

@ochafik ochafik commented Jul 3, 2025

Test that the TS SDK types are in sync w/ the Spec types

Note: ModelHint, ModelPreferences, Annotations are not in the SDK yet, incubating them in a63aeeb

Motivation and Context

#727 cc/ @ihrpr

How Has This Been Tested?

  • Checked that npm run test failes w/ human-readable message before Rename reject to decline #727

    CleanShot 2025-07-03 at 21 23 01@2x

  • Did spot tests of editing either the sdk types or the spec types, e.g. switching fields between optional & required, renaming, altering strings

Breaking Changes

None

Types of changes

  • Test
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Types in the TS SDK are derived from Zod schemas, while the ones in the specs are written by hand. This causes a few type discrepancies, which are temptatively ironed out using ham-handed type mappings:

  • ZodObject.passthrough() feature introduces {[key: string]: unknown} passthroughs: we undo this w/ RemovePassthrough<T>
  • Fields w/ z.unknown() are treated as optional; we undo this w/ MakeUnknownsNotOptional<T>, with the exception of _meta fields

@ochafik ochafik marked this pull request as ready for review July 3, 2025 20:13
@ochafik ochafik requested review from ihrpr and dsp-ant July 3, 2025 20:24
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