Context7 Platform -- Up-to-date docs for AI agents
chore: bum @modelcontextprotocol/sdk to version 1.13.2 and refactor server tool registration in index.ts
enesgules764765dd4e8b
diff --git a/bun.lock b/bun.lockindex 3812b7d0..d3ccd099 100644--- a/bun.lock+++ b/bun.lock@@ -4,7 +4,7 @@"": {"name": "context7-mcp","dependencies": {- "@modelcontextprotocol/sdk": "^1.12.0",+ "@modelcontextprotocol/sdk": "^1.13.2","commander": "^14.0.0","zod": "^3.24.2",},@@ -48,7 +48,7 @@"@humanwhocodes/retry": ["@humanwhocodes/[email protected]", "", {}, "sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ=="],- "@modelcontextprotocol/sdk": ["@modelcontextprotocol/[email protected]", "", { "dependencies": { "ajv": "^6.12.6", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-KG1CZhZfWg+u8pxeM/mByJDScJSrjjxLc8fwQqbsS8xCjBmQfMNEBTotYdNanKekepnfRI85GtgQlctLFpcYPw=="],+ "@modelcontextprotocol/sdk": ["@modelcontextprotocol/[email protected]", "", { "dependencies": { "ajv": "^6.12.6", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-Vx7qOcmoKkR3qhaQ9qf3GxiVKCEu+zfJddHv6x3dY/9P6+uIwJnmuAur5aB+4FDXf41rRrDnOEGkviX5oYZ67w=="],"@nodelib/fs.scandir": ["@nodelib/[email protected]", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],diff --git a/package.json b/package.jsonindex 0c8c77cf..aaba3ff3 100644--- a/package.json+++ b/package.json@@ -33,7 +33,7 @@},"homepage": "https://github.com/upstash/context7#readme","dependencies": {- "@modelcontextprotocol/sdk": "^1.12.0",+ "@modelcontextprotocol/sdk": "^1.13.2","commander": "^14.0.0","zod": "^3.24.2"},diff --git a/src/index.ts b/src/index.tsindex bc1b3f9b..267d9285 100644--- a/src/index.ts+++ b/src/index.ts@@ -60,9 +60,11 @@ function createServerInstance() {);// Register Context7 tools- server.tool(+ server.registerTool("resolve-library-id",- `Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.+ {+ title: "Resolve Library ID Tool",+ description: `Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.You MUST call this function before 'get-library-docs' to obtain a valid Context7-compatible library ID UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.@@ -81,10 +83,11 @@ Response Format:- If no good matches exist, clearly state this and suggest query refinementsFor ambiguous queries, request clarification before proceeding with a best-guess match.`,- {- libraryName: z- .string()- .describe("Library name to search for and retrieve a Context7-compatible library ID."),+ inputSchema: {+ libraryName: z+ .string()+ .describe("Library name to search for and retrieve a Context7-compatible library ID."),+ },},async ({ libraryName }) => {const searchResponse: SearchResponse = await searchLibraries(libraryName);@@ -129,26 +132,29 @@ ${resultsText}`,});- server.tool(+ server.registerTool("get-library-docs",- "Fetches up-to-date documentation for a library. You must call 'resolve-library-id' first to obtain the exact Context7-compatible library ID required to use this tool, UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.",{- context7CompatibleLibraryID: z- .string()- .describe(- "Exact Context7-compatible library ID (e.g., '/mongodb/docs', '/vercel/next.js', '/supabase/supabase', '/vercel/next.js/v14.3.0-canary.87') retrieved from 'resolve-library-id' or directly from user query in the format '/org/project' or '/org/project/version'."- ),- topic: z- .string()- .optional()- .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),- tokens: z- .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())- .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.`- ),+ title: "Get Library Docs Tool",+ description: "Fetches up-to-date documentation for a library. You must call 'resolve-library-id' first to obtain the exact Context7-compatible library ID required to use this tool, UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.",+ inputSchema: {+ context7CompatibleLibraryID: z+ .string()+ .describe(+ "Exact Context7-compatible library ID (e.g., '/mongodb/docs', '/vercel/next.js', '/supabase/supabase', '/vercel/next.js/v14.3.0-canary.87') retrieved from 'resolve-library-id' or directly from user query in the format '/org/project' or '/org/project/version'."+ ),+ topic: z+ .string()+ .optional()+ .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),+ tokens: z+ .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())+ .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.`+ ),+ },},async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {const fetchDocsResponse = await fetchLibraryDocumentation(context7CompatibleLibraryID, {