封装Intel MCP服务器
一个模型上下文协议(MCP)服务器,用于查询包注册表(npm、PyPI、crates.io),以检索有关包的元数据,包括版本、发布节奏和维护信号。
特性
- 多注册表支持:从单个接口查询npm、PyPI和crates.io
- 包装摘要:获取全面的包元数据,包括版本、许可证和存储库信息
- 发布时间表:检索包含发布日期的版本历史记录
- 维护信号:使用自动评分分析包裹健康状况
安装
npm install
npm run build用法
作为MCP服务器(stdio)
npm start作为HTTP服务器
npm run start:http
# Or with custom port
PORT=8080 npm run start:httpClaude桌面配置
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"package-intel": {
"command": "node",
"args": ["/path/to/package-intel/dist/cli.js"]
}
}
}工具
包_摘要
获取有关包的摘要信息。
参数:
ecosystem(必填):"npm"|"pypi"|"crates"name(必填):包名称
例子:
{
"ecosystem": "npm",
"name": "lodash"
}答复:
{
"ok": true,
"data": {
"name": "lodash",
"version": "4.17.21",
"description": "Lodash modular utilities.",
"homepage": "https://lodash.com/",
"repository": "https://github.com/lodash/lodash",
"license": "MIT",
"keywords": ["modules", "stdlib", "util"]
},
"meta": {
"source": "https://registry.npmjs.org/lodash",
"retrieved_at": "2024-01-15T10:30:00.000Z",
"pagination": { "next_cursor": null },
"warnings": []
}
}release_timeline
获取包的发布历史记录。
参数:
ecosystem(必填):"npm"|"pypi"|"crates"name(必填):包名称limit(可选):要返回的最大版本数(默认值:20,最大值:100)
例子:
{
"ecosystem": "pypi",
"name": "requests",
"limit": 5
}答复:
{
"ok": true,
"data": {
"package_name": "requests",
"ecosystem": "pypi",
"releases": [
{
"version": "2.31.0",
"date": "2023-05-22T10:00:00.000Z",
"is_prerelease": false
},
{
"version": "2.30.0",
"date": "2023-05-01T10:00:00.000Z",
"is_prerelease": false
}
],
"total_versions": 87
},
"meta": {
"source": "https://pypi.org/pypi/requests/json",
"retrieved_at": "2024-01-15T10:30:00.000Z",
"pagination": { "next_cursor": "5" },
"warnings": []
}
}维护_信号
分析包的维护健康信号。
参数:
ecosystem(必填):"npm"|"pypi"|"crates"name(必填):包名称
例子:
{
"ecosystem": "crates",
"name": "serde"
}答复:
{
"ok": true,
"data": {
"package_name": "serde",
"ecosystem": "crates",
"days_since_last_release": 45,
"last_release_date": "2023-12-01T10:00:00.000Z",
"releases_per_year": 12.5,
"total_versions": 156,
"is_deprecated": false,
"maintenance_score": "good",
"score_factors": {
"recency": "good",
"frequency": "good",
"maturity": "good"
}
},
"meta": {
"source": "https://crates.io/api/v1/crates/serde",
"retrieved_at": "2024-01-15T10:30:00.000Z",
"pagination": { "next_cursor": null },
"warnings": []
}
}维修评分计算
维修分数基于三个因素计算:
近期(50%重量)
- 好:最后发布时间\=365天前
频率(30%权重)
- 好:>=每年4次发布
- 公平的:>=每年发布一次
- 贫穷的:每年发布\=总共10个版本
- 公平的:>=总共3个版本
- 贫穷的:总共\<3个版本
如果一个包被弃用,分数会自动设置为“差”。
错误处理
所有工具都以一致的信封格式返回错误:
{
"ok": false,
"error": {
"code": "INVALID_INPUT",
"message": "Package 'nonexistent' not found on npm",
"details": {
"package": "nonexistent",
"ecosystem": "npm"
}
},
"meta": {
"retrieved_at": "2024-01-15T10:30:00.000Z"
}
}错误代码
INVALID_INPUT:找不到无效参数或包UPSTREAM_ERROR:注册表API返回意外错误RATE_LIMITED:超出注册表速率限制TIMEOUT:请求超时PARSE_ERROR:无法解析注册表响应INTERNAL_ERROR:意外的服务器错误
配置
环境变量(参见 .env.example):
| 变量 | 默认值 | 描述 |
|---|---|---|
PORT | 3000 | HTTP服务器端口 |
REQUEST_TIMEOUT | 30000 | 请求超时(毫秒) |
USER_AGENT | package-intel/0.1.0 | 注册表请求的用户代理 |
CACHE_TTL | 300 | 缓存TTL(秒) |
LOG_LEVEL | info | 日志级别:调试、信息、警告、错误 |
发展
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Type check
npm run typecheck
# Development mode (watch)
npm run dev许可证
麻省理工学院
