aalhommada/nextjs-docs-mcp
If you are the rightful owner of nextjs-docs-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server for accessing and searching Next.js documentation.
Next.js Documentation MCP Server
A Model Context Protocol (MCP) server for accessing and searching Next.js documentation. This package provides programmatic access to Next.js documentation through a simple interface.
Features
- 🔍 Search Documentation: Search through Next.js documentation with natural language queries
- 📖 Full Page Access: Retrieve complete documentation pages by URL
- 💡 Best Practices: Get curated best practices for specific Next.js topics
- 📊 Cache Statistics: Monitor cache performance and statistics
- 🔄 Smart Caching: Documentation is cached with size limits and expiration (6 hours)
- ⚡ Performance Optimized: Concurrent scraping and efficient search algorithms
- 🔒 Security Enhanced: Rate limiting (30 requests/minute) to prevent abuse
- 🌐 Comprehensive Coverage: Covers all major Next.js documentation sections including:
- Getting Started
- App Router
- Pages Router
- API Reference
- Functions
- Optimization
- Security
- Advanced Topics
Quick Installation
Choose your platform:
Claude Code Terminal (Windows):
Due to a Windows-specific issue with the claude mcp add command, use this automated installer:
npx @aalhommada/nextjs-docs-mcp install-claude
Or manually run this PowerShell command:
powershell -ExecutionPolicy Bypass -Command "$config = Get-Content '$env:USERPROFILE\.claude.json' | ConvertFrom-Json; $projectPath = (Get-Location).Path; if (-not $config.projects.$projectPath) { $config.projects | Add-Member -NotePropertyName $projectPath -NotePropertyValue @{allowedTools=@(); history=@(); mcpContextUris=@(); mcpServers=@{}; enabledMcpjsonServers=@(); disabledMcpjsonServers=@(); hasTrustDialogAccepted=$false} }; $config.projects.$projectPath.mcpServers.'nextjs-docs' = @{type='stdio'; command='cmd'; args=@('/c', 'npx', '-y', '@aalhommada/nextjs-docs-mcp'); env=@{}}; $config | ConvertTo-Json -Depth 100 | Set-Content '$env:USERPROFILE\.claude.json'; Write-Host 'MCP installed! Run: claude mcp list'"
Claude Code Terminal (Mac/Linux):
claude mcp add --transport stdio nextjs-docs -- npx -y @aalhommada/nextjs-docs-mcp
VS Code (Cline): Add to settings.json:
{
"mcp.servers": {
"nextjs-docs": {
"command": "npx",
"args": ["-y", "@aalhommada/nextjs-docs-mcp"]
}
}
}
Cursor: Add to MCP Settings:
{
"mcpServers": {
"nextjs-docs": {
"command": "npx",
"args": ["-y", "@aalhommada/nextjs-docs-mcp"]
}
}
}
Requirements
- Node.js >= 20.0
Usage
This package provides an MCP server that can be used with tools like Claude or other AI assistants that support the Model Context Protocol.
Available Tools
-
search_nextjs_docs
- Search the Next.js documentation for relevant information
- Input:
query(string)
-
get_nextjs_page
- Get the full content of a specific Next.js documentation page
- Input:
url(string)
-
get_nextjs_best_practices
- Get current Next.js best practices for a specific topic
- Input:
topic(string)
-
get_nextjs_cache_stats
- Get statistics about the documentation cache
- Input: none
Using with Claude Code Terminal
Windows:
npx @aalhommada/nextjs-docs-mcp install-claude
Mac/Linux:
claude mcp add --transport stdio nextjs-docs -- npx -y @aalhommada/nextjs-docs-mcp
Verify it's working:
claude mcp list
Now you can ask Claude questions about Next.js documentation in any conversation:
- "How do I implement server-side rendering in Next.js?"
- "Show me the best practices for data fetching"
- "What are the latest features in App Router?"
Using with VS Code (Cline Extension)
-
Install the Cline extension from VS Code marketplace
-
Open VS Code Settings (JSON) by pressing
Ctrl+Shift+P(orCmd+Shift+Pon Mac) and search for "Preferences: Open User Settings (JSON)" -
Add this MCP server configuration to your settings:
{
"mcp.servers": {
"nextjs-docs": {
"command": "npx",
"args": ["-y", "@aalhommada/nextjs-docs-mcp"],
"transport": "stdio"
}
}
}
- Restart VS Code and the MCP server will automatically connect when you use Cline
Now you can ask Next.js documentation questions directly in the Cline chat!
Using with Cursor
-
Open Cursor Settings:
Cursor > Settings > Cursor Settings(or pressCtrl+Shift+J/Cmd+Shift+J) -
Click on "Models" tab, scroll down to find "MCP Settings"
-
Add this configuration to your MCP settings:
{
"mcpServers": {
"nextjs-docs": {
"command": "npx",
"args": ["-y", "@aalhommada/nextjs-docs-mcp"]
}
}
}
- Restart Cursor and the MCP server will automatically connect
Now you can ask questions in Cursor's chat:
- "How do I set up middleware in Next.js 14?"
- "Show me examples of API routes"
- "What are the best practices for image optimization?"
Quick Start (npx)
You can also run the MCP server directly without installation:
npx @aalhommada/nextjs-docs-mcp
This is useful for testing or one-time usage.
Development
-
Clone the repository:
git clone https://github.com/aalhommada/nextjs-docs-mcp.git cd nextjs-docs-mcp -
Install dependencies:
npm install -
Build the project:
npm run build -
Start the server:
npm start
Performance & Security Features
Caching Strategy
- Documentation is cached for 6 hours with automatic refresh
- Maximum cache size of 500 pages
- Content truncation for large pages (100KB limit)
- Graceful degradation when scraping fails
Rate Limiting
- 30 requests per minute per client
- Automatic reset of counters
- Clear error messages when limits are exceeded
Error Handling
- Comprehensive error handling for network issues
- Fallback to stale cache when scraping fails
- Detailed logging for debugging
Technical Details
- Built with TypeScript for type safety
- Uses cheerio for HTML parsing
- Implements efficient caching mechanism
- Follows MCP server specifications
- Secure by design with rate limiting
License
MIT
Author
Abdullah Al Hommada
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.