Skip to main content
Glama
mshegolev

harbor-registry-mcp

harbor_list_repos

Read-onlyIdempotent

List all repositories in a Harbor project, showing artifact count and total pulls to identify unused repos. Supports pagination.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesHarbor project name.
pageNoPage number (1-based).
page_sizeNoItems per page (1-100).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYes
repositories_countYes
pageYes
page_sizeYes
has_moreYes
next_pageYes
repositoriesYes

Implementation Reference

  • The `harbor_list_repos` function — the actual handler that lists repositories in a Harbor project. It calls the Harbor API GET /projects/{project_name}/repositories with pagination, maps each repo to a RepositorySummary (name, artifact_count, pull_count, updated), and returns a RepositoriesListOutput with pagination info.
    def harbor_list_repos(
        project_name: Annotated[str, Field(min_length=1, max_length=255, description="Harbor project name.")],
        page: Annotated[int, Field(default=1, ge=1, le=1000, description="Page number (1-based).")] = 1,
        page_size: Annotated[int, Field(default=50, ge=1, le=100, description="Items per page (1-100).")] = 50,
    ) -> RepositoriesListOutput:
        """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``.
        """
        try:
            client = get_client()
            raw = (
                client.get(
                    f"/projects/{project_name}/repositories",
                    params={"page": page, "page_size": page_size},
                )
                or []
            )
            repos: list[RepositorySummary] = [
                {
                    "name": r["name"].replace(f"{project_name}/", ""),
                    "artifact_count": int(r.get("artifact_count", 0) or 0),
                    "pull_count": int(r.get("pull_count", 0) or 0),
                    "updated": _short(r.get("update_time")),
                }
                for r in raw
            ]
            has_more = len(raw) == page_size
            result: RepositoriesListOutput = {
                "project": project_name,
                "repositories_count": len(repos),
                "page": page,
                "page_size": page_size,
                "has_more": has_more,
                "next_page": page + 1 if has_more else None,
                "repositories": repos,
            }
            md = f"## {project_name} — page {page} ({len(repos)} repos, has_more={has_more})\n\n" + "\n".join(
                [f"- **{r['name']}** — {r['artifact_count']} artifacts, {r['pull_count']} pulls" for r in repos]
            )
            return output.ok(result, md)  # type: ignore[return-value]
        except Exception as exc:
            output.fail(exc, f"listing repositories in {project_name}")
  • The `@mcp.tool()` decorator registration for "harbor_list_repos", which registers this function as an MCP tool with read-only, idempotent, non-destructive annotations and structured_output=True.
    @mcp.tool(
        name="harbor_list_repos",
        annotations={
            "title": "List Repositories",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        },
        structured_output=True,
    )
  • The `RepositorySummary` TypedDict schema — describes the shape of each repository entry returned by the tool.
    class RepositorySummary(TypedDict):
        name: str
        artifact_count: int
        pull_count: int
        updated: str | None
  • The `RepositoriesListOutput` TypedDict schema — describes the full structured output of the tool (project, count, pagination fields, repository list).
    class RepositoriesListOutput(TypedDict):
        project: str
        repositories_count: int
        page: int
        page_size: int
        has_more: bool
        next_page: int | None
        repositories: list[RepositorySummary]
  • The `_list_repos` helper function that fetches all repositories across all pages (used internally by other tools like storage report).
    def _list_repos(client: Any, project_name: str) -> list[dict[str, Any]]:
        """Fetch every repository for a project across all pages."""
        return client.get_all_pages(
            f"/projects/{project_name}/repositories",
            page_size=100,
        )
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already mark the tool as read-only and idempotent. The description adds behavioral context: it explains pagination mechanics (has_more flag, calling again with page+1) and what data is returned per repository. This goes beyond annotations but does not cover rate limits or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences: first states purpose, second adds output details and use case, third explains pagination. It is front-loaded and contains no unnecessary information. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a list tool with pagination, the description covers purpose, reported data, and pagination. With output schema present and annotations providing safety hints, the description is largely complete. It does not mention prerequisites or error handling, but these are less critical given the output schema and simple parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema covers all 3 parameters with descriptions (100% coverage). The description does not add additional meaning to parameters beyond what the schema provides. The pagination detail refers to the response, not parameters, so parameter semantics are adequately covered by schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List repositories in a Harbor project' with specific verb and resource. It adds details about reported data (artifact count, pull count) and a use case (spotting unused repos before cleanup), distinguishing it from sibling tools like harbor_list_artifacts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a use case ('useful for spotting unused repos before cleanup') but does not explicitly state when to use this tool vs alternatives like harbor_list_artifacts or harbor_cleanup_candidates. The context is implied rather than explicit, lacking exclusions or alternative recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mshegolev/harbor-registry-mcp'

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