Skip to content

Commit d5c3d81

Browse files
committed
Add TypeScript types from Zod schemas
1 parent cd6820e commit d5c3d81

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

src/types.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,3 +819,102 @@ export class McpError extends Error {
819819
super(`MCP error ${code}: ${message}`);
820820
}
821821
}
822+
823+
/* JSON-RPC types */
824+
export type ProgressToken = z.infer<typeof ProgressTokenSchema>;
825+
export type Request = z.infer<typeof RequestSchema>;
826+
export type Notification = z.infer<typeof NotificationSchema>;
827+
export type Result = z.infer<typeof ResultSchema>;
828+
export type RequestId = z.infer<typeof RequestIdSchema>;
829+
export type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
830+
export type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
831+
export type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
832+
export type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
833+
export type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
834+
835+
/* Empty result */
836+
export type EmptyResult = z.infer<typeof EmptyResultSchema>;
837+
838+
/* Initialization */
839+
export type TextContent = z.infer<typeof TextContentSchema>;
840+
export type ImageContent = z.infer<typeof ImageContentSchema>;
841+
export type SamplingMessage = z.infer<typeof SamplingMessageSchema>;
842+
export type Implementation = z.infer<typeof ImplementationSchema>;
843+
export type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
844+
export type InitializeRequest = z.infer<typeof InitializeRequestSchema>;
845+
export type ServerCapabilities = z.infer<typeof ServerCapabilitiesSchema>;
846+
export type InitializeResult = z.infer<typeof InitializeResultSchema>;
847+
export type InitializedNotification = z.infer<
848+
typeof InitializedNotificationSchema
849+
>;
850+
851+
/* Ping */
852+
export type PingRequest = z.infer<typeof PingRequestSchema>;
853+
854+
/* Progress notifications */
855+
export type Progress = z.infer<typeof ProgressSchema>;
856+
export type ProgressNotification = z.infer<typeof ProgressNotificationSchema>;
857+
858+
/* Resources */
859+
export type ResourceContents = z.infer<typeof ResourceContentsSchema>;
860+
export type TextResourceContents = z.infer<typeof TextResourceContentsSchema>;
861+
export type BlobResourceContents = z.infer<typeof BlobResourceContentsSchema>;
862+
export type Resource = z.infer<typeof ResourceSchema>;
863+
export type ResourceTemplate = z.infer<typeof ResourceTemplateSchema>;
864+
export type ListResourcesRequest = z.infer<typeof ListResourcesRequestSchema>;
865+
export type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
866+
export type ReadResourceRequest = z.infer<typeof ReadResourceRequestSchema>;
867+
export type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
868+
export type ResourceListChangedNotification = z.infer<
869+
typeof ResourceListChangedNotificationSchema
870+
>;
871+
export type SubscribeRequest = z.infer<typeof SubscribeRequestSchema>;
872+
export type UnsubscribeRequest = z.infer<typeof UnsubscribeRequestSchema>;
873+
export type ResourceUpdatedNotification = z.infer<
874+
typeof ResourceUpdatedNotificationSchema
875+
>;
876+
877+
/* Prompts */
878+
export type PromptArgument = z.infer<typeof PromptArgumentSchema>;
879+
export type Prompt = z.infer<typeof PromptSchema>;
880+
export type ListPromptsRequest = z.infer<typeof ListPromptsRequestSchema>;
881+
export type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
882+
export type GetPromptRequest = z.infer<typeof GetPromptRequestSchema>;
883+
export type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
884+
885+
/* Tools */
886+
export type Tool = z.infer<typeof ToolSchema>;
887+
export type ListToolsRequest = z.infer<typeof ListToolsRequestSchema>;
888+
export type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
889+
export type CallToolResult = z.infer<typeof CallToolResultSchema>;
890+
export type CallToolRequest = z.infer<typeof CallToolRequestSchema>;
891+
export type ToolListChangedNotification = z.infer<
892+
typeof ToolListChangedNotificationSchema
893+
>;
894+
895+
/* Logging */
896+
export type LoggingLevel = z.infer<typeof LoggingLevelSchema>;
897+
export type SetLevelRequest = z.infer<typeof SetLevelRequestSchema>;
898+
export type LoggingMessageNotification = z.infer<
899+
typeof LoggingMessageNotificationSchema
900+
>;
901+
902+
/* Sampling */
903+
export type CreateMessageRequest = z.infer<typeof CreateMessageRequestSchema>;
904+
export type CreateMessageResult = z.infer<typeof CreateMessageResultSchema>;
905+
906+
/* Autocomplete */
907+
export type ResourceReference = z.infer<typeof ResourceReferenceSchema>;
908+
export type PromptReference = z.infer<typeof PromptReferenceSchema>;
909+
export type CompleteRequest = z.infer<typeof CompleteRequestSchema>;
910+
export type CompleteResult = z.infer<typeof CompleteResultSchema>;
911+
912+
/* Client messages */
913+
export type ClientRequest = z.infer<typeof ClientRequestSchema>;
914+
export type ClientNotification = z.infer<typeof ClientNotificationSchema>;
915+
export type ClientResult = z.infer<typeof ClientResultSchema>;
916+
917+
/* Server messages */
918+
export type ServerRequest = z.infer<typeof ServerRequestSchema>;
919+
export type ServerNotification = z.infer<typeof ServerNotificationSchema>;
920+
export type ServerResult = z.infer<typeof ServerResultSchema>;

0 commit comments

Comments
 (0)