fix(build): resolve TS2589 in server.ts and axios header type drift in media.ts#22
Open
kleintech wants to merge 1 commit into
Open
fix(build): resolve TS2589 in server.ts and axios header type drift in media.ts#22kleintech wants to merge 1 commit into
kleintech wants to merge 1 commit into
Conversation
…n media.ts The MCP SDK's `server.tool` generic resolves `ShapeOutput<Args>` against a combined zod v3/v4 schema union, which exceeds TypeScript's instantiation depth when matched against the tool input shapes. Pass the raw shape through a flat call-site cast so inference does not recurse through the dual-zod compat types. axios's `response.headers['content-type']` is typed as `AxiosHeaderValue`, which permits `string[] | number | boolean | null`. Narrow to `string` before handing it to `normalizeMimeType`, which only accepts `string | undefined`. Co-Authored-By: Claude Opus 4.7 <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
npm run buildcurrently fails onmainwith two TypeScript errors. This PR addresses both:src/server.ts:58(TS2589) —server.toolis generic overArgs extends ZodRawShapeCompat, andToolCallback<Args>resolvesShapeOutput<Args>against the SDK's combined zod v3 / zod v4 schema union (z3.ZodTypeAny | z4.$ZodType). InferringArgsfrom the project's tool input shapes blows past TypeScript's instantiation depth. Passing the raw shape through a flat call-site cast keeps the runtime behavior identical while stopping inference from recursing through the dual-zod compat types.src/tools/media.ts:258(TS2345) —response.headers['content-type']is typedAxiosHeaderValue | undefined(which includesstring[] | number | boolean | null), butnormalizeMimeTypeonly acceptsstring | undefined. Narrow to astringbefore passing it in; non-string values fall through to the existingapplication/octet-streamdefault.After both changes,
npm run buildis clean.Test plan
npm run buildsucceeds with no errorscreate_mediawithsource_urlto confirm the narrowing still yields the expected MIME type on a normal HTTP response