Skip to content

Context7 Platform -- Up-to-date docs for AI agents

docs: enhance library name guidelines in CLI and documentation (#2408)

Enes Gules83228794e4e7
diff --git a/.changeset/funky-peaches-tickle.md b/.changeset/funky-peaches-tickle.md
new file mode 100644
index 00000000..9ab87c0b
--- /dev/null
+++ b/.changeset/funky-peaches-tickle.md
@@ -0,0 +1,7 @@
+---
+"@upstash/context7-tools-ai-sdk": patch
+"ctx7": patch
+"@upstash/context7-mcp": patch
+---
+
+Improve resolve libryar id tool prompt to provide the libraryName query with proper format
diff --git a/packages/cli/src/setup/templates.ts b/packages/cli/src/setup/templates.ts
index 63ae24ff..e10faeda 100644
--- a/packages/cli/src/setup/templates.ts
+++ b/packages/cli/src/setup/templates.ts
@@ -9,7 +9,7 @@ Do not use for: refactoring, writing scripts from scratch, debugging business lo
## Steps
-1. \`resolve-library-id\` with the library name and the user's question
+1. \`resolve-library-id\` with the library name and the user's question. Use the official library name with proper punctuation (e.g., "Next.js" not "nextjs", "Customer.io" not "customerio", "Three.js" not "threejs")
2. Pick the best match by: exact name match, description relevance, code snippet count, source reputation (High/Medium preferred), and benchmark score (higher is better). Use version-specific IDs when the user mentions a version
3. \`query-docs\` with the selected library ID and the user's full question (not single words)
4. Answer using the fetched docs
diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts
index 2314f2b9..1de77a7c 100644
--- a/packages/mcp/src/index.ts
+++ b/packages/mcp/src/index.ts
@@ -197,7 +197,9 @@ IMPORTANT: Do not call this tool more than 3 times per question. If you cannot f
),
libraryName: z
.string()
- .describe("Library name to search for and retrieve a Context7-compatible library ID."),
+ .describe(
+ "Library name to search for and retrieve a Context7-compatible library ID. Use the official library name with proper punctuation — e.g., 'Next.js' instead of 'nextjs', 'Customer.io' instead of 'customerio', 'Three.js' instead of 'threejs'."
+ ),
},
annotations: {
readOnlyHint: true,
diff --git a/packages/tools-ai-sdk/src/tools/resolve-library-id.ts b/packages/tools-ai-sdk/src/tools/resolve-library-id.ts
index b92977c8..4cdc1120 100644
--- a/packages/tools-ai-sdk/src/tools/resolve-library-id.ts
+++ b/packages/tools-ai-sdk/src/tools/resolve-library-id.ts
@@ -44,7 +44,9 @@ export function resolveLibraryId(config: Context7ToolsConfig = {}) {
),
libraryName: z
.string()
- .describe("Library name to search for and retrieve a Context7-compatible library ID."),
+ .describe(
+ "Library name to search for and retrieve a Context7-compatible library ID. Use the official library name with proper punctuation — e.g., 'Next.js' instead of 'nextjs', 'Customer.io' instead of 'customerio', 'Three.js' instead of 'threejs'."
+ ),
}),
execute: async ({ query, libraryName }: { query: string; libraryName: string }) => {
try {
diff --git a/rules/context7-cli.md b/rules/context7-cli.md
index 6986a4a5..f723bde1 100644
--- a/rules/context7-cli.md
+++ b/rules/context7-cli.md
@@ -4,7 +4,7 @@ Do not use for: refactoring, writing scripts from scratch, debugging business lo
## Steps
-1. Resolve library: `npx ctx7@latest library <name> "<user's question>"`
+1. Resolve library: `npx ctx7@latest library <name> "<user's question>"` — use the official library name with proper punctuation (e.g., "Next.js" not "nextjs", "Customer.io" not "customerio", "Three.js" not "threejs")
2. Pick the best match (ID format: `/org/project`) by: exact name match, description relevance, code snippet count, source reputation (High/Medium preferred), and benchmark score (higher is better). If results don't look right, try alternate names or queries (e.g., "next.js" not "nextjs", or rephrase the question)
3. Fetch docs: `npx ctx7@latest docs <libraryId> "<user's question>"`
4. Answer using the fetched documentation