-
Notifications
You must be signed in to change notification settings - Fork 0
MCP Events: Zod schemas and type exports #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
67a9a69
4647456
46fe6ac
da16634
fbf3d99
5c64664
7d51c90
7b1d327
8d88f53
dd41dd2
aab4271
7e6077f
0a812ae
4cb327b
1108df8
b38364d
009ee05
b84a0b3
1537bdd
6a9388a
2c3ce31
b6d57aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -462,6 +462,33 @@ export const InitializeRequestSchema = RequestSchema.extend({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: InitializeRequestParamsSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Events */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Advisory hint about how the client should handle an event. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventEffectSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: z.enum(['inject_context', 'notify_user', 'trigger_turn']), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| priority: z.enum(['low', 'normal', 'high', 'urgent']).optional().default('normal') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Describes a topic the server can publish to. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventTopicDescriptorSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: z.string().optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| retained: z.boolean().optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schema: JSONObjectSchema.optional() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Server capability for events. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventsCapabilitySchema = z.looseObject({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topics: z.array(EventTopicDescriptorSchema).optional().default([]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| instructions: z.string().optional() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -520,6 +547,10 @@ export const ServerCapabilitiesSchema = z.object({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Present if the server supports task creation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks: ServerTasksCapabilitySchema.optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Present if the server supports publishing events to clients. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| events: EventsCapabilitySchema.optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2075,6 +2106,120 @@ export const RootsListChangedNotificationSchema = NotificationSchema.extend({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: NotificationsParamsSchema.optional() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Events */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Parameters for events/emit notification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Extends NotificationsParamsSchema to inherit _meta for related_request_id tracking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventParamsSchema = NotificationsParamsSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topic: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event_id: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: JSONValueSchema.optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timestamp: z.iso.datetime({ offset: true }).optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| retained: z.boolean().optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source: z.string().optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| correlation_id: z.string().optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| requested_effects: z.array(EventEffectSchema).optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expires_at: z.iso.datetime({ offset: true }).optional() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).loose(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Event notification sent from server to client. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventEmitNotificationSchema = NotificationSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: z.literal('events/emit'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: EventParamsSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Parameters for events/subscribe request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventSubscribeParamsSchema = z | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topics: z.array(z.string()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .loose(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * A topic pattern that was successfully subscribed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const SubscribedTopicSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: z.string() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * A topic pattern that was rejected, with reason. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const RejectedTopicSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reason: z.string() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * A retained event delivered on subscribe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const RetainedEventSchema = z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topic: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event_id: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timestamp: z.iso.datetime({ offset: true }).optional(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: JSONValueSchema.optional() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2194
to
+2199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename
Suggested change
Comment on lines
+2194
to
+2199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Field names should be camelCase (
Suggested change
Comment on lines
+2194
to
+2199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Response to events/subscribe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventSubscribeResultSchema = ResultSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subscribed: z.array(SubscribedTopicSchema), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rejected: z.array(RejectedTopicSchema).optional().default([]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| retained: z.array(RetainedEventSchema).optional().default([]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Client request to subscribe to event topics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventSubscribeRequestSchema = RequestSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: z.literal('events/subscribe'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: EventSubscribeParamsSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Parameters for events/unsubscribe request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventUnsubscribeParamsSchema = z | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topics: z.array(z.string()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .loose(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Response to events/unsubscribe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventUnsubscribeResultSchema = ResultSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unsubscribed: z.array(z.string()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Client request to unsubscribe from event topics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventUnsubscribeRequestSchema = RequestSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: z.literal('events/unsubscribe'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: EventUnsubscribeParamsSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Response to events/list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventListResultSchema = PaginatedResultSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topics: z.array(EventTopicDescriptorSchema) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Client request to list available event topics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const EventListRequestSchema = PaginatedRequestSchema.extend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: z.literal('events/list') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Client messages */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ClientRequestSchema = z.union([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PingRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2093,7 +2238,10 @@ export const ClientRequestSchema = z.union([ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GetTaskRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GetTaskPayloadRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ListTasksRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CancelTaskRequestSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CancelTaskRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventSubscribeRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventUnsubscribeRequestSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventListRequestSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ClientNotificationSchema = z.union([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2136,7 +2284,8 @@ export const ServerNotificationSchema = z.union([ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolListChangedNotificationSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PromptListChangedNotificationSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TaskStatusNotificationSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ElicitationCompleteNotificationSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ElicitationCompleteNotificationSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventEmitNotificationSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ServerResultSchema = z.union([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2152,7 +2301,10 @@ export const ServerResultSchema = z.union([ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ListToolsResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GetTaskResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ListTasksResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreateTaskResultSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreateTaskResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventSubscribeResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventUnsubscribeResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EventListResultSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Runtime schema lookup — result schemas by method */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2176,7 +2328,10 @@ const resultSchemas: Record<string, z.core.$ZodType> = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tasks/get': GetTaskResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tasks/result': ResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tasks/list': ListTasksResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tasks/cancel': CancelTaskResultSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tasks/cancel': CancelTaskResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'events/subscribe': EventSubscribeResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'events/unsubscribe': EventUnsubscribeResultSchema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'events/list': EventListResultSchema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -589,6 +589,30 @@ export interface ClientCapabilities { | |
| extensions?: { [key: string]: JSONObject }; | ||
| } | ||
|
|
||
| /** | ||
| * Describes a topic the server can publish to. | ||
| * | ||
| * @category `events` | ||
| */ | ||
| export interface EventTopicDescriptor { | ||
| /** | ||
| * A pattern identifying the topic. | ||
| */ | ||
| pattern: string; | ||
| /** | ||
| * A human-readable description of the topic. | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * Whether the server retains the last published message for this topic. | ||
| */ | ||
| retained?: boolean; | ||
| /** | ||
| * An optional JSON Schema describing the shape of messages on this topic. | ||
| */ | ||
| schema?: JSONObject; | ||
| } | ||
|
Comment on lines
+611
to
+640
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file |
||
|
|
||
| /** | ||
| * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. | ||
| * | ||
|
|
@@ -695,6 +719,20 @@ export interface ServerCapabilities { | |
| }; | ||
| }; | ||
| }; | ||
| /** | ||
| * Present if the server supports publishing events to clients. | ||
| */ | ||
| events?: { | ||
| /** | ||
| * Topics the server can publish to. | ||
| */ | ||
| topics: EventTopicDescriptor[]; | ||
| /** | ||
| * Instructions describing the server's events capability. | ||
| */ | ||
| instructions?: string; | ||
| [key: string]: unknown; | ||
| }; | ||
| /** | ||
| * Optional MCP extensions that the server supports. Keys are extension identifiers | ||
| * (e.g., "io.modelcontextprotocol/apps"), and values are per-extension settings | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
topicsarray can currently be empty. While technically valid, allowing subscription to an empty list of topics can lead to ambiguous behavior and might be better treated as a client error. Consider making it a non-empty array to be more explicit about the expected input.This change should also be applied to
EventUnsubscribeParamsSchemafor consistency.If you apply this change, please also update the tests in
packages/core/test/event-schemas.test.tsto assert that an empty array is rejected.