mcpField
M
Maven Dependencies MCP Server

Maven Dependencies MCP Server

本地服务
github.com/Bigsy开发工具3427 周前更新

关于 Maven Dependencies MCP Server

Maven Dependencies MCP Server 是一个用于检查 Maven 依赖版本的 MCP 服务,可从 Maven Central 获取依赖的最新稳定版本。它面向需要在 LLM 中核实 Maven 依赖的开发者,默认排除预发布版本。

主要功能

  1. 01获取最新稳定版本
  2. 02检查依赖版本是否存在
  3. 03列出依赖的历史版本
  4. 04自动识别预发布版本
  5. 05支持完整 Maven 坐标
  6. 06支持 stdio 与 SSE 传输方式

适用场景

  1. 01让 LLM 核实 Maven 依赖的最新稳定版本
  2. 02检查项目中指定的依赖版本是否存在
  3. 03查看依赖最近发布的版本列表

MCP 相关

该项目是一个 MCP 服务,向 MCP 客户端提供查询 Maven Central 依赖版本的工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"maven": {
"command": "npx",
"args": [
"-y",
"mcp-maven-deps"
]
}
}
}
启动命令npx -y mcp-maven-deps

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmmcp-maven-deps

工具

3

收录的工具列表 · 更新于 3 周前

参数类型必填说明
dependencystring是格式为 "groupId:artifactId[:version][:packaging][:classifier]" 的 Maven 坐标(例如 "org.springframework:spring-core" 或 "org.springframework:spring-core:5.3.20:jar")
excludePreReleasesboolean否是否排除预发布版本(alpha、beta、milestone、RC、snapshot)。默认值:true

详细介绍

npm version

Maven 依赖项 MCP 服务

一个用于检查 Maven 依赖项版本的 MCP(Model Context Protocol)服务。此服务可让大模型验证 Maven 依赖项,并从 Maven Central Repository 获取其最新版本。

maven-mcp-server MCP server

安装

你可以使用 npm 全局安装此 MCP 服务:

npm install -g mcp-maven-deps

也可以使用 npx 直接运行:

npx mcp-maven-deps
通过 Smithery 安装

要通过 Smithery 为 Claude Desktop 自动安装 Maven Dependencies Server:

npx -y @smithery/cli install maven-deps-server --client claude

功能

  • 获取任意 Maven 依赖项的最新稳定版本(默认排除预发布版本)
  • 验证 Maven 依赖项是否存在
  • 检查依赖项的特定版本是否存在
  • 列出 Maven 依赖项版本,并可选择筛选预发布版本
  • 智能检测预发布版本(alpha、beta、milestone、RC、snapshot)
  • 支持包含 packaging 和 classifier 在内的完整 Maven 坐标
  • 实时访问 Maven Central Repository 数据
  • 兼容多种构建工具格式(Maven、Gradle、SBT、Mill)

开发步骤:

  1. 克隆此仓库
  2. 安装依赖项:npm install
  3. 构建服务:npm run build

配置

将服务添加到 MCP 设置配置文件中:

{
  "mcpServers": {
    "maven-deps-server": {
      "command": "npx",
      "args": ["mcp-maven-deps"]
    }
  }
}

如果是全局安装,也可以使用:

{
  "mcpServers": {
    "maven-deps-server": {
      "command": "mcp-maven-deps"
    }
  }
}

传输选项

此服务支持两种传输模式:

  1. stdio(默认)- 标准输入/输出通信
  2. SSE(Server-Sent Events)- 基于 HTTP 的通信,可选远程访问

要使用 SSE 传输,可以指定主机和端口:

# Local access only (default host: localhost)
npx mcp-maven-deps --port=3000

# Remote access
npx mcp-maven-deps --host=0.0.0.0 --port=3000

在 MCP 设置中使用 SSE 传输时:

{
  "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"]
    }
  }
}

可用工具

get_latest_release

获取 Maven 依赖项的最新稳定版本。默认排除预发布版本(alpha、beta、milestone、RC、snapshot),确保获取可用于生产环境的版本。

输入架构:

