Skip to content

Commit 40f9684

Browse files
committed
Recent policy updates, added a new claude command for updates
Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
1 parent 4000288 commit 40f9684

16 files changed

+1794
-1765
lines changed

CLAUDE.md

Lines changed: 53 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ Each tool handler follows this structure:
133133
- **RateLimitPolicy**: Rate limiting (kuadrant.io/v1)
134134
- **TokenRateLimitPolicy**: Token-based rate limiting for AI/LLM services (kuadrant.io/v1)
135135
- **AuthPolicy**: Authentication/authorization (kuadrant.io/v1)
136+
- **TelemetryPolicy**: Custom metrics labels via CEL (kuadrant.io/v1alpha1)
136137
- **Kuadrant CR**: Main operator configuration (kuadrant.io/v1beta1)
138+
- **PlanPolicy** (extension): Plan-based rate limiting for tiered services (extensions.kuadrant.io/v1alpha1)
137139

138140
### Error Handling
139141

@@ -268,7 +270,7 @@ echo -e '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"202
268270

269271
## Current MCP Resources
270272

271-
The server provides 11 documentation resources:
273+
The server provides 13 documentation resources:
272274

273275
**Policy References:**
274276
- `kuadrant://docs/gateway-api` - Gateway API overview
@@ -277,9 +279,13 @@ The server provides 11 documentation resources:
277279
- `kuadrant://docs/tokenratelimitpolicy` - TokenRateLimitPolicy reference
278280
- `kuadrant://docs/authpolicy` - AuthPolicy reference
279281
- `kuadrant://docs/tlspolicy` - TLSPolicy reference
282+
- `kuadrant://docs/telemetrypolicy` - TelemetryPolicy reference (custom metrics labels)
280283
- `kuadrant://docs/kuadrant` - Kuadrant CR reference
281284
- `kuadrant://docs/authorino-features` - Authorino authentication/authorization features
282285

286+
**Extensions:**
287+
- `kuadrant://docs/planpolicy` - PlanPolicy extension (plan-based rate limiting)
288+
283289
**Examples & Guides:**
284290
- `kuadrant://examples/basic-setup` - Basic API setup example
285291
- `kuadrant://examples/production-setup` - Production deployment example
@@ -313,86 +319,70 @@ docker run -i --rm ghcr.io/jasonmadigan/kuadrant-mcp-server:latest
313319

314320
## Updating Resource Documentation
315321

316-
The MCP server includes documentation resources that are extracted from the official Kuadrant repositories. This documentation is kept up-to-date using automated scripts.
322+
Documentation is stored as markdown files in `docs/` and embedded into the binary at build time using Go's `//go:embed` directive.
317323

318-
### Quick Update Process
324+
### Architecture
325+
326+
```
327+
docs/ # Committed to git, embedded at build time
328+
├── gateway-api.md
329+
├── dnspolicy.md
330+
├── ratelimitpolicy.md
331+
├── authpolicy.md
332+
├── tlspolicy.md
333+
├── tokenratelimitpolicy.md
334+
├── kuadrant.md
335+
├── authorino-features.md
336+
├── telemetrypolicy.md
337+
├── planpolicy.md
338+
├── troubleshooting.md
339+
└── examples/
340+
├── basic-setup.md
341+
└── production-setup.md
342+
```
319343

320-
To update the documentation to the latest version:
344+
### Quick Update Process
321345

322346
```bash
323-
# 1. Extract latest docs from source repos (based on mkdocs.yml config)
347+
# 1. Extract latest docs from source repos
324348
./update-docs.sh
325349

326-
# 2. (Optional) Generate Go resource handlers from the extracted docs
327-
go run process-docs.go
328-
329-
# 3. Review and integrate the generated code
330-
# The script generates resources-generated.go which you can review
331-
# and manually integrate into resources.go as needed
332-
```
333-
334-
### How It Works
350+
# 2. Review extracted content
351+
cat extracted-docs/extraction-summary.txt
335352

