MCP Harbor

by nomagicln
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides tools for interacting with Harbor container registry, enabling operations on projects, repositories, tags, and Helm charts such as listing, creating, and deleting resources.

  • Enables management of Helm charts within Harbor registry, including listing available charts, viewing chart versions, and deleting chart versions.

MCP 港

MCP Harbor 是一个 Node.js 应用,它提供了一个模型上下文协议 (MCP) 服务器,用于与 Harbor 容器注册表进行交互。它还包含一个用于 Harbor 操作的 REST API。

目录

特征

  • MCP 服务器:通过模型上下文协议公开与 Harbor 交互的工具
  • REST API :为 Harbor 操作提供 RESTful 端点
  • Harbor Operations :支持项目、存储库、标签和 Helm 图表的操作
  • TypeScript :用 TypeScript 编写,以获得更好的类型安全性和开发人员体验
  • 自动化测试:全面的测试套件,确保可靠的功能

先决条件

在安装 MCP Harbor 之前,请确保您已:

  • Node.js 18.x 或更高版本
  • npm 8.x 或更高版本
  • 访问 Harbor 注册表实例
  • Git(用于克隆存储库)

安装

  1. 克隆存储库:
    git clone https://github.com/nomagicln/mcp-harbor.git
  2. 导航到项目目录:
    cd mcp-harbor
  3. 安装依赖项:
    npm install
  4. 构建项目:
    npm run build
  5. 启动应用程序:
    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 服务器公开以下工具:

工具名称描述参数
list_projects列出 Harbor 中的所有项目没有任何
get_project通过ID获取项目详细信息id: number
create_project创建新项目name: string, public?: boolean
delete_project删除项目id: number
list_repositories列出项目中的存储库projectId: number
delete_repository删除存储库projectId: number, repoName: string
list_tags列出存储库中的标签projectId: number, repoName: string
delete_tag删除标签projectId: number, repoName: string, tag: string
list_charts列出 Helm 图表projectId: number
list_chart_versions列出图表版本projectId: number, chartName: string
delete_chart删除图表版本projectId: number, chartName: string, version: string

发展

以开发模式运行

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

故障排除

常见问题

  1. 连接失败
    Error: Unable to connect to Harbor instance
    • 验证 HARBOR_URL 是否正确且可访问
    • 检查网络连接
    • 确保 Harbor 实例正在运行
  2. 身份验证失败
    Error: Invalid credentials
    • 验证 HARBOR_USERNAME 和 HARBOR_PASSWORD 是否正确
    • 检查用户是否具有所需的权限
  3. 构建错误
    Error: TypeScript compilation failed
    • 运行npm install以确保所有依赖项都已安装
    • 检查 TypeScript 版本兼容性
    • 清除dist目录并重建

调试模式

通过设置启用调试日志记录:

LOG_LEVEL=debug

支持

如需更多帮助:

  1. 检查DEBUG.md文件
  2. 运行连接测试: npm run test:connection
  3. 查看logs/目录中的应用程序日志

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

-
security - not tested
F
license - not found
-
quality - not tested

一个 Node.js 应用程序,提供用于与 Harbor 容器注册表交互的模型上下文协议服务器,支持项目、存储库、标签和 Helm 图表的操作。

  1. Table of Contents
    1. Features
      1. Prerequisites
        1. Installation
          1. Configuration
            1. Environment Variables
            2. Configuration File
          2. API Endpoints
            1. Projects
            2. Repositories
            3. Tags
            4. Helm Charts
          3. MCP Tools
            1. Development
              1. Running in Development Mode
              2. Running Tests
              3. Debug Tools
            2. Project Structure
              1. Troubleshooting
                1. Common Issues
                2. Debug Mode
                3. Support
              2. License
                ID: 7zkzz915sh