Type System
The SDK’s type system is built on three key principles:- Auto-generated: Types are generated from the OpenAPI specification to ensure accuracy and consistency with the protocol
- Zod validation: All types include Zod schemas for runtime validation
- TypeScript-first: Full TypeScript support with strict typing throughout
Importing Types
All types are exported from the schema module:Type Categories
The type system is organized into several categories:Request Types
Types for requests sent from client to agent. See Request Types for details.InitializeRequestNewSessionRequestLoadSessionRequestPromptRequestSetSessionModeRequest- And more…
Response Types
Types for responses from agent to client. See Response Types for details.InitializeResponseNewSessionResponsePromptResponseListSessionsResponse- And more…
Notification Types
Types for one-way notifications. See Notification Types for details.SessionNotificationSessionUpdate(union type)CancelNotificationCancelRequestNotification
Content Types
Types for representing content in messages:ContentBlock- Union of text, image, audio, resource link, or embedded resourceTextContent- Plain text contentImageContent- Image data with MIME typeAudioContent- Audio data with MIME typeResourceLink- Reference to a resourceEmbeddedResource- Embedded resource content
Capability Types
Types for negotiating features between client and agent:ClientCapabilities- What the client supportsAgentCapabilities- What the agent supportsPromptCapabilities- Supported content types in promptsFileSystemCapabilities- File system operationsMcpCapabilities- MCP transport support
Session Types
Types for session management:SessionId- Unique session identifierSessionInfo- Session metadataSessionMode- Session mode configurationSessionConfigOption- Configuration options
Schema Constants
The SDK exports important constants. See Schema Constants for details.Zod Validation
All types include corresponding Zod schemas for runtime validation:Extensibility
All protocol types include an optional_meta field for custom metadata:
Next Steps
- Explore Request Types
- Learn about Response Types
- Understand Notification Types
- Check Schema Constants