Skip to content

Commit f22bf8f

Browse files
ochafikclaude
andcommitted
refactor: re-export primitive schemas from generated
Replace manual definitions with re-exports from generated schemas for: - ProgressTokenSchema - CursorSchema - RequestIdSchema - RoleSchema - TaskStatusSchema - LoggingLevelSchema These are identical between types.ts and generated, so re-exporting reduces duplication and ensures consistency with MCP spec. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e28e9b8 commit f22bf8f

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

src/types.ts

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
import * as z from 'zod/v4';
22
import { AuthInfo } from './server/auth/types.js';
33

4+
// =============================================================================
5+
// Re-exports from generated schemas
6+
// =============================================================================
7+
// These schemas are generated from spec.types.ts and are identical to the
8+
// manually-defined versions. Re-exporting reduces duplication and ensures
9+
// consistency with the MCP specification.
10+
11+
// Primitive type schemas - import for local use and re-export
12+
import {
13+
ProgressTokenSchema,
14+
CursorSchema,
15+
RequestIdSchema,
16+
RoleSchema,
17+
TaskStatusSchema,
18+
LoggingLevelSchema,
19+
} from './generated/sdk.schemas.js';
20+
21+
export {
22+
ProgressTokenSchema,
23+
CursorSchema,
24+
RequestIdSchema,
25+
RoleSchema,
26+
TaskStatusSchema,
27+
LoggingLevelSchema,
28+
};
29+
430
export const LATEST_PROTOCOL_VERSION = '2025-11-25';
531
export const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
632
export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, '2025-06-18', '2025-03-26', '2024-11-05', '2024-10-07'];
@@ -20,15 +46,6 @@ type ExpandRecursively<T> = T extends object ? (T extends infer O ? { [K in keyo
2046
* @internal
2147
*/
2248
const AssertObjectSchema = z.custom<object>((v): v is object => v !== null && (typeof v === 'object' || typeof v === 'function'));
23-
/**
24-
* A progress token, used to associate progress notifications with the original request.
25-
*/
26-
export const ProgressTokenSchema = z.union([z.string(), z.number().int()]);
27-
28-
/**
29-
* An opaque token used to represent a cursor for pagination.
30-
*/
31-
export const CursorSchema = z.string();
3249

3350
/**
3451
* Task creation parameters, used to ask that the server create a task to represent a request.
@@ -129,11 +146,6 @@ export const ResultSchema = z.looseObject({
129146
_meta: RequestMetaSchema.optional()
130147
});
131148

132-
/**
133-
* A uniquely identifying ID for a request in JSON-RPC.
134-
*/
135-
export const RequestIdSchema = z.union([z.string(), z.number().int()]);
136-
137149
/**
138150
* A request that expects a response.
139151
*/
@@ -639,11 +651,6 @@ export const PaginatedResultSchema = ResultSchema.extend({
639651
nextCursor: CursorSchema.optional()
640652
});
641653

642-
/**
643-
* The status of a task.
644-
* */
645-
export const TaskStatusSchema = z.enum(['working', 'input_required', 'completed', 'failed', 'cancelled']);
646-
647654
/* Tasks */
648655
/**
649656
* A pollable state object associated with a request.
@@ -806,11 +813,6 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
806813
blob: Base64Schema
807814
});
808815

809-
/**
810-
* The sender or recipient of messages and data in a conversation.
811-
*/
812-
export const RoleSchema = z.enum(['user', 'assistant']);
813-
814816
/**
815817
* Optional annotations providing clients additional context about a resource.
816818
*/
@@ -1533,11 +1535,6 @@ export type ListChangedHandlers = {
15331535
};
15341536

15351537
/* Logging */
1536-
/**
1537-
* The severity of a log message.
1538-
*/
1539-
export const LoggingLevelSchema = z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']);
1540-
15411538
/**
15421539
* Parameters for a `logging/setLevel` request.
15431540
*/

0 commit comments

Comments
 (0)