Maven 依赖 MCP 服务器
一个 MCP(模型上下文协议)服务器,提供用于检查 Maven 依赖项版本的工具。此服务器使 LLM 能够验证 Maven 依赖项并从 Maven 中央存储库检索其最新版本。
安装
您可以使用 npm 全局安装此 MCP 服务器:
npm install -g mcp-maven-deps
或者直接使用 npx 运行:
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Maven Dependencies Server:
npx -y @smithery/cli install maven-deps-server --client claude
Related MCP server: cve-search_mcp
特征
对于开发:
克隆此存储库
安装依赖项: npm install
构建服务器: npm run build
配置
将服务器添加到您的 MCP 设置配置文件:
{
"mcpServers": {
"maven-deps-server": {
"command": "npx",
"args": ["mcp-maven-deps"]
}
}
}
如果全局安装,您还可以使用:
{
"mcpServers": {
"maven-deps-server": {
"command": "mcp-maven-deps"
}
}
}
交通选择
服务器支持两种传输模式:
stdio (默认)- 标准输入/输出通信
SSE (服务器发送事件)- 基于 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"]
}
}
}
可用工具
获取 Maven 最新版本
检索 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"
检查 Maven 版本是否存在
检查 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"
});
实现细节
错误处理
服务器处理各种错误情况:
依赖项格式无效
版本格式无效
不存在的依赖关系
API 连接问题
格式错误的响应
缺少版本信息
发展
要修改或扩展服务器:
修改src/index.ts
使用npm run build重建
重新启动 MCP 服务器以应用更改
执照
麻省理工学院