@@ -790,14 +790,19 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
790790 blob : Base64Schema
791791} ) ;
792792
793+ /**
794+ * The sender or recipient of messages and data in a conversation.
795+ */
796+ export const RoleSchema = z . enum ( [ 'user' , 'assistant' ] ) ;
797+
793798/**
794799 * Optional annotations providing clients additional context about a resource.
795800 */
796801export const AnnotationsSchema = z . object ( {
797802 /**
798803 * Intended audience(s) for the resource.
799804 */
800- audience : z . array ( z . enum ( [ 'user' , 'assistant' ] ) ) . optional ( ) ,
805+ audience : z . array ( RoleSchema ) . optional ( ) ,
801806
802807 /**
803808 * Importance hint for the resource, from 0 (least) to 1 (most).
@@ -1200,7 +1205,7 @@ export const ContentBlockSchema = z.union([
12001205 * Describes a message returned as part of a prompt.
12011206 */
12021207export const PromptMessageSchema = z . object ( {
1203- role : z . enum ( [ 'user' , 'assistant' ] ) ,
1208+ role : RoleSchema ,
12041209 content : ContentBlockSchema
12051210} ) ;
12061211
@@ -1647,7 +1652,7 @@ export const SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
16471652 */
16481653export const SamplingMessageSchema = z
16491654 . object ( {
1650- role : z . enum ( [ 'user' , 'assistant' ] ) ,
1655+ role : RoleSchema ,
16511656 content : z . union ( [ SamplingMessageContentBlockSchema , z . array ( SamplingMessageContentBlockSchema ) ] ) ,
16521657 /**
16531658 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
@@ -1731,7 +1736,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
17311736 * This field is an open string to allow for provider-specific stop reasons.
17321737 */
17331738 stopReason : z . optional ( z . enum ( [ 'endTurn' , 'stopSequence' , 'maxTokens' ] ) . or ( z . string ( ) ) ) ,
1734- role : z . enum ( [ 'user' , 'assistant' ] ) ,
1739+ role : RoleSchema ,
17351740 /**
17361741 * Response content. Single content block (text, image, or audio).
17371742 */
@@ -1759,7 +1764,7 @@ export const CreateMessageResultWithToolsSchema = ResultSchema.extend({
17591764 * This field is an open string to allow for provider-specific stop reasons.
17601765 */
17611766 stopReason : z . optional ( z . enum ( [ 'endTurn' , 'stopSequence' , 'maxTokens' , 'toolUse' ] ) . or ( z . string ( ) ) ) ,
1762- role : z . enum ( [ 'user' , 'assistant' ] ) ,
1767+ role : RoleSchema ,
17631768 /**
17641769 * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
17651770 */
@@ -2349,6 +2354,7 @@ export type Icon = Infer<typeof IconSchema>;
23492354export type Icons = Infer < typeof IconsSchema > ;
23502355export type BaseMetadata = Infer < typeof BaseMetadataSchema > ;
23512356export type Annotations = Infer < typeof AnnotationsSchema > ;
2357+ export type Role = Infer < typeof RoleSchema > ;
23522358
23532359/* Initialization */
23542360export type Implementation = Infer < typeof ImplementationSchema > ;
0 commit comments