336-
The update process:
337-
1. **Reads mkdocs.yml** from docs.kuadrant.io to get the exact list of files being published
338-
2. **Clones source repos** (kuadrant-operator and authorino)
339-
3. **Extracts only the files** specified in mkdocs.yml configuration
340-
4. **Preserves directory structure** for easy navigation
341-
5. **Creates a summary** of all extracted documentation
353+
# 3. Update markdown files in docs/ as needed
354+
# Compare with extracted-docs/ and update relevant content
342355

343-
### Directory Structure After Update
356+
# 4. Rebuild to embed changes
357+
go build -o kuadrant-mcp-server
344358

359+
# 5. Test
360+
echo -e '...' | ./kuadrant-mcp-server 2>/dev/null | jq '.result.resources[].uri'
345361
```
346-
extracted-docs/
347-
├── kuadrant-operator/ # Docs from kuadrant-operator repo
348-
│ ├── doc/reference/ # API reference documentation
349-
│ ├── doc/user-guides/ # Practical guides
350-
│ └── doc/overviews/ # Conceptual overviews
351-
├── authorino/ # Docs from authorino repo
352-
│ ├── docs/ # Core documentation
353-
│ └── docs/user-guides/ # Authorino-specific guides
354-
└── extraction-summary.txt # List of all extracted files
355-
```
356-
357-
### Manual Integration
358-
359-
After running the scripts, you can:
360-
1. Review `extracted-docs/` for the latest content
361-
2. Check `resources-generated.go` for auto-generated handlers
362-
3. Manually update `resources.go` with relevant changes
363-
4. Test the updated resources work correctly
364362

365-
### Keeping Documentation Current
363+
### Adding New Resources
366364

367-
Run periodically (e.g., weekly or when new features are released):
368-
369-
```bash
370-
# Full documentation update
371-
./update-docs.sh
372-
373-
# Check what changed
374-
cat extracted-docs/extraction-summary.txt
375-
376-
# Generate and review Go code
377-
go run process-docs.go
378-
git diff resources-generated.go
365+
1. Create markdown file in `docs/`
366+
2. Add mapping in `resources.go`:
367+
```go
368+
"kuadrant://docs/newpolicy": {"docs/newpolicy.md", "NewPolicy Reference", "Description"},
379369
```
370+
3. Update embed directive if needed (for new subdirectories)
371+
4. Rebuild
380372

381-
### Important Files
373+
### Key Files
382374

383-
- **`update-docs.sh`** - Main extraction script that reads mkdocs.yml
384-
- **`process-docs.go`** - Converts markdown to Go resource handlers
385-
- **`extracted-docs/`** - Contains all extracted documentation (git-ignored)
386-
- **`resources-generated.go`** - Auto-generated resource handlers (git-ignored)
375+
- **`docs/`** - Markdown files for each resource (committed)
376+
- **`resources.go`** - Embed directive and resource mapping
377+
- **`update-docs.sh`** - Extracts docs from upstream repos
378+
- **`extracted-docs/`** - Temporary extraction output (git-ignored)
387379

388-
### Note on Documentation Sources
380+
### Documentation Sources
389381

390-
The script automatically pulls from:
382+
The extraction script pulls from:
391383
1. **docs.kuadrant.io** - For mkdocs.yml configuration
392-
2. **kuadrant-operator** - For policy references and guides
393-
3. **authorino** - For authentication/authorization features
394-
395-
This ensures documentation stays in sync with what's published on the official docs site.
384+
2. **kuadrant-operator** - Policy references and guides
385+
3. **authorino** - Authentication/authorization features
396386

397387
### Important: AuthConfig vs AuthPolicy Translation
398388

README.md

Lines changed: 84 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A Model Context Protocol (MCP) server that generates Kuadrant policy manifests i
1010

1111
```bash
1212
# Add the MCP server using Docker (available in all projects)
13-
claude mcp add -s user kuadrant "docker run -i --rm ghcr.io/kuadrant/kuadrant-mcp-server:latest"
13+
claude mcp add -s user kuadrant docker -- run -i --rm ghcr.io/kuadrant/kuadrant-mcp-server:latest
1414

