NPMLens MCP
npmlens-mcp 让你的编码代理(如Claude、Cursor、Copilot、, Gemini或Codex)搜索npm注册表并获取包上下文 (README、下载、GitHub信息、使用片段)。它充当一个 模型上下文协议(MCP)服务器,为您的AI助手提供 结构化的方法来发现库并快速整合它们。
主要特点
- 具有可选排名权重的结构化npm搜索。
- 直接获取README(可选截断)。
- 丰富的软件包信息(下载+GitHub详细信息)。
- 从README中提取用法代码片段。
- Stdio MCP传输,为MCP兼容客户端做好准备。
免责声明
npmlens-mcp 当工具处于以下状态时,向npm和GitHub执行网络请求 使用。避免在提示中分享秘密;集 GITHUB_TOKEN 只要你 想要更高的GitHub速率限制。
需求
- Node.js v18.17或更新版本
- npm(或pnpm)
入门
将以下配置添加到MCP客户端:
{
"mcpServers": {
"npmlens": {
"command": "npx",
"args": ["-y", "npmlens-mcp@latest"]
}
}
}\[!注意\] 使用 npmlens-mcp@latest 确保您的MCP客户端始终运行 最新发布的版本。MCP客户端配置
Amp Follow the Amp docs and use the config provided above. You can also install via CLI:
amp mcp add npmlens -- npx npmlens-mcp@latestClaude Code Use the Claude Code CLI to add the NPMLens MCP server (see the Claude Code MCP guide):
claude mcp add npmlens npx npmlens-mcp@latestCline Follow and use the config provided above.
Codex Use the Codex CLI to add the server:
codex mcp add npmlens -- npx npmlens-mcp@latestCopilot CLI
启动Copilot CLI:
copilot通过运行以下命令启动对话框以添加新的MCP服务器:
/mcp add配置以下字段,然后按 CTRL+S 保存:
- 服务器名称:
npmlens - 服务器类型:
Local - 命令:
npx -y npmlens-mcp@latest
Copilot / VS Code Use the VS Code CLI:
code --add-mcp '{"name":"npmlens","command":"npx","args":["-y","npmlens-mcp@latest"]}'Cursor
首选 Cursor Settings -> MCP -> New MCP Server.使用上面提供的配置。
Gemini CLI Install the NPMLens MCP server using the Gemini CLI.
项目范围:
gemini mcp add npmlens npx npmlens-mcp@latest全球地:
gemini mcp add -s user npmlens npx npmlens-mcp@latest或者,遵循Gemini CLI MCP指南并使用标准 从上面配置。
Gemini Code Assist Follow the provider guide to configure MCP servers and use the standard config from above.
JetBrains AI Assistant & Junie
首选 Settings | Tools | AI Assistant | Model Context Protocol (MCP) -> Add.使用上面提供的配置。Junie也是如此 Settings | Tools | Junie | MCP Settings -> Add.
Warp
首选 Settings | AI | Manage MCP Servers -> + Add 并使用 上面提供的配置。
您的第一个提示
在MCP客户端中输入以下提示之一,检查是否一切正常:
基本搜索和信息:
Find 5 React debounce hook libraries, include weekly downloads, and
fetch the README for the top result.比较软件包:
Compare react-query, swr, and apollo-client. Show me their weekly
downloads, GitHub stars, and licenses.版本历史:
Show me all TypeScript versions released in the last 6 months with
their publish dates.依赖关系:
What are the dependencies of express? Include dev dependencies.______________________________________________________________________
高级和本地使用
寻找JSON-RPC示例、工具模式、本地开发CLI, 故障排除或贡献者设置?
- 看
docs/advanced.md所有技术细节。 - 看
CONTRIBUTING.md为提供指导方针。
工具
以下是NPMLens MCP公开的工具。有关完整的JSON模式,请参阅 这 工具参考.
核心搜索和信息
search_npm
- 使用可选的排名权重搜索npm注册表。 - Args: query (字符串,必填), size (1..250), from (偏移), weights (对象与 quality, popularity, maintenance). - 退货: { total, results[] } 其中每个结果包括 name, version, description, links, score等等。
search_by_keywords
- 使用AND/OR运算符按特定关键字/标签搜索npm包。 - Args: keywords (字符串数组,必填), operator (AND | OR,默认值 AND), size (1..250). - 退货:与 search_npm. - 示例:查找带有“react”、“hooks”和“typescript”的包。
get_readme
- 获取包的README标记(可选按版本)。 - Args: name (字符串,必填), version (字符串), truncateAt (数字)。 - 返回:JSON元数据(name, version, repository, homepage) README作为文本内容。
get_package_info
- 丰富的包信息,结合注册表元数据、npm下载、, 以及GitHub的详细信息。 - Args: name (字符串,必填), version (字符串), includeReadme (布尔值)。 - 退货: name, version, repository, homepage, github{ fullName, url, stars, forks, license }, downloadsLastWeek,以及 可选的 readme.
get_usage_snippet
- 从README包中提取一个可能的用法片段。 - Args: name (字符串,必填), version (字符串)。 - 退货: { snippet: { language, code, heading } }.
版本和依赖性分析
get_package_versions
- 列出包含发布日期和dist的包的所有可用版本 标签。 - Args: name (字符串,必填), limit (数字), since (字符串- ISO日期或类似“6个月”的相对日期)。 - 退货: { name, versions[] } 其中每个版本包括 version, date, tags[]. - 示例:“显示去年的所有React版本”。
get_package_dependencies
- 获取包的依赖树。 - Args: name (字符串,必填), version (字符串), depth (1-3, 默认值1), includeDevDependencies (布尔值)。 - 退货: { name, version, dependencies[], devDependencies[] } 随着 每个依赖项的名称和版本范围。 - 示例:“express有什么依赖关系?”。
度量与比较
get_downloads
- 获取最后一次的npm下载 day/week/month. - Args: name (字符串,必填), period (day | week | month, 默认 week). - 退货: { downloads, start, end, package }.
compare_packages
- 并排比较多个npm包。 - Args: packages (1-10个包名称的数组,必填)。 - 返回值:具有以下值的比较数据数组 name, version, description, downloads, stars, forks, license, repository, homepage,可选 error. - 并行获取所有包以提高性能。 - 示例:“比较react-query、swr和apollo客户端”。
示例使用查询
以下是您可以与AI助手一起使用的示例查询,以测试所有 9个NPMLens工具:
search_npm
Search npm for react testing librariesFind packages related to "typescript validation" and show me the top 5 resultsget_adme
Show me the README for expressGet the README for react version 18.0.0get_package_info
Get detailed information about the lodash packageTell me about the vite package including GitHub stats and download numbersget_downloads
How many downloads does react have in the last week?Show me download statistics for next for the last monthget_usage_snippet
Show me a usage example for axiosHow do I use the commander package? Give me a code snippet.get_package_versions
List all versions of React from the last yearShow me the version history of TypeScript since 6 months agoget_package_dependency
What dependencies does express have?Show me the dependency tree for next with depth 2compare_包
Compare react, vue, and angularCompare the packages axios, fetch, and node-fetch and help me decide which to use搜索_关键字
Find packages with keywords "react" AND "hooks" AND "typescript"Search for packages with keywords "cli" OR "terminal"组合查询
你也可以让你的人工智能助手同时使用多种工具:
Compare react-query, swr, and apollo-client, then show me usage examples for the most popular oneSearch for typescript validation libraries, then show me the README and dependencies for the top resultFind the package "zod", show me its download stats, version history, and a usage example许可和贡献
NPMLens MCP是 麻省理工学院许可。欢迎投稿! 请看 贡献.md 作为指导方针。
发现错误或有功能请求?打开一个问题 .
______________________________________________________________________
由以下材料制成❤️ 为vibe编码社区。编码愉快!
