Skip to content

Commit 5c8d559

Browse files
ochafikclaude
andcommitted
refactor: re-export derived request/notification schemas from generated
Add re-exports for schemas derived from RequestSchema/NotificationSchema/ResultSchema: - PaginatedRequestSchema, PaginatedResultSchema - PingRequestSchema - InitializedNotificationSchema, CancelledNotificationSchema - ResourceListChangedNotificationSchema, PromptListChangedNotificationSchema - ToolListChangedNotificationSchema, RootsListChangedNotificationSchema These are now unlocked because Request.params and Notification.params include proper param types after the pre-processing injection. Total schemas re-exported: 45 Lines saved: ~402 (2600 → 2198) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e526ee6 commit 5c8d559

File tree

1 file changed

+28
-62
lines changed

1 file changed

+28
-62
lines changed

src/types.ts

Lines changed: 28 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ import {
5959
RequestSchema,
6060
NotificationSchema,
6161
ResultSchema,
62+
// Derived base schemas
63+
PaginatedResultSchema,
64+
PaginatedRequestSchema,
65+
// Simple request/notification schemas (no extra params beyond base)
66+
PingRequestSchema,
67+
InitializedNotificationSchema,
68+
CancelledNotificationSchema,
69+
ResourceListChangedNotificationSchema,
70+
PromptListChangedNotificationSchema,
71+
ToolListChangedNotificationSchema,
72+
RootsListChangedNotificationSchema,
6273
} from './generated/sdk.schemas.js';
6374

6475
// Alias RequestParamsSchema to BaseRequestParamsSchema for internal use
@@ -102,6 +113,15 @@ export {
102113
RequestSchema,
103114
NotificationSchema,
104115
ResultSchema,
116+
PaginatedResultSchema,
117+
PaginatedRequestSchema,
118+
PingRequestSchema,
119+
InitializedNotificationSchema,
120+
CancelledNotificationSchema,
121+
ResourceListChangedNotificationSchema,
122+
PromptListChangedNotificationSchema,
123+
ToolListChangedNotificationSchema,
124+
RootsListChangedNotificationSchema,
105125
};
106126

107127
export const LATEST_PROTOCOL_VERSION = '2025-11-25';
@@ -280,16 +300,8 @@ export const CancelledNotificationParamsSchema = NotificationsParamsSchema.exten
280300
/**
281301
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
282302
*
283-
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
284-
*
285-
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
286-
*
287-
* A client MUST NOT attempt to cancel its `initialize` request.
303+
* Note: CancelledNotificationSchema is re-exported from generated.
288304
*/
289-
export const CancelledNotificationSchema = NotificationSchema.extend({
290-
method: z.literal('notifications/cancelled'),
291-
params: CancelledNotificationParamsSchema
292-
});
293305

294306
/* Initialization */
295307
const FormElicitationCapabilitySchema = z.intersection(
@@ -524,25 +536,13 @@ export const InitializeResultSchema = ResultSchema.extend({
524536
instructions: z.string().optional()
525537
});
526538

527-
/**
528-
* This notification is sent from the client to the server after initialization has finished.
529-
*/
530-
export const InitializedNotificationSchema = NotificationSchema.extend({
531-
method: z.literal('notifications/initialized'),
532-
params: NotificationsParamsSchema.optional()
533-
});
539+
// Note: InitializedNotificationSchema is re-exported from generated.
534540

535541
export const isInitializedNotification = (value: unknown): value is InitializedNotification =>
536542
InitializedNotificationSchema.safeParse(value).success;
537543

538544
/* Ping */
539-
/**
540-
* A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
541-
*/
542-
export const PingRequestSchema = RequestSchema.extend({
543-
method: z.literal('ping'),
544-
params: BaseRequestParamsSchema.optional()
545-
});
545+
// Note: PingRequestSchema is re-exported from generated.
546546

547547
/* Progress notifications */
548548
export const ProgressSchema = z.object({
@@ -587,17 +587,7 @@ export const PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
587587
});
588588

589589
/* Pagination */
590-
export const PaginatedRequestSchema = RequestSchema.extend({
591-
params: PaginatedRequestParamsSchema.optional()
592-
});
593-
594-
export const PaginatedResultSchema = ResultSchema.extend({
595-
/**
596-
* An opaque token representing the pagination position after the last returned result.
597-
* If present, there may be more results available.
598-
*/
599-
nextCursor: CursorSchema.optional()
600-
});
590+
// Note: PaginatedRequestSchema and PaginatedResultSchema are re-exported from generated.
601591

602592
/* Tasks */
603593
/**
@@ -839,13 +829,7 @@ export const ReadResourceResultSchema = ResultSchema.extend({
839829
contents: z.array(z.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
840830
});
841831

842-
/**
843-
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
844-
*/
845-
export const ResourceListChangedNotificationSchema = NotificationSchema.extend({
846-
method: z.literal('notifications/resources/list_changed'),
847-
params: NotificationsParamsSchema.optional()
848-
});
832+
// Note: ResourceListChangedNotificationSchema is re-exported from generated.
849833

850834
export const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
851835
/**
@@ -1010,13 +994,7 @@ export const GetPromptResultSchema = ResultSchema.extend({
1010994
messages: z.array(PromptMessageSchema)
1011995
});
1012996

1013-
/**
1014-
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
1015-
*/
1016-
export const PromptListChangedNotificationSchema = NotificationSchema.extend({
1017-
method: z.literal('notifications/prompts/list_changed'),
1018-
params: NotificationsParamsSchema.optional()
1019-
});
997+
// Note: PromptListChangedNotificationSchema is re-exported from generated.
1020998

1021999
/* Tools */
10221000
/**
@@ -1163,13 +1141,7 @@ export const CallToolRequestSchema = RequestSchema.extend({
11631141
params: CallToolRequestParamsSchema
11641142
});
11651143

1166-
/**
1167-
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
1168-
*/
1169-
export const ToolListChangedNotificationSchema = NotificationSchema.extend({
1170-
method: z.literal('notifications/tools/list_changed'),
1171-
params: NotificationsParamsSchema.optional()
1172-
});
1144+
// Note: ToolListChangedNotificationSchema is re-exported from generated.
11731145

11741146
/**
11751147
* Callback type for list changed notifications.
@@ -1787,13 +1759,7 @@ export const ListRootsResultSchema = ResultSchema.extend({
17871759
roots: z.array(RootSchema)
17881760
});
17891761

1790-
/**
1791-
* A notification from the client to the server, informing it that the list of roots has changed.
1792-
*/
1793-
export const RootsListChangedNotificationSchema = NotificationSchema.extend({
1794-
method: z.literal('notifications/roots/list_changed'),
1795-
params: NotificationsParamsSchema.optional()
1796-
});
1762+
// Note: RootsListChangedNotificationSchema is re-exported from generated.
17971763

17981764
/* Client messages */
17991765
export const ClientRequestSchema = z.union([

0 commit comments

Comments
 (0)