Purpose: npm-package-docs-mcp is a Model Context Protocol (MCP) tool designed to let IDEs (such as Cursor) directly retrieve the latest documentation for npm packages. It addresses the problem that package documentation in IDEs may be outdated or incomplete, helping developers understand a package's API and usage based on the latest README.
Main capabilities:
- GitHub repository first: If a package has a GitHub repository, the tool retrieves the README directly from the repository's main branch, attempting the master, main, or develop branches.
- npm package fallback: If a package has no available GitHub repository, the tool downloads the package's tarball and extracts the README file from it.
- Real-time updates: Always retrieves the latest documentation, ensuring the information is for the current version.
- Provides the tool function get_docs_for_npm_package: accepts packageName (a string, such as "react", "lodash", "express") and returns the README content text.
- Workflow: Query the npm registry to get package metadata → detect whether a GitHub repository URL exists → if so, retrieve README.md from the main branch → if not, download and extract the tarball to find the README → return the documentation content to the IDE.
Usage:
- Environment requirements: Node.js (v16 or higher), and Cursor IDE or another MCP-compatible IDE.
- Configuration: Edit the Cursor MCP configuration file (usually located at ~/.cursor/mcp.json), then restart the Cursor IDE to load the new MCP server.
- Invocation: Open the command palette in Cursor (Cmd/Ctrl + Shift + P) and enter a request, such as "Get docs for express", "Show me the latest react documentation", "What's new in lodash v4?", and the tool will retrieve and display the current documentation for the corresponding package.
Use cases:
- Developers querying the latest README documentation for npm packages within the IDE, avoiding reliance on outdated or incomplete IDE hints.
- Needing to accurately understand a package's API and usage patterns, reducing errors caused by outdated API references or deprecated methods.
- Wanting seamless integration of documentation lookup via the MCP protocol without leaving the IDE.
Limitations:
- Requires Node.js v16 or higher, and Cursor IDE or any MCP-compatible IDE.
- The documentation source depends on the package's GitHub repository main branch or the README included in the npm package; if neither is available, it cannot be retrieved.
- The official materials do not provide pricing or fee information beyond the license; the license is MIT, see the LICENSE file for details.
- The official materials do not provide specific information on other platform support, performance data, or usage results.
The project also includes instructions on running in development mode, production builds, project structure, and more, and welcomes contributions via Pull Request. If you encounter problems, you can submit an issue in the GitHub repository.