使用说明
PackageLens MCP
packagelens-mcp 让你的编码代理(如Claude、Cursor、Copilot、,
Gemini或Codex)跨多个生态系统的搜索包注册表
(npm、PyPI、RubyGems、Crates.io、Packagist、Hex)并获取包上下文
(README、下载、GitHub信息、使用片段)。它的特点是 聪明的
生态系统自动检测,这样你的人工智能就可以在不需要的情况下找到包裹
指定要搜索的生态系统。它充当模型上下文协议
(MCP)服务器,为您的AI助手提供结构化的发现方式
图书馆,并快速整合它们。
更新日志 | 贡献 | 查询示例 | 故障排除 | 工具参考
支持的生态系统
PackageLens MCP支持6个具有不同功能可用性的封装生态系统:
| 生态系统 | 搜索 | README | 版本 | 依赖关系 | 下载 |
|---|---|---|---|---|---|
| npm | ✅ | ✅ | ✅ | ✅ | ✅ |
| RubyGems (红宝石) | ✅ | ✅ | ✅ | ✅ | ✅ |
| 板条箱.io (生锈) | ✅ | ✅ | ✅ | ✅ | ✅ |
| 包装商 (PHP) | ✅ | ✅ | ✅ | ✅ | ✅ |
| 十六进制 (灵丹妙药) | ✅ | ✅ | ✅ | ✅ | ✅ |
| PyPI python✅ | ✅ | ✅ | ✅ | ❌* |
* PyPI不提供官方下载API
主要特点
- 🌟 智能生态系统自动检测 -询问“查找HTTP客户端” 不指定npm、PyPI等。
- 🔍 多生态系统支持:npm、PyPI、RubyGems、Crates.io、, 包装师,六角形
- 📦 具有可选排名权重的结构化包搜索
- 📄 直接获取README(可选截断)
- 📊 丰富的软件包信息(下载+GitHub详细信息)
- 🔖 版本列表和依赖关系分析
- 💡 从README中提取用法代码片段
- 🔌 Stdio MCP传输,为MCP兼容客户端做好准备
免责声明
packagelens-mcp 执行网络请求以打包注册表(npm、PyPI等),
RubyGems、Crates.io、Packagist、Hex)和GitHub。避免分享
提示中的秘密;集 GITHUB_TOKEN 只有当你想要更高的GitHub费率时
限制。
需求
- Node.js v18.17或更新版本
- npm(或pnpm)
入门
将以下配置添加到MCP客户端:
{
"mcpServers": {
"packagelens": {
"command": "npx",
"args": ["-y", "packagelens-mcp@latest"]
}
}
}
[!注意] 使用
packagelens-mcp@latest确保您的MCP客户端始终运行 最新发布的版本。
MCP客户端配置
Amp
Follow the Amp docs and use the config provided above. You can also install via CLI:amp mcp add packagelens -- npx packagelens-mcp@latest
Claude Code
Use the Claude Code CLI to add the PackageLens MCP server (see the Claude Code MCP guide):claude mcp add packagelens npx packagelens-mcp@latest
Cline
Follow and use the config provided above.Codex
Use the Codex CLI to add the server:codex mcp add packagelens -- npx packagelens-mcp@latest
Copilot CLI
启动Copilot CLI:
copilot
通过运行以下命令启动对话框以添加新的MCP服务器:
/mcp add
配置以下字段,然后按 CTRL+S 保存:
- 服务器名称:
packagelens - 服务器类型:
Local - 命令:
npx -y packagelens-mcp@latest
Copilot / VS Code
Use the VS Code CLI:code --add-mcp '{"name":"packagelens","command":"npx","args":["-y","packagelens-mcp@latest"]}'
Cursor
首选 Cursor Settings -> MCP -> New MCP Server.使用上面提供的配置。
Gemini CLI
Install the PackageLens MCP server using the Gemini CLI.项目范围:
gemini mcp add packagelens npx packagelens-mcp@latest
全球地:
gemini mcp add -s user packagelens npx packagelens-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 并使用
上面提供的配置。
您的第一个提示
输入其中一个 智能查询 (不需要生态系统!)检查是否 一切正常:
智能搜索(自动检测生态系统):
Find HTTP client libraries
Find async runtime packages for Rust
智能包裹信息(自动检测生态系统):
Tell me about react
Get info for django including README
智能使用示例:
Show me how to use axios
比较软件包:
Compare react-query, swr, and apollo-client
高级:生态系统特定查询 (当你需要控制时):
Search npm for React debounce hooks, show weekly downloads
What are the dependencies of express in npm? Include dev dependencies.
高级和本地使用
寻找JSON-RPC示例、工具模式、本地开发CLI, 故障排除或贡献者设置?
- 看
docs/advanced.md所有技术细节。 - 看
CONTRIBUTING.md为提供指导方针。
工具
PackageLens MCP提供 8工具 具有自动生态系统检测功能。 有关完整的JSON模式,请参阅 工具参考.
🌟 主要工具: smart_search
您将用于查找包的主要工具。 它会自动检测 根据您的项目或查询搜索哪个包生态系统。
检测策略:
- 查询关键字 -检测语言提及(Python、Rust、JavaScript等)
- 代码库分析 -检查当前目录中的包文件 (package.json→ npm,Cargo.toml→ Crates.io等)
- 用户澄清 -如果仍然不清楚,请询问规格
Args: query, ecosystem?, packageName?, size?
重要提示: 一旦检测到生态系统,响应就会包括一个指令
使用 ecosystem="..." 所有后续搜索中要维护的参数
一致性。除非明确要求,否则不要搜索其他生态系统。
示例:
// In a TypeScript project with package.json
{ query: "HTTP clients" }
// → Auto-detects npm, searches npm only
// Follow-up query (maintaining consistency)
{ query: "async libraries", ecosystem: "npm" }
// → Continues searching npm
// Explicit ecosystem
{ query: "web frameworks", ecosystem: "pypi" }
// → Searches PyPI regardless of project type
// With language context
{ query: "Find Rust async runtime libraries" }
// → Detects "Rust", searches Crates.io
其他智能工具
所有智能工具都支持可选 ecosystem 显式参数
规范。
包装信息:
-
smart_package_info-获取详细的包裹信息- Args:
packageName,ecosystem?,context?,includeReadme? - 示例:“告诉我反应”→ 检测npm
- Args:
-
smart_get_readme-获取包README- Args:
packageName,ecosystem?,context?,version?,truncateAt? - 示例:“获取django的README”→ 检测PyPI
- Args:
-
smart_get_usage_snippet-从README中提取代码示例- Args:
packageName,ecosystem?,context?,version? - 示例:“演示如何使用axios”→ 检测npm
- Args:
版本和依赖关系:
-
smart_get_versions-列出软件包版本- Args:
packageName,context?,limit?,since? - 示例:“显示tokio的版本”→ 检测Crates.io
- Args:
-
smart_get_dependencies-获取包依赖关系- Args:
packageName,context?,version? - 示例:“表达依赖于什么?”→ 检测npm
- Args:
下载:
smart_get_downloads-获取下载统计信息- Args:
packageName,context?,period? - 示例:“flask有多少下载?”→ 检测PyPI
- Args:
比较:
compare_packages-比较不同生态系统的包- Args:
items[]随着{ecosystem, name}物体 - 示例:比较axios(npm)、requests(PyPI)、httparty(RubyGems)
- Args:
示例使用查询
PackageLens MCP支持两种查询样式: 智能查询 (自动 检测)和 具体查询 (明确的生态系统)。曾经的生态系统 如果检测到,请使用相同的生态系统进行后续查询以进行维护 一致性。
🌟 智能查询(自动检测)
使用语言上下文进行初始搜索:
Find Python HTTP client libraries
→ Detects PyPI from "Python" keyword
→ Response: "Use ecosystem='pypi' for follow-up searches"
Search for Rust async libraries
→ Detects Crates.io from "Rust" keyword
→ Response: "Use ecosystem='crates' for follow-up searches"
在项目目录中的初始搜索:
Find HTTP client libraries
→ In TypeScript project with package.json
→ Detects npm from codebase
→ Response: "Use ecosystem='npm' for follow-up searches"
Search for async runtime packages
→ In Rust project with Cargo.toml
→ Detects Crates.io from codebase
→ Response: "Use ecosystem='crates' for follow-up searches"
后续搜索(保持一致性):
Initial: "Find Python web frameworks"
→ Detects PyPI, finds django, flask, fastapi
Follow-up: "Show me more async frameworks" (with ecosystem='pypi')
→ Continues searching PyPI only
→ Finds aiohttp, starlette, tornado
Initial: "Search for JavaScript testing libraries"
→ Detects npm, finds jest, mocha, vitest
Follow-up: "Find assertion libraries" (with ecosystem='npm')
→ Continues searching npm only
→ Finds chai, expect, should
具有自动检测功能的包裹信息:
Tell me about react
→ Detects npm from well-known package name
Get info for django including README
→ Detects PyPI from well-known package name
Show me details for tokio
→ Detects Crates.io from well-known package name
使用示例:
Show me how to use axios
→ Detects npm, extracts usage snippet from README
Get usage example for requests
→ Detects PyPI, extracts usage snippet from README
版本和依赖关系:
What versions of react are available?
→ Detects npm, lists recent versions
What does express depend on?
→ Detects npm, shows dependency tree
下载:
How many downloads does django have?
→ Detects PyPI (note: PyPI doesn't provide download stats)
Show me weekly downloads for lodash
→ Detects npm, shows weekly download count
跨生态系统比较(明确意图):
Compare axios from npm with requests from PyPI
→ Compares HTTP clients across ecosystems
Compare react, vue, and angular
→ All detected as npm packages, compares within npm
🎯 特定查询(显式生态系统)
当您需要精确控制或想要覆盖自动检测时,请使用这些:
明确的生态系统搜索:
Search npm for React debounce hooks
→ Uses npm regardless of project type
Search crates for tokio alternatives
→ Uses Crates.io regardless of project type
保持与显式参数的一致性:
Initial: "Find web frameworks" (in TypeScript project)
→ Detects npm
Follow-up: Search for "validation libraries" with ecosystem="npm"
→ Continues in npm (recommended approach)
切换生态系统(需要时):
Initial: "Find Python web frameworks"
→ Detects PyPI, finds django, flask
Explicit switch: "Now search npm for web frameworks"
→ Explicitly switches to npm ecosystem
具体包裹查询:
Get info for @types/node from npm
→ Scoped package, explicitly npm
Show README for symfony/console from packagist
→ Vendor/package format, explicitly Packagist
高级依赖关系查询:
What are the dependencies of express in npm? Include dev dependencies.
→ Explicit npm query with dev dependencies
Show me versions of tokio from crates published in last 6 months
→ Explicit crates query with time filter
💡 最佳实践
- 第一个查询:使用语言上下文(“Python”、“Rust”)或let 代码库检测工作
- 后续查询:使用
ecosystem第一个参数 响应 - 比较:只有在明确的情况下,才能跨生态系统进行比较 比较备选方案
- 特定套餐:众所周知的包名称能够可靠地自动检测 (反应→ npm,django→ PyPI)
许可和贡献
封装透镜MCP 麻省理工学院许可。欢迎投稿! 请看 贡献.md 作为指导方针。
发现错误或有功能请求?打开一个问题 GitHub.
由以下材料制成❤️ 为vibe编码社区。编码愉快!
