Skip to main content
Glama

MCP 港

许可证:MIT TypeScript Node.js

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

目录

Related MCP server: ShipStation API MCP Server

特征

  • 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
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nomagicln/mcp-harbor'

If you have feedback or need assistance with the MCP directory API, please join our Discord server