Skip to main content
Glama
harbor-registry-mcp

harbor-registry-mcp

harbor-registry-mcp

PyPI Python License: MIT

Harbor Registry 的 MCP 服务器。允许 LLM 智能体(如 Claude Code、Cursor、OpenCode 等)列出项目、仓库和制品,运行存储报告,查找清理候选对象,并删除无标签或旧的制品 — 所有操作均带有安全防护(批量删除默认开启试运行模式)。

Python,FastMCP,stdio 传输。

适用于任何 Harbor 2.x 实例 — SaaS 或自托管/本地部署。

为什么需要另一个 Harbor MCP?

社区中已存在几个 Harbor MCP(如 nomagicln/mcp-harbor、[bupd/harbor-mcp-server](https://github.com/bupd/harbor-mcp-server),但它们仅暴露了基础的列表/获取端点。本项目增加了**存储报告、清理候选对象、删除无标签制品以及带试运行功能的删除旧制品**功能 — 这些都是 DevOps 工程师回收磁盘空间真正需要的操作。

Related MCP server: Harbor MCP Server

设计亮点

  • 工具注解 — 只读工具带有 readOnlyHint: True;破坏性工具(harbor_delete_*)带有 destructiveHint: True,以便 MCP 客户端请求确认。

  • 默认试运行 — 批量清理操作默认开启试运行(harbor_delete_old_artifacts(dry_run=True)) — 智能体必须手动切换才能执行。

  • 结构化输出 — 每个工具返回一个类型化载荷 (TypedDict) 和一个 Markdown 摘要。

  • 结构化错误 — 401 / 403 / 404 / 429 / 5xx 错误映射为可操作的提示。

  • Pydantic 输入验证 — 对每个参数进行验证。

  • 漏洞快照 — 如果启用了 with_scan_overview,harbor_list_artifacts 会显示扫描状态和计数。

功能 (8 个工具)

发现与检查

  • harbor_list_projects — 列出项目及其仓库数量和可见性

  • harbor_list_repos — 列出项目中的仓库

  • harbor_list_artifacts — 列出仓库中的制品,包含标签/大小/扫描状态

  • harbor_storage_report — 完整的项目存储明细(所有仓库 × 所有制品)

清理规划

  • harbor_cleanup_candidates — 建议删除的对象(无标签、从未拉取、旧版本)

清理执行(破坏性)

  • harbor_delete_artifact — 通过标签或摘要删除单个制品

  • harbor_delete_untagged — 删除项目/仓库中所有无标签的制品

  • harbor_delete_old_artifacts — 每个仓库保留 N 个最新版本,删除其余版本(默认试运行)

安装

需要 Python 3.10+。

# via uvx (recommended)
uvx --from harbor-registry-mcp harbor-registry-mcp

# or via pipx
pipx install harbor-registry-mcp

配置

claude mcp add harbor -s project \
  --env HARBOR_URL=https://harbor.example.com \
  --env HARBOR_USERNAME='robot$your-robot' \
  --env HARBOR_PASSWORD=your-robot-token \
  --env HARBOR_SSL_VERIFY=true \
  -- uvx --from harbor-registry-mcp harbor-registry-mcp

或者在 .mcp.json 中配置:

{
  "mcpServers": {
    "harbor": {
      "type": "stdio",
      "command": "uvx",
      "args": ["--from", "harbor-registry-mcp", "harbor-registry-mcp"],
      "env": {
        "HARBOR_URL": "https://harbor.example.com",
        "HARBOR_USERNAME": "robot$your-robot",
        "HARBOR_PASSWORD": "${HARBOR_PASSWORD}",
        "HARBOR_SSL_VERIFY": "true"
      }
    }
  }
}

检查:

claude mcp list
# harbor: uvx --from harbor-registry-mcp harbor-registry-mcp - ✓ Connected

环境变量

变量

必需

描述

HARBOR_URL

是

Harbor URL(末尾不带斜杠)

HARBOR_USERNAME

是

Harbor 用户名 — 建议使用机器人账号

HARBOR_PASSWORD

是

密码或机器人令牌

HARBOR_SSL_VERIFY

否

true/false。默认:true。

使用示例

  • “获取项目 einvy-pub 的存储报告”

  • “在 qa-assistant 中查找清理候选对象 — 保留最新的 3 个”

  • “删除 qa-assistant 中所有无标签的制品”

  • “在 qa-assistant/pgvector-rag 中试运行删除旧制品,保留最新的 1 个”

  • “einvy-pub/my-image 里有什么?”

安全性

  • 只读工具使用 readOnlyHint: True — 无需确认。

  • 删除工具使用 destructiveHint: True — 客户端应进行确认。

  • harbor_delete_old_artifacts 默认开启 dry_run=True;智能体必须显式设置 dry_run=False 才能真正执行删除。

  • harbor_cleanup_candidates 是只读的 — 它仅提供候选建议,绝不执行删除。

开发

git clone https://github.com/mshegolev/harbor-registry-mcp.git
cd harbor-registry-mcp
pip install -e '.[dev]'
pytest

许可证

MIT © Mikhail Shchegolev

Available Tools

8 tools
harbor_cleanup_candidatesA
Read-onlyIdempotent

Suggest which artifacts could be deleted to reclaim space.

READ-ONLY — never deletes anything; just produces a list with reasons. Use harbor_delete_artifact / harbor_delete_untagged / harbor_delete_old_artifacts to act on the results.

Reasons emitted: - untagged — artifact has no tags (orphaned layer) - never_pulled — artifact has never been pulled (and is past the keep_latest_per_repo cutoff) - old_version — artifact is older than the keep_latest_per_repo newest tagged artifacts

Inputs: project_name (required), include_untagged, include_zero_pulls, keep_latest_per_repo. Returns: project, candidates_count, total_reclaimable, total_reclaimable_bytes, +2 more

harbor_delete_artifactA
Destructive

Delete a single artifact by tag or digest.

DESTRUCTIVE & IRREVERSIBLE — Harbor immediately removes the manifest from its catalogue; the underlying blobs are reclaimed by the next GC sweep. There is no soft-delete or undo.

Returns the freed space and tag list for confirmation.

Inputs: project_name (required), repository_name (required), reference (required). Returns: success, project, repository, reference, +4 more

harbor_delete_old_artifactsA
Destructive

Keep the N newest artifacts in a repository, delete the rest.

DESTRUCTIVE. dry_run=True is the default — the agent must explicitly set dry_run=False to actually delete. Each entry in to_delete carries a deleted field (True/False after real run, None in dry-run).

Inputs: project_name (required), repository_name (required), keep_count, dry_run. Returns: project, repository, dry_run, keeping, +6 more

harbor_delete_untaggedA
DestructiveIdempotent

Delete all untagged artifacts in a project (or single repository).

DESTRUCTIVE. Untagged artifacts are typically orphaned layers left behind after pushing a new tag of the same image — generally safe to delete. The full project sweep is opaque, so the response includes repos_scanned for visibility.

Inputs: project_name (required), repository_name. Returns: project, repos_scanned, deleted_count, freed_size, +3 more

harbor_list_artifactsA
Read-onlyIdempotent

List artifacts (tags) in a repository, newest first.

Each artifact carries digest, size, push/pull timestamps, scan status and vulnerability counts (if scanned).

Pagination: if has_more is True, call again with page + 1. For repositories with hundreds of artifacts prefer harbor_storage_report or harbor_cleanup_candidates which paginate internally.

Inputs: project_name (required), repository_name (required), page, page_size. Returns: project, repository, total_size, total_size_bytes, +6 more

harbor_list_projectsA
Read-onlyIdempotent

List Harbor projects, sorted by repository count (descending within the page).

Use this first to discover which Harbor projects exist before drilling in with harbor_list_repos / harbor_list_artifacts.

Pagination: if has_more is True, call again with page + 1. Note that sorting is per-page — agents that need a global ranking should aggregate across pages.

Returns: dict with keys projects_count / page / page_size / has_more / next_page / projects (list).

Inputs: page, page_size. Returns: projects_count, page, page_size, has_more, +2 more

harbor_list_reposA
Read-onlyIdempotent

List repositories in a Harbor project.

Each repository is reported with artifact count and total pull count (useful for spotting unused repos before cleanup).

Pagination: if has_more is True, call again with page + 1.

Inputs: project_name (required), page, page_size. Returns: project, repositories_count, page, page_size, +3 more

harbor_storage_reportA
Read-onlyIdempotent

Full storage breakdown for a Harbor project.

Iterates every repository × every artifact and returns a sorted-by-size report — the canonical view for "what's eating up our quota?". Performs O(repos × artifacts) API calls; emits progress events through MCP Context.

Inputs: project_name (required). Returns: project, total_repositories, total_size, total_size_bytes, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct operation: listing, reporting, or deleting. The cleanup candidate tool is clearly separate from the delete tools, and deletion tools are differentiated by scope (single, old, untagged). No overlapping purposes.

    Naming Consistency4/5

    Most tools follow the harbor_verb_noun pattern (e.g., harbor_delete_artifact, harbor_list_projects), but harbor_storage_report uses a noun_noun pattern, breaking consistency. The prefix and general style are otherwise uniform.

    Tool Count5/5

    Eight tools cover the essential operations for a Harbor registry: discovery (list projects, repos, artifacts), cleanup (candidates, delete single, delete old, delete untagged), and reporting (storage report). The count is well-scoped without being excessive.

    Completeness5/5

    The tool set provides comprehensive coverage for registry management: full lifecycle for artifacts (list, delete individual/bulk/untagged), project and repository exploration, storage analysis, and a cleanup candidate suggestion tool. No major gaps in functionality for the intended domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      A Node.js application that provides a Model Context Protocol server for interacting with Harbor container registry, supporting operations for projects, repositories, tags, and Helm charts.
      21 npm
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI models to interact with Harbor container registries to manage projects, repositories, and system configurations in real time. It provides a suite of tools for monitoring health, retrieving statistics, and performing searches across registry data.
      6
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP Harbor is a Node.js application that provides a Model Context Protocol (MCP) server for interacting with Harbor container registry.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables interacting with a Harbor container registry through the Model Context Protocol, supporting operations for projects, repositories, tags, and Helm charts.
      1
      MIT