diff --git a/README.md b/README.md index 837a06f..4890a08 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude D - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID. - `context7CompatibleLibraryID` (required) - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks") - - `tokens` (optional, default 5000): Max number of tokens to return + - `tokens` (optional, default 5000): Max number of tokens to return. Values less than 5000 are automatically increased to 5000. ## Development diff --git a/src/index.ts b/src/index.ts index 19d88dc..0111f5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,9 +81,7 @@ server.tool( .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."), tokens: z .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}`, - }) + .transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val)) .optional() .describe( `Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`