Skip to content

Commit 8e957cc

Browse files
committed
Removing non-standard enumNames for standard oneOf
1 parent f657ead commit 8e957cc

File tree

6 files changed

+113
-23
lines changed

6 files changed

+113
-23
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,11 @@ server.tool(
10401040
type: "string",
10411041
title: "Date flexibility",
10421042
description: "How flexible are your dates?",
1043-
enum: ["next_day", "same_week", "next_week"],
1044-
enumNames: ["Next day", "Same week", "Next week"]
1043+
oneOf: [
1044+
{ const: "next_day", title: "Next day" },
1045+
{ const: "same_week", title: "Same week" },
1046+
{ const: "next_week", title: "Next week" }
1047+
],
10451048
}
10461049
},
10471050
required: ["checkAlternatives"]

package-lock.json

Lines changed: 88 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"client": "tsx src/cli.ts client"
5151
},
5252
"dependencies": {
53-
"ajv": "^6.12.6",
53+
"ajv": "^8.17.1",
5454
"content-type": "^1.0.5",
5555
"cors": "^2.8.5",
5656
"cross-spawn": "^7.0.5",

src/examples/server/simpleStreamableHttp.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ const getServer = () => {
141141
type: 'string',
142142
title: 'Theme',
143143
description: 'Choose your preferred theme',
144-
enum: ['light', 'dark', 'auto'],
145-
enumNames: ['Light', 'Dark', 'Auto'],
144+
oneOf: [
145+
{ const: 'light', title: 'Light' },
146+
{ const: 'dark', title: 'Dark' },
147+
{ const: 'auto', title: 'Auto' }
148+
],
146149
},
147150
notifications: {
148151
type: 'boolean',
@@ -154,8 +157,11 @@ const getServer = () => {
154157
type: 'string',
155158
title: 'Notification Frequency',
156159
description: 'How often would you like notifications?',
157-
enum: ['daily', 'weekly', 'monthly'],
158-
enumNames: ['Daily', 'Weekly', 'Monthly'],
160+
oneOf: [
161+
{ const: 'daily', title: 'Daily' },
162+
{ const: 'weekly', title: 'Weekly' },
163+
{ const: 'monthly', title: 'Monthly' }
164+
],
159165
},
160166
},
161167
required: ['theme'],

src/server/mcp.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,8 +4119,11 @@ describe("elicitInput()", () => {
41194119
type: "string",
41204120
title: "Date flexibility",
41214121
description: "How flexible are your dates?",
4122-
enum: ["next_day", "same_week", "next_week"],
4123-
enumNames: ["Next day", "Same week", "Next week"]
4122+
oneOf: [
4123+
{ const: "next_day", title: "Next day" },
4124+
{ const: "same_week", title: "Same week" },
4125+
{ const: "next_week", title: "Next week" }
4126+
],
41244127
}
41254128
},
41264129
required: ["checkAlternatives"]

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,10 @@ export const EnumSchemaSchema = z
12121212
type: z.literal("string"),
12131213
title: z.optional(z.string()),
12141214
description: z.optional(z.string()),
1215-
enum: z.array(z.string()),
1216-
enumNames: z.optional(z.array(z.string())),
1215+
oneOf: z.array(z.object({
1216+
const: z.string(),
1217+
title: z.string()
1218+
})),
12171219
})
12181220
.passthrough();
12191221

0 commit comments

Comments
 (0)