MCP Harbor
MCP 港
MCP Harbor 是一个 Node.js 应用,它提供了一个模型上下文协议 (MCP) 服务器,用于与 Harbor 容器注册表进行交互。它还包含一个用于 Harbor 操作的 REST API。
目录
Related MCP server: MCP Server
特征
MCP 服务器:通过模型上下文协议公开与 Harbor 交互的工具
REST API :为 Harbor 操作提供 RESTful 端点
Harbor Operations :支持项目、存储库、标签和 Helm 图表的操作
TypeScript :用 TypeScript 编写,以获得更好的类型安全性和开发人员体验
自动化测试:全面的测试套件,确保可靠的功能
先决条件
在安装 MCP Harbor 之前,请确保您已:
Node.js 18.x 或更高版本
npm 8.x 或更高版本
访问 Harbor 注册表实例
Git(用于克隆存储库)
安装
克隆存储库:
git clone https://github.com/nomagicln/mcp-harbor.git导航到项目目录:
cd mcp-harbor安装依赖项:
npm install构建项目:
npm run build启动应用程序:
npm start
配置
环境变量
在根目录中创建一个.env文件,其中包含以下变量:
# Required
HARBOR_URL=https://your-harbor-instance.com
HARBOR_USERNAME=your_username
HARBOR_PASSWORD=your_password
# Optional
PORT=3000 # Server port (default: 3000)
LOG_LEVEL=info # Logging level (default: info)
ENABLE_HTTPS=false # Enable HTTPS (default: false)
SSL_CERT_PATH=/path/to/cert.pem # Required if ENABLE_HTTPS=true
SSL_KEY_PATH=/path/to/key.pem # Required if ENABLE_HTTPS=true配置文件
可以在src/config/harbor.config.ts中设置其他配置选项:
{
timeout: 30000, // API request timeout in milliseconds
retryAttempts: 3, // Number of retry attempts for failed requests
cacheEnabled: true, // Enable response caching
cacheTTL: 300 // Cache TTL in seconds
}API 端点
项目
GET /projects- 列出所有项目GET /projects/:id- 获取项目详细信息POST /projects- 创建新项目DELETE /projects/:id- 删除项目
存储库
GET /projects/:projectId/repositories- 列出项目中的存储库DELETE /projects/:projectId/repositories/:repositoryName- 删除存储库
标签
GET /projects/:projectId/repositories/:repositoryName/tags- 列出存储库中的标签DELETE /projects/:projectId/repositories/:repositoryName/tags/:tag- 删除标签
Helm Charts
GET /projects/:projectId/charts- 列出项目中的 Helm 图表GET /projects/:projectId/charts/:chartName/versions- 列出 Helm chart 的版本DELETE /projects/:projectId/charts/:chartName/versions/:version- 删除 Helm 图表版本
MCP 工具
MCP 服务器公开以下工具:
工具名称 | 描述 | 参数 |
| 列出 Harbor 中的所有项目 | 没有任何 |
| 通过ID获取项目详细信息 |
|
| 创建新项目 |
|
| 删除项目 |
|
| 列出项目中的存储库 |
|
| 删除存储库 |
|
| 列出存储库中的标签 |
|
| 删除标签 |
|
| 列出 Helm 图表 |
|
| 列出图表版本 |
|
| 删除图表版本 |
|
发展
以开发模式运行
npm run dev运行测试
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run specific test file
npm test -- test/harbor.test.ts调试工具
该项目在tools目录中包含调试工具:
# Test Harbor connection
npm run test:connection
# Start debug server
npm run debug:server项目结构
mcp-harbor
├── src
│ ├── app.ts # Main application entry point (MCP server)
│ ├── config
│ │ └── harbor.config.ts # Harbor configuration
│ ├── controllers
│ │ └── harbor.controller.ts # REST API controllers
│ ├── services
│ │ └── harbor.service.ts # Harbor service implementation
│ ├── models
│ │ └── harbor.model.ts # Data models
│ ├── routes
│ │ └── harbor.routes.ts # API route definitions
│ └── types
│ └── index.ts # TypeScript type definitions
├── test
│ └── harbor.test.ts # Tests for Harbor service
├── tools
│ ├── debug-server.ts # Debug server implementation
│ └── test-connection.ts # Connection testing utility
├── .env.example # Example environment variables
├── .gitignore # Git ignore file
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation故障排除
常见问题
连接失败
Error: Unable to connect to Harbor instance验证 HARBOR_URL 是否正确且可访问
检查网络连接
确保 Harbor 实例正在运行
身份验证失败
Error: Invalid credentials验证 HARBOR_USERNAME 和 HARBOR_PASSWORD 是否正确
检查用户是否具有所需的权限
构建错误
Error: TypeScript compilation failed运行
npm install以确保所有依赖项都已安装检查 TypeScript 版本兼容性
清除
dist目录并重建
调试模式
通过设置启用调试日志记录:
LOG_LEVEL=debug支持
如需更多帮助:
检查DEBUG.md文件
运行连接测试:
npm run test:connection查看
logs/目录中的应用程序日志
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for Studex tools, notifications, and profile integrations
Model Context Protocol server for todo.vu task management and time tracking.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Node.js implementation that enables browsing Git repositories through the Model Context Protocol, providing features like displaying directory structures, reading files, searching code, comparing branches, and viewing commit history.2726 npm2MIT
- AlicenseNot gradedqualityDmaintenanceA Node.js/TypeScript server implementing the Model Context Protocol that provides integrations with GitHub and Notion, allowing automated workflow between these platforms via API endpoints.1,462 npmMIT
- AlicenseNot gradedqualityDmaintenanceMCP Harbor is a Node.js application that provides a Model Context Protocol (MCP) server for interacting with Harbor container registry.15 npmMIT
- AlicenseAqualityDmaintenanceModel Context Protocol server for npm registry. Enables searching packages, checking security, comparing versions, and validating compatibility.1232 npm3MIT