Skip to content

Commit ce29678

Browse files
Merge pull request containers#60 from Cali0707/sync-downstream
NO-JIRA: Sync downstream
2 parents b5bc635 + 1545750 commit ce29678

File tree

88 files changed

+3498
-716
lines changed

Some content is hidden

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

88 files changed

+3498
-716
lines changed

.github/workflows/release.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ concurrency:
1212

1313
env:
1414
GO_VERSION: 1.23
15-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1615
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
1716

1817
permissions:
1918
contents: write
19+
id-token: write # Required for npmjs OIDC
2020
discussions: write
2121

2222
jobs:
@@ -39,6 +39,12 @@ jobs:
3939
files: |
4040
LICENSE
4141
kubernetes-mcp-server-*
42+
# Ensure npm 11.5.1 or later is installed (required for https://docs.npmjs.com/trusted-publishers)
43+
- name: Setup node
44+
uses: actions/setup-node@v6
45+
with:
46+
node-version: 24
47+
registry-url: 'https://registry.npmjs.org'
4248
- name: Publish npm
4349
run:
4450
make npm-publish

AGENTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ This MCP server enables AI assistants (like Claude, Gemini, Cursor, and others)
1111
- Go package layout follows the standard Go conventions:
1212
- `cmd/kubernetes-mcp-server/` – main application entry point using Cobra CLI framework.
1313
- `pkg/` – libraries grouped by domain.
14+
- `api/` - API-related functionality, tool definitions, and toolset interfaces.
1415
- `config/` – configuration management.
1516
- `helm/` - Helm chart operations integration.
1617
- `http/` - HTTP server and authorization middleware.
1718
- `kubernetes/` - Kubernetes client management, authentication, and access control.
1819
- `mcp/` - Model Context Protocol (MCP) server implementation with tool registration and STDIO/HTTP support.
1920
- `output/` - output formatting and rendering.
21+
- `toolsets/` - Toolset registration and management for MCP tools.
22+
- `version/` - Version information management.
2023
- `.github/` – GitHub-related configuration (Actions workflows, issue templates...).
2124
- `docs/` – documentation files.
2225
- `npm/` – Node packages that wraps the compiled binaries for distribution through npmjs.com.
@@ -30,6 +33,21 @@ Implement new functionality in the Go sources under `cmd/` and `pkg/`.
3033
The JavaScript (`npm/`) and Python (`python/`) directories only wrap the compiled binary for distribution (npm and PyPI).
3134
Most changes will not require touching them unless the version or packaging needs to be updated.
3235

36+
### Adding new MCP tools
37+
38+
The project uses a toolset-based architecture for organizing MCP tools:
39+
40+
- **Tool definitions** are created in `pkg/api/` using the `ServerTool` struct.
41+
- **Toolsets** group related tools together (e.g., config tools, core Kubernetes tools, Helm tools).
42+
- **Registration** happens in `pkg/toolsets/` where toolsets are registered at initialization.
43+
- Each toolset lives in its own subdirectory under `pkg/toolsets/` (e.g., `pkg/toolsets/config/`, `pkg/toolsets/core/`, `pkg/toolsets/helm/`).
44+
45+
When adding a new tool:
46+
1. Define the tool handler function that implements the tool's logic.
47+
2. Create a `ServerTool` struct with the tool definition and handler.
48+
3. Add the tool to an appropriate toolset (or create a new toolset if needed).
49+
4. Register the toolset in `pkg/toolsets/` if it's a new toolset.
50+
3351
## Building
3452

3553
Use the provided Makefile targets:
@@ -105,6 +123,45 @@ make lint
105123

106124
The `lint` target downloads the specified `golangci-lint` version if it is not already present under `_output/tools/bin/`.
107125

126+
## Additional Makefile targets
127+
128+
Beyond the basic build, test, and lint targets, the Makefile provides additional utilities:
129+
130+
**Local Development:**
131+
```bash
132+
# Setup a complete local development environment with Kind cluster
133+
make local-env-setup
134+
135+
# Tear down the local Kind cluster
136+
make local-env-teardown
137+
138+
# Show Keycloak status and connection info (for OIDC testing)
139+
make keycloak-status
140+
141+
# Tail Keycloak logs
142+
make keycloak-logs
143+
144+
# Install required development tools (like Kind) to ./_output/bin/
145+
make tools
146+
```
147+
148+
**Distribution and Publishing:**
149+
```bash
150+
# Copy compiled binaries to each npm package
151+
make npm-copy-binaries
152+
153+
# Publish the npm packages
154+
make npm-publish
155+
156+
# Publish the Python packages
157+
make python-publish
158+
159+
# Update README.md with the latest toolsets
160+
make update-readme-tools
161+
```
162+
163+
Run `make help` to see all available targets with descriptions.
164+
108165
## Dependencies
109166

110167
When introducing new modules run `make tidy` so that `go.mod` and `go.sum` remain tidy.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

Makefile

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LD_FLAGS = -s -w \
1616
COMMON_BUILD_ARGS = -ldflags "$(LD_FLAGS)"
1717

1818
GOLANGCI_LINT = $(shell pwd)/_output/tools/bin/golangci-lint
19-
GOLANGCI_LINT_VERSION ?= v2.2.2
19+
GOLANGCI_LINT_VERSION ?= v2.5.0
2020

2121
# NPM version should not append the -dirty flag
2222
NPM_VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//')
@@ -71,16 +71,14 @@ npm-publish: npm-copy-binaries ## Publish the npm packages
7171
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
7272
DIRNAME="$(BINARY_NAME)-$(os)-$(arch)"; \
7373
cd npm/$$DIRNAME; \
74-
echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> .npmrc; \
7574
jq '.version = "$(NPM_VERSION)"' package.json > tmp.json && mv tmp.json package.json; \
76-
npm publish; \
75+
npm publish --tag latest; \
7776
cd ../..; \
7877
))
7978
cp README.md LICENSE ./npm/kubernetes-mcp-server/
80-
echo '//registry.npmjs.org/:_authToken=$(NPM_TOKEN)' >> ./npm/kubernetes-mcp-server/.npmrc
8179
jq '.version = "$(NPM_VERSION)"' ./npm/kubernetes-mcp-server/package.json > tmp.json && mv tmp.json ./npm/kubernetes-mcp-server/package.json; \
8280
jq '.optionalDependencies |= with_entries(.value = "$(NPM_VERSION)")' ./npm/kubernetes-mcp-server/package.json > tmp.json && mv tmp.json ./npm/kubernetes-mcp-server/package.json; \
83-
cd npm/kubernetes-mcp-server && npm publish
81+
cd npm/kubernetes-mcp-server && npm publish --tag latest
8482

8583
.PHONY: python-publish
8684
python-publish: ## Publish the python packages
@@ -115,3 +113,43 @@ lint: golangci-lint ## Lint the code
115113
.PHONY: update-readme-tools
116114
update-readme-tools: ## Update the README.md file with the latest toolsets
117115
go run ./internal/tools/update-readme/main.go README.md
116+
117+
##@ Tools
118+
119+
.PHONY: tools
120+
tools: ## Install all required tools (kind) to ./_output/bin/
121+
@echo "Checking and installing required tools to ./_output/bin/ ..."
122+
@if [ -f _output/bin/kind ]; then echo "[OK] kind already installed"; else echo "Installing kind..."; $(MAKE) -s kind; fi
123+
@echo "All tools ready!"
124+
125+
##@ Local Development
126+
127+
.PHONY: local-env-setup
128+
local-env-setup: ## Setup complete local development environment with Kind cluster
129+
@echo "========================================="
130+
@echo "Kubernetes MCP Server - Local Setup"
131+
@echo "========================================="
132+
$(MAKE) tools
133+
$(MAKE) kind-create-cluster
134+
$(MAKE) keycloak-install
135+
$(MAKE) build
136+
@echo ""
137+
@echo "========================================="
138+
@echo "Local environment ready!"
139+
@echo "========================================="
140+
@echo ""
141+
@echo "Configuration file generated:"
142+
@echo " _output/config.toml"
143+
@echo ""
144+
@echo "Run the MCP server with:"
145+
@echo " ./$(BINARY_NAME) --port 8008 --config _output/config.toml"
146+
@echo ""
147+
@echo "Or run with MCP inspector:"
148+
@echo " npx @modelcontextprotocol/inspector@latest \$$(pwd)/$(BINARY_NAME) --config _output/config.toml"
149+
150+
.PHONY: local-env-teardown
151+
local-env-teardown: ## Tear down the local Kind cluster
152+
$(MAKE) kind-delete-cluster
153+
154+
# Include build configuration files
155+
-include build/*.mk

0 commit comments

Comments
 (0)