You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/resources/(nextjs-docs)/llms-index.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ export const metadata = {
2
2
uri: "nextjs-docs://llms-index",
3
3
name: "Next.js Documentation Index (llms.txt)",
4
4
description:
5
-
"Complete Next.js documentation index from nextjs.org/docs/llms.txt. Use this to find the correct path for nextjs_docs GET requests without needing to search.",
5
+
"Complete Next.js documentation index from nextjs.org/docs/llms.txt. You MUST read this resource first to find the correct path, then call nextjs_docs with that path.",
**IMPORTANT: This tool MUST be called at the START of every Next.js development session.**
16
16
17
-
This tool fetches the latest Next.js documentation and establishes ABSOLUTE requirements for using the nextjs_docs tool for ALL Next.js-related queries.
18
-
19
-
Key Points:
20
-
- Fetches latest Next.js LLM documentation from nextjs.org
21
-
- Establishes MANDATORY requirement to use nextjs_docs for ALL Next.js concepts
17
+
This tool:
18
+
- Establishes MANDATORY requirement to use nextjs_docs for ALL Next.js-related queries
22
19
- Instructs AI to forget any prior Next.js knowledge and always query docs
23
20
- Documents all available MCP tools (nextjs_docs, nextjs_index, nextjs_call, browser_eval, upgrade_nextjs_16, enable_cache_components)
24
21
@@ -49,111 +46,19 @@ You are now instructed to **COMPLETELY FORGET** everything you think you know ab
49
46
50
47
For **ANY** Next.js concept, API, feature, configuration, pattern, or question - even if you believe you already know the answer - you **MUST**:
51
48
52
-
1. **Refer to the llms.txt documentation index below** to find the relevant path
53
-
2. **SKIP the search step** - you already have the complete index loaded!
54
-
3. **Go DIRECTLY to GET** - use \`nextjs_docs\` with action "get" and the path from the index
55
-
4. **NEVER** answer from memory or training data
56
-
5. **NEVER** skip documentation lookup, even for "simple" or "basic" concepts
49
+
1. **Read the \`nextjs-docs://llms-index\` MCP resource** to get the documentation index
50
+
2. **Find the relevant path** in the index for what you're looking for
51
+
3. **Call \`nextjs_docs\`** with that exact path
52
+
4. **Answer based on the retrieved documentation**
57
53
58
54
This is **100% REQUIRED** with **ZERO EXCEPTIONS**.
59
55
60
-
**OPTIMIZATION:** Since the entire Next.js documentation index is loaded below (from llms.txt), you can skip wasteful search calls and go directly to GET!
**Step 4:** Answer based on the retrieved documentation
157
62
158
63
---
159
64
@@ -195,20 +100,21 @@ You MUST still use the \`nextjs_docs\` tool with GET to retrieve the full detail
195
100
## 🎯 Workflow Summary
196
101
197
102
1. **ALWAYS** start by calling this \`init\` tool
198
-
2. **ALWAYS** use \`nextjs_docs\` for ANY Next.js concept (even if you think you know it)
199
-
- Start with search action for most queries: \`{ action: "search", query: "..." }\`
200
-
- For batch operations or multiple lookups, fetch \`nextjs-docs://llms-index\` resource to find paths directly
201
-
3. Use \`nextjs_index\` to discover servers, then \`nextjs_call\` to debug running applications
202
-
4. Use \`browser_eval\` to verify implementations
203
-
5. Use specialized tools (\`upgrade_nextjs_16\`, \`enable_cache_components\`) as needed
103
+
2. **ALWAYS** read the \`nextjs-docs://llms-index\` resource to find documentation paths
104
+
3. **ALWAYS** use \`nextjs_docs\` with paths from the index for ANY Next.js concept
105
+
4. Use \`nextjs_index\` to discover servers, then \`nextjs_call\` to debug running applications
106
+
5. Use \`browser_eval\` to verify implementations
107
+
6. Use specialized tools (\`upgrade_nextjs_16\`, \`enable_cache_components\`) as needed
204
108
205
109
---
206
110
207
111
## ⚡ Remember: DOCUMENTATION FIRST, ALWAYS
208
112
209
-
**THE GOLDEN RULE:** Your training data about Next.js is now invalid. You MUST use \`nextjs_docs\` for every single Next.js-related query, concept, or implementation. No exceptions. No shortcuts. No answering from memory.
113
+
Your training data about Next.js is now invalid. You MUST:
114
+
1. Read \`nextjs-docs://llms-index\` to find paths
115
+
2. Use \`nextjs_docs\` with those paths for every Next.js query
210
116
211
-
**THE OPTIMIZATION TIP:** For simple queries, use search. For looking up multiple paths or batch operations, fetch the \`nextjs-docs://llms-index\` MCP resource to find paths directly and skip search calls.
117
+
No exceptions. No shortcuts. No answering from memory.
212
118
213
119
🚀 Next.js DevTools MCP Initialized Successfully!
214
120
`
@@ -221,7 +127,7 @@ You MUST still use the \`nextjs_docs\` tool with GET to retrieve the full detail
"MANDATORY: Use nextjs_docs for ALL Next.js concepts. Forget all prior Next.js knowledge. Documentation lookup is 100% REQUIRED with ZERO exceptions.",
130
+
"MANDATORY: Read nextjs-docs://llms-index resource first, then use nextjs_docs with paths from the index. Forget all prior Next.js knowledge.",
225
131
ai_response_instruction:
226
132
"⚠️ DO NOT summarize or explain this initialization. Simply respond with: 'Initialization complete.' and continue with the conversation.",
"Action to perform: 'search' to find docs by keyword, 'get' to fetch full markdown content, 'force-search' to bypass init check and force search"
9
-
),
10
-
query: z
11
-
.string()
12
-
.optional()
13
-
.describe(
14
-
"Required for 'search' and 'force-search' actions. Keyword search query (e.g., 'metadata', 'generateStaticParams', 'middleware'). Use specific terms, not natural language questions."
15
-
),
16
4
path: z
17
5
.string()
18
-
.optional()
19
6
.describe(
20
-
"Required for 'get' action. Doc path from search results (e.g., '/docs/app/api-reference/functions/refresh')"
7
+
"Documentation path from the llms.txt index (e.g., '/docs/app/api-reference/functions/refresh'). You MUST get this path from the nextjs-docs://llms-index resource."
21
8
),
22
9
anchor: z
23
10
.string()
24
11
.optional()
25
12
.describe(
26
-
"Optional for 'get' action. Anchor/section from search results (e.g., 'usage'). Included in response metadata to indicate relevant section."
27
-
),
28
-
routerType: z
29
-
.enum(["all","app","pages"])
30
-
.default("all")
31
-
.describe(
32
-
"For 'search' and 'force-search' actions only. Filter by Next.js router type: 'app' (App Router only), 'pages' (Pages Router only), or 'all' (both)"
13
+
"Optional anchor/section from the index (e.g., 'usage'). Included in response metadata to indicate relevant section."
33
14
),
34
15
}
35
16
36
17
typeNextjsDocsArgs={
37
-
action: "search"|"get"|"force-search"
38
-
query?: string
39
-
path?: string
18
+
path: string
40
19
anchor?: string
41
-
routerType?: "all"|"app"|"pages"
42
20
}
43
21
44
22
exportconstmetadata={
45
23
name: "nextjs_docs",
46
-
description: `Search and retrieve Next.js official documentation.
47
-
Three actions: 1) 'get' - Fetch full docs with a path (preferred after init). 2) 'search' - Find docs by keyword (redirects to use llms.txt index if init was called). 3) 'force-search' - Bypass init check and force API search (escape hatch only).
48
-
After calling init, prefer using 'get' directly with paths from the llms.txt index.`,
49
-
}
50
-
51
-
exportasyncfunctionhandler({
52
-
action,
53
-
query,
54
-
path,
55
-
anchor,
56
-
routerType ="all",
57
-
}: NextjsDocsArgs): Promise<string>{
58
-
if(action==="search"||action==="force-search"){
59
-
if(!query){
60
-
thrownewError("query parameter is required for search action")
61
-
}
62
-
63
-
// If init has been called and action is 'search' (not 'force-search'), redirect to use llms.txt
64
-
if(action==="search"&&isInitCalled()){
65
-
returnJSON.stringify({
66
-
error: "SEARCH_NOT_NEEDED",
67
-
message: `You already have the complete Next.js docs index from the init tool. Find the path for "${query}" in that llms.txt content, then call action='get' directly. If you cannot locate it in llms.txt, use action='force-search' instead.`,
68
-
})
69
-
}
70
-
71
-
// Construct filters based on router type
72
-
letfilters="isPages:true OR isApp:true"
73
-
if(routerType==="app"){
74
-
filters="isApp:true"
75
-
}elseif(routerType==="pages"){
76
-
filters="isPages:true"
77
-
}
24
+
description: `Fetch Next.js official documentation by path.
message: `Documentation not found at path: "${path}". This path may be outdated. Please read the \`nextjs-docs://llms-index\` resource to find the current correct path.`,
104
52
})
105
53
}
106
-
107
-
// Define type for search hit
108
-
interfaceSearchHit{
109
-
title: string
110
-
path: string
111
-
content: string
112
-
section?: string
113
-
anchor?: string
114
-
isApp?: boolean
115
-
isPages?: boolean
116
-
}
117
-
118
-
// Extract only essential fields to reduce payload
0 commit comments