Skip to content

fix(build): resolve TS2589 in server.ts and axios header type drift in media.ts#22

Open
kleintech wants to merge 1 commit into
InstaWP:mainfrom
kleintech:feature/fix-typescript-build-errors
Open

fix(build): resolve TS2589 in server.ts and axios header type drift in media.ts#22
kleintech wants to merge 1 commit into
InstaWP:mainfrom
kleintech:feature/fix-typescript-build-errors

Conversation

@kleintech
Copy link
Copy Markdown

Summary

npm run build currently fails on main with two TypeScript errors. This PR addresses both:

  • src/server.ts:58 (TS2589)server.tool is generic over Args extends ZodRawShapeCompat, and ToolCallback<Args> resolves ShapeOutput<Args> against the SDK's combined zod v3 / zod v4 schema union (z3.ZodTypeAny | z4.$ZodType). Inferring Args from 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 typed AxiosHeaderValue | undefined (which includes string[] | number | boolean | null), but normalizeMimeType only accepts string | undefined. Narrow to a string before passing it in; non-string values fall through to the existing application/octet-stream default.

After both changes, npm run build is clean.

Test plan

  • npm run build succeeds with no errors
  • Smoke-test create_media with source_url to confirm the narrowing still yields the expected MIME type on a normal HTTP response
  • Confirm tool registration still works end-to-end by listing tools from a connected MCP client

…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>
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