1515
# Verify installation
1616
claude mcp list
@@ -24,7 +24,7 @@ claude # Start new session, type /mcp to see available servers
2424
This MCP server generates Kuadrant-specific Kubernetes manifests:
2525
- Gateway resources with Kuadrant annotations
2626
- HTTPRoute configurations
27-
- Kuadrant policies (DNS, TLS, RateLimit, Auth)
27+
- Kuadrant policies (DNS, TLS, RateLimit, TokenRateLimit, Auth)
2828

2929
All manifests are generated in YAML format, matching the actual Kuadrant CRD specifications.
3030

@@ -153,8 +153,15 @@ The MCP server provides comprehensive documentation and examples through resourc
153153
- `kuadrant://docs/gateway-api` - Gateway API overview and Kuadrant integration
154154
- `kuadrant://docs/dnspolicy` - Complete DNSPolicy reference with examples
155155
- `kuadrant://docs/ratelimitpolicy` - RateLimitPolicy patterns and advanced usage
156+
- `kuadrant://docs/tokenratelimitpolicy` - TokenRateLimitPolicy for AI/LLM API management
156157
- `kuadrant://docs/authpolicy` - AuthPolicy authentication and authorization methods
157158
- `kuadrant://docs/tlspolicy` - TLSPolicy certificate management guide
159+
- `kuadrant://docs/telemetrypolicy` - TelemetryPolicy for custom metrics labels
160+
- `kuadrant://docs/kuadrant` - Kuadrant CR (operator configuration)
161+
- `kuadrant://docs/authorino-features` - Authorino authentication/authorization features
162+
163+
### Extensions
164+
- `kuadrant://docs/planpolicy` - PlanPolicy for plan-based rate limiting (gold/silver/bronze tiers)
158165

159166
### Example Resources
160167
- `kuadrant://examples/basic-setup` - Simple API with rate limiting and API key auth
@@ -170,7 +177,7 @@ Access these resources in Claude by asking questions like:
170177

171178
**Note**: Claude may not always use resources automatically. To ensure resource usage:
172179
- Be specific about wanting documentation or examples
173-
- Reference Kuadrant policies by name (e.g., "RateLimitPolicy", "AuthPolicy")
180+
- Reference Kuadrant policies by name (e.g., "RateLimitPolicy", "TokenRateLimitPolicy", "AuthPolicy")
174181
- Ask for "complete examples" or "troubleshooting guide"
175182