{
  "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\")"
    },
    "excludePreReleases": {
      "type": "boolean",
      "description": "Whether to exclude pre-release versions (alpha, beta, milestone, RC, snapshot). Default: true",
      "default": true
    }
  },
  "required": ["dependency"]
}

使用示例:

// Get latest stable release (default behavior)
const result1 = await mcpClient.callTool("maven-deps-server", "get_latest_release", {
  dependency: "org.springframework:spring-core"
});
// Returns: "6.2.8" (latest stable, excludes "7.0.0-M6" milestone)

// Include pre-releases if needed
const result2 = await mcpClient.callTool("maven-deps-server", "get_latest_release", {
  dependency: "org.springframework:spring-core",
  excludePreReleases: false
});
// Returns: "7.0.0-M6" (includes pre-releases)
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"
});
list_maven_versions

按发布顺序列出 Maven 依赖项版本,最新版本在前,并可选择筛选预发布版本和控制深度。输出为每行一个版本。

输入架构:

{
  "type": "object",
  "properties": {
    "dependency": {
      "type": "string",
      "description": "Maven coordinate in format \"groupId:artifactId[:packaging][:classifier]\" (e.g. \"org.springframework:spring-core\" or \"org.springframework:spring-core:jar\")"
    },
    "depth": {
      "type": "number",
      "description": "Number of versions to return (default: 15)",
      "minimum": 1,
      "maximum": 100
    },
    "excludePreReleases": {
      "type": "boolean",
      "description": "Whether to exclude pre-release versions (alpha, beta, milestone, RC, snapshot). Default: true",
      "default": true
    }
  },
  "required": ["dependency"]
}

使用示例:

// Get last 15 stable versions (default - excludes pre-releases)
const result1 = await mcpClient.callTool("maven-deps-server", "list_maven_versions", {
  dependency: "org.springframework:spring-core"
});
// Returns only stable versions: "6.2.8\n6.1.21\n6.2.7\n..."

// Get last 5 versions including pre-releases
const result2 = await mcpClient.callTool("maven-deps-server", "list_maven_versions", {
  dependency: "org.springframework:spring-core",
  depth: 5,
  excludePreReleases: false
});
// Returns: "7.0.0-M6\n6.2.8\n6.1.21\n7.0.0-M5\n6.2.7"

实现详情

  • 直接查询 Maven Central 上的 maven-metadata.xml(https://repo1.maven.org/maven2/<g>/<a>/maven-metadata.xml)——这是 Maven 和 Gradle 在解析依赖项时会查阅的权威文件。部署后几秒内即会更新,因此结果始终是最新的。
  • 支持完整 Maven 坐标(groupId:artifactId:version:packaging:classifier)
  • 使用正则表达式模式匹配,智能检测预发布版本
  • 按 maven-metadata.xml 中记录的发布顺序返回版本,最新版本在前
  • 针对无效依赖项和 API 问题提供错误处理
  • 对有效依赖项返回简洁、可解析的版本字符串
  • 对版本存在性检查返回布尔值

预发布版本检测

服务器会使用以下模式自动检测预发布版本:

  • Alpha:-alpha、-a
  • Beta:-beta、-b
  • Milestone:-milestone、-m、-M
  • Release Candidate:-rc、-cr
  • Snapshot:-snapshot

示例:

  • 7.0.0-M6 → 预发布版本(milestone)
  • 6.2.8 → 稳定版本
  • 3.1.0-SNAPSHOT → 预发布版本(snapshot)
  • 2.5.0-RC1 → 预发布版本(release candidate)

重大变更说明: 该工具已从 get_maven_last_updated_version 重命名为 get_latest_release,现在默认会排除预发布版本。这样可确保生产应用默认使用稳定版本,同时仍可按需访问预发布版本。

错误处理

服务器会处理各种错误情况:

  • 依赖项格式无效
  • 版本格式无效
  • 依赖项不存在
  • 未找到稳定版本(启用筛选时)
  • API 连接问题
  • 响应格式错误
  • 缺少版本信息

开发

若要修改或扩展服务器:

  1. 修改 src/index.ts
  2. 使用 npm run build 重新构建
  3. 重启 MCP 服务以应用更改

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。