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は、Harborコンテナレジストリと連携するためのModel Context Protocol(MCP)サーバーを提供するNode.jsアプリケーションです。また、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チャート

  • GET /projects/:projectId/charts - プロジェクト内のHelmチャート一覧を取得する
  • GET /projects/:projectId/charts/:chartName/versions - Helm チャートのバージョンを一覧表示する
  • DELETE /projects/:projectId/charts/:chartName/versions/:version - Helm チャートのバージョンを削除します

MCPツール

MCP サーバーは次のツールを公開します。

ツール名説明パラメータ
list_projectsHarborのすべてのプロジェクトを一覧表示するなし
get_projectIDでプロジェクトの詳細を取得する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_chartsHelm チャートの一覧表示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

Harbor コンテナ レジストリと対話するためのモデル コンテキスト プロトコル サーバーを提供し、プロジェクト、リポジトリ、タグ、Helm チャートに対する操作をサポートする Node.js アプリケーション。

  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