<a href="https://www.npmjs.com/package/mcp-maven-deps"><img src="https://img.shields.io/npm/v/mcp-maven-deps.svg" alt="npm 版本" /></a>
这是一个提供工具来检查 Maven 依赖版本的 MCP(模型上下文协议)服务器。该服务器使大语言模型能够验证 Maven 依赖并从 Maven 中央仓库检索其最新版本。
<a href="https://glama.ai/mcp/servers/juuo2ye0qi"><img width="380" height="200" src="https://gips1.baidu.com/it/u=1295603139,813592466&fm=3081&app=3081&f=PNG?w=760&h=400" alt="maven-mcp-server MCP 服务器" /></a>
你可以通过 npm 全局安装这个 MCP 服务器:
npm install -g mcp-maven-deps
或者直接使用 npx 运行:
npx mcp-maven-deps
要自动通过 Smithery 安装 Maven 依赖服务器到 Claude Desktop:
npx -y @smithery/cli install maven-deps-server --client claude
对于开发:
npm installnpm run build在你的 MCP 设置配置文件中添加服务器:
{
"mcpServers": {
"maven-deps-server": {
"command": "npx",
"args": ["mcp-maven-deps"]
}
}
}
如果全局安装,也可以使用:
{
"mcpServers": {
"maven-deps-server": {
"command": "mcp-maven-deps"
}
}
}
服务器支持两种传输模式:
要使用 SSE 传输,可以指定主机和端口:
# 仅本地访问(默认主机:localhost)
npx mcp-maven-deps --port=3000
# 远程访问
npx mcp-maven-deps --host=0.0.0.0 --port=3000
在使用 SSE 传输时,在你的 MCP 设置中:
{
"mcpServers": {
"maven-deps-server": {
"command": "npx",
"args": ["mcp-maven-deps", "--port=3000"]
}
}
}
对于远程访问,在客户端配置中使用服务器的 IP 或主机名:
{
"mcpServers": {
"maven-deps-server": {
"command": "npx",
"args": ["mcp-maven-deps", "--host=your-server-ip", "--port=3000"]
}
}
}
检索 Maven 依赖的最新稳定发布版本。默认情况下,这会排除预发布版本(alpha、beta、里程碑、RC、快照),以确保你获得生产就绪版本。
输入模式:
{
"type": "object",
"properties": {
"dependency": {
"type": "string",
"description": "Maven 坐标,格式为 \"groupId:artifactId[:version][:packaging][:classifier]\"(例如 \"org.springframework:spring-core\" 或 \"org.springframework:spring-core:5.3.20:jar\")"
},
"excludePreReleases": {
"type": "boolean",
"description": "是否排除预发布版本(alpha、beta、里程碑、RC、快照)。默认值:true",
"default": true
}
},
"required": ["dependency"]
}
示例用法:
// 获取最新稳定版本(默认行为)
const result1 = await mcpClient.callTool("maven-deps-server", "get_latest_release", {
dependency: "org.springframework:spring-core"
});
// 返回:"6.2.8"(最新的稳定版本,排除 "7.0.0-M6" 里程碑)
// 如果需要包含预发布版本
const result2 = await mcpClient.callTool("maven-deps-server", "get_latest_release", {
dependency: "org.springframework:spring-core",
excludePreReleases: false
});
// 返回:"7.0.0-M6"(包括预发布版本)
检查特定版本的 Maven 依赖是否存在。版本可以在依赖字符串中提供,也可以作为单独的参数提供。
输入模式:
{
"type": "object",
"properties": {
"dependency": {
"type": "string",
"description": "Maven 坐标,格式为 \"groupId:artifactId[:version][:packaging][:classifier]\"(例如 \"org.springframework:spring-core\" 或 \"org.springframework:spring-core:5.3.20:jar\")"
},
"version": {
"type": "string",
"description": "如果未包含在依赖字符串中,则要检查的版本"
}
},
"required": ["dependency"]
}
示例用法:
// 使用依赖字符串中的版本
const result1 = await mcpClient.callTool("maven-deps-server", "check_maven_version_exists", {
dependency: "org.springframework:spring-core:5.3.20"
});
// 使用单独的版本参数
const result2 = await mcpClient.callTool("maven-deps-server", "check_maven_version_exists", {
dependency: "org.springframework:spring-core",
version: "5.3.20"
});
列出按最后更新日期排序(最近的优先)的 Maven 依赖版本,并可选地过滤预发布版本和控制深度。
输入模式:
{
"type": "object",
"properties": {
"dependency": {
"type": "string",
"description": "Maven 坐标,格式为 \"groupId:artifactId[:packaging][:classifier]\"(例如 \"org.springframework:spring-core\" 或 \"org.springframework:spring-core:jar\")"
},
"depth": {
"type": "number",
"description": "要返回的版本数量(默认:15)",
"minimum": 1,
"maximum": 100
},
"excludePreReleases": {
"type": "boolean",
"description": "是否排除预发布版本(alpha、beta、里程碑、RC、快照)。默认值:true",
"default": true
}
},
"required": ["dependency"]
}
示例用法:
// 获取最后 15 个稳定版本(默认 - 排除预发布版本)
const result1 = await mcpClient.callTool("maven-deps-server", "list_maven_versions", {
dependency: "org.springframework:spring-core"
});
// 返回只有稳定版本:"6.2.8 (2025-06-12)\n6.1.21 (2025-06-12)\n6.2.7 (2025-05-15)\n..."
// 获取最后 5 个版本,包括预发布版本
const result2 = await mcpClient.callTool("maven-deps-server", "list_maven_versions", {
dependency: "org.springframework:spring-core",
depth: 5,
excludePreReleases: false
});
// 返回:"7.0.0-M6 (2025-06-12)\n6.2.8 (2025-06-12)\n6.1.21 (2025-06-12)\n7.0.0-M5 (2025-05-15)\n6.2.7 (2025-05-15)"
服务器自动检测预发布版本,使用以下模式:
-alpha,-a-beta,-b-milestone,-m,-M-rc,-cr-snapshot示例:
7.0.0-M6 → 预发布(里程碑)6.2.8 → 稳定发布3.1.0-SNAPSHOT → 预发布(快照)2.5.0-RC1 → 预发布(候选发布)重大变更说明:工具已从 get_maven_last_updated_version 重命名为 get_latest_release,并且现在默认排除预发布版本。这确保了生产应用程序默认获得稳定版本,同时仍然允许访问预发布版本。
服务器处理各种错误情况:
要修改或扩展服务器:
src/index.tsnpm run build 重新构建MIT