Skip to content

Commit 1f8a11d

Browse files
feat: redesign setup and add missed unittest for cli package (#13)
1 parent 130d6c4 commit 1f8a11d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+7397
-410
lines changed

.github/workflows/post-merge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- name: Run unit tests with coverage
7676
run: |
7777
go test -v -race -coverprofile=unit.out \
78-
$(go list ./... | grep -v '^mcp-runtime/test' | grep -v '^mcp-runtime/examples/example-app$')
78+
$(go list ./... | grep -v '^github.com/Agent-Hellboy/mcp-runtime/test' | grep -v '^github.com/Agent-Hellboy/mcp-runtime/examples/example-app$')
7979
8080
- name: Run integration tests with coverage
8181
run: |

.github/workflows/pre-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Run unit tests with coverage
5959
run: |
6060
go test -v -race -coverprofile=unit.out \
61-
$(go list ./... | grep -v '^mcp-runtime/test' | grep -v '^mcp-runtime/examples/example-app$')
61+
$(go list ./... | grep -v '^github.com/Agent-Hellboy/mcp-runtime/test' | grep -v '^github.com/Agent-Hellboy/mcp-runtime/examples/example-app$')
6262
6363
- name: Run integration tests with coverage
6464
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ benchmarking.md
1111
.fakehome/
1212
.cache/
1313
DIFF*.md
14+
.gomodcache/
15+
FUTURE_PLAN.md
16+
.DS_Store

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ repos:
88
types: [go]
99
- id: staticcheck
1010
name: staticcheck
11-
entry: staticcheck
12-
language: golang
11+
entry: hack/staticcheck.sh
12+
language: system
1313
pass_filenames: false
1414
args: [./...]
15-
additional_dependencies:
16-
- honnef.co/go/tools/cmd/staticcheck@latest
1715
- id: govet
1816
name: go vet
1917
entry: go vet ./...

Dockerfile.operator

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS builder
1+
FROM golang:1.24.11-alpine AS builder
22

33
WORKDIR /build
44

README.md

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Post-Merge Checks](https://github.com/Agent-Hellboy/mcp-runtime/actions/workflows/post-merge.yaml/badge.svg)](https://github.com/Agent-Hellboy/mcp-runtime/actions/workflows/post-merge.yaml)
44
[![Gosec Scan](https://img.shields.io/github/actions/workflow/status/Agent-Hellboy/mcp-runtime/post-merge.yaml?branch=main&label=Gosec%20Scan)](https://github.com/Agent-Hellboy/mcp-runtime/actions/workflows/post-merge.yaml)
55
[![Trivy Scan](https://img.shields.io/github/actions/workflow/status/Agent-Hellboy/mcp-runtime/post-merge.yaml?branch=main&label=Trivy%20Scan)](https://github.com/Agent-Hellboy/mcp-runtime/actions/workflows/post-merge.yaml)
6-
[![Coverage](https://codecov.io/gh/Agent-Hellboy/mcp-runtime/branch/main/graph/badge.svg)](https://codecov.io/gh/Agent-Hellboy/mcp-runtime)
6+
[![Coverage](https://codecov.io/gh/Agent-Hellboy/mcp-runtime/branch/main/graph/badge.svg)](https://codecov.io/gh/Agent-Hellboy/mcp-runtime/branch/main)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/Agent-Hellboy/mcp-runtime)](https://goreportcard.com/report/github.com/Agent-Hellboy/mcp-runtime)
88

99
A complete platform for deploying and managing MCP (Model Context Protocol) servers.
@@ -25,13 +25,13 @@ MCP Runtime Platform provides a streamlined workflow for teams to deploy a suite
2525
## Features
2626

2727
- **Complete Platform** - Internal registry deployment plus cluster setup helpers
28-
- **CLI Tool** - Manage platform, registry, cluster, and servers
28+
- **CLI Tool** - Manage platform, registry, cluster, certificate, pipeline, and servers
2929
- **Automated Setup** - One-command platform deployment
3030
- **CI/CD Integration** - Automated build and deployment pipeline
3131
- **Kubernetes Operator** - Automatically creates Deployment, Service, and Ingress
3232
- **Metadata-Driven** - Simple YAML files, no Kubernetes knowledge needed
3333
- **Unified URLs** - All servers get consistent `/{server-name}/mcp` routes
34-
- **Auto Image Building** - Builds from Dockerfiles and updates metadata automatically
34+
- **Auto Image Building** - Builds from Dockerfiles (through server build cmd) and updates metadata automatically
3535

3636
## Architecture
3737

@@ -66,11 +66,16 @@ MCP Runtime Platform provides a streamlined workflow for teams to deploy a suite
6666

6767
### Required
6868

69-
- Go 1.21+
69+
- Go 1.24+ (Tested on 1.24.11)
7070
- Make
71-
- kubectl (configured for your cluster)
71+
- kubectl (Tested on)
72+
```
73+
kubectl version
74+
Client Version: v1.34.1
75+
Kustomize Version: v5.7.1
76+
Server Version: v1.34.0
77+
```
7278
- Docker
73-
- Kubernetes cluster (1.21+) with default StorageClass
7479

7580

7681
### Registry
@@ -125,6 +130,10 @@ Override any defaults in your server metadata if needed.
125130

126131
### Environment Variables
127132

133+
#### CLI Environment Variables
134+
135+
These variables control the behavior of the `mcp-runtime` CLI tool:
136+
128137
| Variable | Default | Description |
129138
|----------|---------|-------------|
130139
| `MCP_DEPLOYMENT_TIMEOUT` | `5m` | Timeout for deployment readiness checks |
@@ -133,6 +142,24 @@ Override any defaults in your server metadata if needed.
133142
| `MCP_SKOPEO_IMAGE` | `quay.io/skopeo/stable:v1.14` | Skopeo image for in-cluster image transfers (useful for air-gapped environments) |
134143
| `MCP_OPERATOR_IMAGE` | (auto) | Override operator image (bypasses build/push) |
135144
| `MCP_DEFAULT_SERVER_PORT` | `8088` | Default container port for MCP servers |
145+
| `PROVISIONED_REGISTRY_URL` | (none) | URL of external/provisioned registry (used by CLI for registry operations) |
146+
| `PROVISIONED_REGISTRY_USERNAME` | (none) | Username for external registry authentication |
147+
| `PROVISIONED_REGISTRY_PASSWORD` | (none) | Password for external registry authentication |
148+
149+
#### Operator Environment Variables
150+
151+
These variables are set in the operator deployment and control operator behavior:
152+
153+
| Variable | Default | Description |
154+
|----------|---------|-------------|
155+
| `MCP_DEFAULT_INGRESS_HOST` | (none) | Default hostname for ingress resources (used when `spec.ingressHost` is not set) |
156+
| `DEFAULT_INGRESS_HOST` | (none) | Alternative name for default ingress host (same as `MCP_DEFAULT_INGRESS_HOST`) |
157+
| `DEFAULT_INGRESS_CLASS` | `traefik` | Default ingress class to use for ingress resources |
158+
| `PROVISIONED_REGISTRY_URL` | (none) | URL of provisioned registry (used when `useProvisionedRegistry: true` in MCPServer spec) |
159+
| `PROVISIONED_REGISTRY_USERNAME` | (none) | Username for provisioned registry authentication |
160+
| `PROVISIONED_REGISTRY_PASSWORD` | (none) | Password for provisioned registry authentication |
161+
| `PROVISIONED_REGISTRY_SECRET_NAME` | `mcp-runtime-registry-creds` | Name of the Kubernetes secret for registry credentials |
162+
| `REQUEUE_DELAY_SECONDS` | `10` | Delay in seconds before requeueing when resources aren't ready |
136163

137164
Examples:
138165
```bash
@@ -144,14 +171,28 @@ MCP_SKOPEO_IMAGE=my-registry.local/skopeo:v1.14 mcp-runtime registry push myimag
144171

145172
# Use pre-built operator image
146173
MCP_OPERATOR_IMAGE=ghcr.io/myorg/mcp-operator:v1.0 mcp-runtime setup
174+
175+
# Configure external registry for CLI
176+
PROVISIONED_REGISTRY_URL=registry.example.com \
177+
PROVISIONED_REGISTRY_USERNAME=admin \
178+
PROVISIONED_REGISTRY_PASSWORD=secret \
179+
mcp-runtime registry provision --url registry.example.com
180+
181+
# Configure operator to use external registry (set in operator deployment)
182+
# This allows MCPServer resources with useProvisionedRegistry: true to use the external registry
183+
kubectl set env deployment/mcp-runtime-operator-controller-manager \
184+
-n mcp-runtime \
185+
PROVISIONED_REGISTRY_URL=registry.example.com \
186+
PROVISIONED_REGISTRY_USERNAME=admin \
187+
PROVISIONED_REGISTRY_PASSWORD=secret
147188
```
148189

149190

150191
## Quick Start
151192

152193
```bash
153194
# 1. Clone and build
154-
git clone https://github.com/Agent-Hellboy/mcp-runtime.git
195+
git clone https://mcp-runtime.git
155196
cd mcp-runtime
156197
make install && make build-runtime
157198

@@ -203,17 +244,6 @@ mcp-runtime cluster # Cluster operations
203244

204245
## Development
205246

206-
### Code Structure
207-
208-
```
209-
├── cmd/ # CLI and operator entry points
210-
├── internal/ # CLI and operator implementations
211-
├── api/ # Kubernetes CRD definitions
212-
├── config/ # Kubernetes manifests
213-
├── examples/ # Working examples
214-
└── test/ # Tests
215-
```
216-
217247
### Building
218248

219249
```bash
@@ -286,9 +316,11 @@ The platform uses `mcp-runtime.org` as the default API group. If you want to use
286316
## Troubleshooting
287317

288318
```bash
289-
# Check platform health
319+
# Check platform health
290320
mcp-runtime status
291321

322+
almost all subcommands has status
323+
292324
# View logs
293325
kubectl logs -n mcp-runtime deployment/mcp-runtime-operator-controller-manager
294326
kubectl logs -n registry deployment/registry

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module mcp-runtime
22

3-
go 1.23.0
3+
go 1.24.11
44

55
require (
66
github.com/go-logr/logr v1.2.4

hack/staticcheck.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
gopath="$(go env GOPATH)"
5+
bin="${gopath}/bin/staticcheck"
6+
7+
if [[ ! -x "${bin}" ]]; then
8+
echo "staticcheck not found at ${bin}. Install with:" >&2
9+
echo " GOTOOLCHAIN=go1.24.11 go install honnef.co/go/tools/cmd/staticcheck@latest" >&2
10+
exit 1
11+
fi
12+
13+
exec "${bin}" "$@"

internal/cli/build.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import (
2020
"gopkg.in/yaml.v3"
2121
)
2222

23+
// yamlMarshal is a test seam for yaml.Marshal.
24+
var yamlMarshal = yaml.Marshal
25+
2326
func newBuildImageCmd(logger *zap.Logger) *cobra.Command {
2427
var dockerfile string
2528
var metadataFile string
@@ -148,7 +151,7 @@ func updateMetadataImage(serverName, imageName, tag, metadataFile, metadataDir s
148151
}
149152

150153
// Write back
151-
data, err := yaml.Marshal(registry)
154+
data, err := yamlMarshal(registry)
152155
if err != nil {
153156
return fmt.Errorf("failed to marshal metadata: %w", err)
154157
}

0 commit comments

Comments
 (0)