Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active October 25, 2025 10:43
Show Gist options
  • Select an option

  • Save ochafik/bd727c3ea02c7409c7a365ec94b082af to your computer and use it in GitHub Desktop.

Select an option

Save ochafik/bd727c3ea02c7409c7a365ec94b082af to your computer and use it in GitHub Desktop.
MCP TS Remove Passthrough Trick
type RemovePassthrough<T> = T extends object
? T extends Array<infer U>
? Array<RemovePassthrough<U>>
: T extends Function
? T
: {
[K in keyof T as string extends K ? never : K]: K extends "properties" ? T[K] : RemovePassthrough<T[K]>;
}
: T;
export type ProgressToken = RemovePassthrough<Infer<typeof ProgressTokenSchema>>;
export type Cursor = RemovePassthrough<Infer<typeof CursorSchema>>;
export type Request = RemovePassthrough<Infer<typeof RequestSchema>>;
export type RequestMeta = RemovePassthrough<Infer<typeof RequestMetaSchema>>;
export type Notification = RemovePassthrough<Infer<typeof NotificationSchema>>;
export type Result = RemovePassthrough<Infer<typeof ResultSchema>>;
export type RequestId = RemovePassthrough<Infer<typeof RequestIdSchema>>;
export type JSONRPCRequest = RemovePassthrough<Infer<typeof JSONRPCRequestSchema>>;
export type JSONRPCNotification = RemovePassthrough<Infer<typeof JSONRPCNotificationSchema>>;
export type JSONRPCResponse = RemovePassthrough<Infer<typeof JSONRPCResponseSchema>>;
export type JSONRPCError = RemovePassthrough<Infer<typeof JSONRPCErrorSchema>>;
export type JSONRPCMessage = RemovePassthrough<Infer<typeof JSONRPCMessageSchema>>;
export type EmptyResult = RemovePassthrough<Infer<typeof EmptyResultSchema>>;
export type CancelledNotification = RemovePassthrough<Infer<typeof CancelledNotificationSchema>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment