MCP Harbor is a Node.js application that provides a Model Context Protocol (MCP) server for interacting with the Harbor container registry. It also includes a REST API for Harbor operations, enabling seamless management of projects, repositories, tags, and Helm charts.
Before installing MCP Harbor, ensure you have:
shell
git clone https://github.com/nomagicln/mcp-harbor.git
shell
cd mcp-harbor
shell
npm install
shell
npm run build
shell
npm start
Create a .env
file in the root directory with the following variables:
# 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
Additional configuration options can be set in 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
}
GET /projects
- List all projectsGET /projects/:id
- Get project detailsPOST /projects
- Create a new projectDELETE /projects/:id
- Delete a projectGET /projects/:projectId/repositories
- List repositories in a projectDELETE /projects/:projectId/repositories/:repositoryName
- Delete a repositoryGET /projects/:projectId/repositories/:repositoryName/tags
- List tags in a repositoryDELETE /projects/:projectId/repositories/:repositoryName/tags/:tag
- Delete a tagGET /projects/:projectId/charts
- List Helm charts in a projectGET /projects/:projectId/charts/:chartName/versions
- List versions of a Helm chartDELETE /projects/:projectId/charts/:chartName/versions/:version
- Delete a Helm chart versionThe MCP server exposes the following tools:
Tool Name | Description | Parameters |
---|---|---|
list_projects |
List all projects in Harbor | None |
get_project |
Get project details by ID | id: number |
create_project |
Create a new project | name: string, public?: boolean |
delete_project |
Delete a project | id: number |
list_repositories |
List repositories in a project | projectId: number |
delete_repository |
Delete a repository | projectId: number, repoName: string |
list_tags |
List tags in a repository | projectId: number, repoName: string |
delete_tag |
Delete a tag | projectId: number, repoName: string, tag: string |
list_charts |
List Helm charts | projectId: number |
list_chart_versions |
List chart versions | projectId: number, chartName: string |
delete_chart |
Delete chart version | 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
The project includes debug tools in the tools
directory:
# 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
HARBOR_URL
is correct and accessible.Ensure Harbor instance is running.
Authentication Failed
HARBOR_USERNAME
and HARBOR_PASSWORD
are correct.Check if user has required permissions.
Build Errors
npm install
to ensure all dependencies are installed.dist
directory and rebuild.Enable debug logging by setting:
LOG_LEVEL=debug
For additional help:
npm run test:connection
.logs/
directory.This project is licensed under the MIT License - see the LICENSE file for details.