diff --git a/src/index.ts b/src/index.ts index 5f82665..19d88dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,8 +80,10 @@ server.tool( .optional() .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."), tokens: z - .number() - .min(DEFAULT_MINIMUM_TOKENS) + .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number()) + .refine((val) => typeof val === "number" && val >= DEFAULT_MINIMUM_TOKENS, { + message: `Must be a number >= ${DEFAULT_MINIMUM_TOKENS}`, + }) .optional() .describe( `Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`