门卫 MCP 服务器
一个MCP(Model Context Protocol)服务器,提供用于检查Maven依赖版本的工具。此服务器使大型语言模型能够验证Maven依赖项并从Maven中央仓库检索其最新版本。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"maven-deps-server": {
"command": "mcp-maven-deps"
}
}
}
服务介绍
Maven 依赖 MCP 服务器
这是一个提供工具来检查 Maven 依赖版本的 MCP(Model Context Protocol)服务器。该服务器使 LLMs 能够验证 Maven 依赖并从 Maven Central Repository 获取它们的最新版本。
安装
您可以使用 npm 全局安装此 MCP 服务器:
npm install -g mcp-maven-deps
或者直接使用 npx 运行:
npx mcp-maven-deps
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 Maven 依赖服务器:
npx -y @smithery/cli install maven-deps-server --client claude
功能
- 查询任何 Maven 依赖的最新版本
- 验证 Maven 依赖是否存在
- 检查特定版本的依赖是否存在
- 支持完整的 Maven 坐标,包括打包和分类器
- 实时访问 Maven Central Repository 数据
- 兼容多种构建工具格式(Maven、Gradle、SBT、Mill)
开发步骤:
- 克隆此仓库
- 安装依赖:
npm install - 构建服务器:
npm run build
配置
将服务器添加到您的 MCP 设置配置文件中:
{
"mcpServers": {
"maven-deps-server": {
"command": "npx",
"args": ["mcp-maven-deps"]
}
}
}
如果全局安装,您也可以使用:
{
"mcpServers": {
"maven-deps-server": {
"command": "mcp-maven-deps"
}
}
}
可用工具
get_maven_latest_version
检索 Maven 依赖的最新版本。
输入模式:
{
"type": "object",
"properties": {
"dependency": {
"type": "string",
"description": "Maven coordinate in format \"groupId:artifactId[:version][:packaging][:classifier]\" (e.g. \"org.springframework:spring-core\" or \"org.springframework:spring-core:5.3.20:jar\")"
}
},
"required": ["dependency"]
}
示例用法:
const result = await mcpClient.callTool("maven-deps-server", "get_maven_latest_version", {
dependency: "org.springframework:spring-core"
});
// Returns: "6.2.2"
check_maven_version_exists
检查特定版本的 Maven 依赖是否存在。版本可以在依赖字符串中提供,也可以作为单独的参数提供。
输入模式:
{
"type": "object",
"properties": {
"dependency": {
"type": "string",
"description": "Maven coordinate in format \"groupId:artifactId[:version][:packaging][:classifier]\" (e.g. \"org.springframework:spring-core\" or \"org.springframework:spring-core:5.3.20:jar\")"
},
"version": {
"type": "string",
"description": "Version to check if not included in dependency string"
}
},
"required": ["dependency"]
}
示例用法:
// Using version in dependency string
const result1 = await mcpClient.callTool("maven-deps-server", "check_maven_version_exists", {
dependency: "org.springframework:spring-core:5.3.20"
});
// Using separate version parameter
const result2 = await mcpClient.callTool("maven-deps-server", "check_maven_version_exists", {
dependency: "org.springframework:spring-core",
version: "5.3.20"
});
实现细节
- 使用 Maven Central 的 REST API 来获取依赖信息
- 支持完整的 Maven 坐标(groupId:artifactId:version:packaging:classifier)
- 按时间戳排序结果以确保返回最新版本
- 包括错误处理,处理无效依赖和 API 问题
- 为有效依赖返回干净、可解析的版本字符串
- 为版本存在性检查提供布尔响应
错误处理
服务器处理各种错误情况:
- 无效的依赖格式
- 无效的版本格式
- 不存在的依赖
- API 连接问题
- 格式错误的响应
- 缺失版本信息
开发
要修改或扩展服务器:
- 修改
src/index.ts - 使用
npm run build重新构建 - 重启 MCP 服务器以应用更改
许可证
MIT