176183
## Available Tools
@@ -390,6 +397,48 @@ spec:
390397
}
391398
```
392399

400+
### `create_tokenratelimitpolicy`
401+
Generate a Kuadrant TokenRateLimitPolicy manifest for AI/LLM API management.
402+
403+
**Arguments:**
404+
- `name` (required): Policy name
405+
- `namespace` (required): Namespace
406+
- `targetRef` (required): Target resource reference
407+
- `limits`: Token-based rate limit configurations
408+
- `defaults`: Default token limits
409+
- `overrides`: Override token limits
410+
411+
**Example Output:**
412+
```yaml
413+
apiVersion: kuadrant.io/v1
414+
kind: TokenRateLimitPolicy
415+
metadata:
416+
name: llm-api-limits
417+
namespace: production
418+
spec:
419+
targetRef:
420+
group: gateway.networking.k8s.io
421+
kind: HTTPRoute
422+
name: llm-route
423+
limits:
424+
"gpt-4":
425+
rates:
426+
- limit: 10000
427+
window: 60s
428+
when:
429+
- selector: request.headers.model
430+
operator: eq
431+
value: gpt-4
432+
"gpt-3.5":
433+
rates:
434+
- limit: 50000
435+
window: 60s
436+
when:
437+
- selector: request.headers.model
438+
operator: eq
439+
value: gpt-3.5-turbo
440+
```
441+
393442
## Kubernetes Integration
394443

395444
For a complete Kubernetes workflow, you can combine this server with the Kubernetes MCP server.
@@ -449,11 +498,11 @@ Or using the binary directly:
449498
#### Claude Code CLI
450499

451500
```bash
452-
# Add Kuadrant server
453-
claude mcp add kuadrant /path/to/kuadrant-mcp-server -s user
501+
# Add Kuadrant server (using Docker)
502+
claude mcp add -s user kuadrant docker -- run -i --rm ghcr.io/kuadrant/kuadrant-mcp-server:latest
454503
455504
# Add Kubernetes server
456-
claude mcp add kubernetes npx @flux159/mcp-server-kubernetes -s user
505+
claude mcp add -s user kubernetes npx -- @flux159/mcp-server-kubernetes
457506
```
458507

459508
### Safe Mode
@@ -599,6 +648,7 @@ spec:
599648
- DNSPolicy: `kuadrant.io/v1`
600649
- TLSPolicy: `kuadrant.io/v1alpha1`
601650
- RateLimitPolicy: `kuadrant.io/v1`
651+
- TokenRateLimitPolicy: `kuadrant.io/v1`
602652
- AuthPolicy: `kuadrant.io/v1`
603653

604654
## Claude Code CLI Setup
@@ -609,7 +659,7 @@ To use this server with Claude Code CLI:
609659

610660
```bash
611661
# Add using Docker image
612-
claude mcp add -s user kuadrant "docker run -i --rm ghcr.io/kuadrant/kuadrant-mcp-server:latest"
662+
claude mcp add -s user kuadrant docker -- run -i --rm ghcr.io/kuadrant/kuadrant-mcp-server:latest
613663
614664
# Verify installation
615665
claude mcp list
@@ -693,6 +743,9 @@ After setting up the MCP server, test it with these commands in Claude:
693743
# Per-user rate limiting
694744
Create a RateLimitPolicy for HTTPRoute 'api-routes' that allows 5 requests per 10 seconds for user 'alice' and 2 requests per 10 seconds for user 'bob' and apply this in my Kubernetes cluster with the kubernetes tool
695745
746+
# Token-based rate limiting for AI APIs
747+
Create a TokenRateLimitPolicy for HTTPRoute 'llm-gateway' that limits GPT-4 to 10000 tokens per minute and GPT-3.5 to 50000 tokens per minute and apply this in my Kubernetes cluster with the kubernetes tool
748+
696749
# Authentication
697750
Create an AuthPolicy for HTTPRoute 'api-routes' that requires JWT authentication from issuer 'https://auth.example.com' and apply this in my Kubernetes cluster with the kubernetes tool
698751
@@ -778,25 +831,38 @@ rates:
778831

779832
## Updating Documentation
780833

781-
The server includes embedded documentation from the official Kuadrant repositories. To update to the latest docs:
834+
Documentation is stored as markdown files in `docs/` and embedded into the binary at build time using Go's `//go:embed` directive.
835+
836+
### Quick Update
782837

783838
```bash
784-
# Extract latest documentation from source repos
839+
# 1. Fetch latest docs from upstream repos
785840
./update-docs.sh
786841
787-
# (Optional) Generate Go code from the extracted docs
788-
go run process-docs.go
842+
# 2. Review extracted content
843+
cat extracted-docs/extraction-summary.txt
844+
845+
# 3. Update markdown files in docs/ as needed
846+
# Compare with extracted-docs/ and update
789847
790-
# Review and integrate changes as needed
848+
# 4. Rebuild to embed changes
849+
go build -o kuadrant-mcp-server
791850
```
792851

793-
The update script:
794-
- Reads the mkdocs.yml configuration from docs.kuadrant.io
795-
- Extracts only the files actually published on the docs site
796-
- Preserves the original directory structure
797-
- Creates a summary of all extracted files
852+
### Architecture
853+
854+
- **`docs/`** - Markdown files for each resource (committed to git)
855+
- **`//go:embed`** - Files embedded into binary at build time
856+
- **Single binary** - No external files needed at runtime
798857

799-
For more details, see [UPDATE_DOCS.md](UPDATE_DOCS.md).
858+
### Adding New Resources
859+
860+
1. Create markdown file: `docs/newpolicy.md`
861+
2. Add mapping in `resources.go`:
862+
```go
863+
"kuadrant://docs/newpolicy": {"docs/newpolicy.md", "NewPolicy Reference", "Description"},
864+
```
865+
3. Rebuild: `go build -o kuadrant-mcp-server`
800866

801867
## Releases and Versioning
802868

0 commit comments

Comments
 (0)