Skip to content

Commit 85fe212

Browse files
committed
adding resource APIs
Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
1 parent b8022e9 commit 85fe212

File tree

3 files changed

+1518
-309
lines changed

3 files changed

+1518
-309
lines changed

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,34 @@ Or if running the binary directly:
140140
}
141141
```
142142

143+
## Available Resources
144+
145+
The MCP server provides comprehensive documentation and examples through resources:
146+
147+
### Documentation Resources
148+
- `kuadrant://docs/gateway-api` - Gateway API overview and Kuadrant integration
149+
- `kuadrant://docs/dnspolicy` - Complete DNSPolicy reference with examples
150+
- `kuadrant://docs/ratelimitpolicy` - RateLimitPolicy patterns and advanced usage
151+
- `kuadrant://docs/authpolicy` - AuthPolicy authentication and authorization methods
152+
- `kuadrant://docs/tlspolicy` - TLSPolicy certificate management guide
153+
154+
### Example Resources
155+
- `kuadrant://examples/basic-setup` - Simple API with rate limiting and API key auth
156+
- `kuadrant://examples/production-setup` - Full production setup with TLS, DNS, JWT auth
157+
158+
### Troubleshooting
159+
- `kuadrant://troubleshooting` - Common issues, debugging techniques, and solutions
160+
161+
Access these resources in Claude by asking questions like:
162+
- "Show me the Kuadrant rate limiting documentation"
163+
- "How do I set up production TLS with Kuadrant?"
164+
- "Help me troubleshoot my AuthPolicy not working"
165+
166+
**Note**: Claude may not always use resources automatically. To ensure resource usage:
167+
- Be specific about wanting documentation or examples
168+
- Reference Kuadrant policies by name (e.g., "RateLimitPolicy", "AuthPolicy")
169+
- Ask for "complete examples" or "troubleshooting guide"
170+
143171
## Available Tools
144172

145173
### `create_gateway`
@@ -392,7 +420,7 @@ Using Docker (recommended):
392420
},
393421
"kubernetes": {
394422
"command": "npx",
395-
"args": ["mcp-server-kubernetes"]
423+
"args": ["@flux159/mcp-server-kubernetes"]
396424
}
397425
}
398426
}
@@ -407,7 +435,7 @@ Or using the binary directly:
407435
},
408436
"kubernetes": {
409437
"command": "npx",
410-
"args": ["mcp-server-kubernetes"]
438+
"args": ["@flux159/mcp-server-kubernetes"]
411439
}
412440
}
413441
}
@@ -420,7 +448,7 @@ Or using the binary directly:
420448
claude mcp add kuadrant /path/to/kuadrant-mcp-server -s user
421449
422450
# Add Kubernetes server
423-
claude mcp add kubernetes npx mcp-server-kubernetes -s user
451+
claude mcp add kubernetes npx @flux159/mcp-server-kubernetes -s user
424452
```
425453

426454
### Safe Mode
@@ -433,7 +461,7 @@ To prevent destructive operations, run the Kubernetes server in safe mode:
433461
"mcpServers": {
434462
"kubernetes": {
435463
"command": "npx",
436-
"args": ["mcp-server-kubernetes"],
464+
"args": ["@flux159/mcp-server-kubernetes"],
437465
"env": {
438466
"ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS": "true"
439467
}
@@ -442,7 +470,7 @@ To prevent destructive operations, run the Kubernetes server in safe mode:
442470
}
443471
444472
# Or with Claude Code CLI:
445-
ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=true npx mcp-server-kubernetes
473+
ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=true npx @flux159/mcp-server-kubernetes
446474
```
447475

448476
### Example Workflow

main.go

Lines changed: 1 addition & 304 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func main() {
542542
),
543543
)
544544

545-
// Add resources for Kuadrant documentation
545+
// Add resources for Kuadrant documentation (from resources.go)
546546
addKuadrantResources(server)
547547

548548
ctx := context.Background()
@@ -579,306 +579,3 @@ func main() {
579579
}
580580
}
581581

582-
// Resource handlers
583-
func gatewayAPIResourceHandler(ctx context.Context, ss *mcp.ServerSession, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error) {
584-
content := `# Gateway API and Kuadrant
585-
586-
The Gateway API is a Kubernetes API for managing ingress traffic. Kuadrant extends the Gateway API with additional policies for:
587-
588-
- DNS management (DNSPolicy)
589-
- TLS certificate management (TLSPolicy)
590-
- Rate limiting (RateLimitPolicy)
591-
- Authentication and authorization (AuthPolicy)
592-
593-
## Enabling Kuadrant on a Gateway
594-
595-
Add the annotation to your Gateway:
596-
kuadrant.io/policy: enabled
597-
598-
## Policy Attachment
599-
600-
Policies attach to Gateway API resources:
601-
- Gateway: Affects all routes through the gateway
602-
- HTTPRoute: Affects specific routes
603-
`
604-
return &mcp.ReadResourceResult{
605-
Contents: []*mcp.ResourceContents{
606-
{
607-
URI: params.URI,
608-
MIMEType: "text/plain",
609-
Text: content,
610-
},
611-
},
612-
}, nil
613-
}
614-
615-
func dnsPolicyResourceHandler(ctx context.Context, ss *mcp.ServerSession, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error) {
616-
content := `# DNSPolicy
617-
618-
DNSPolicy enables DNS management for Gateway API resources.
619-
620-
## Specification
621-
622-
apiVersion: kuadrant.io/v1
623-
kind: DNSPolicy
624-
625-
Key fields:
626-
- targetRef: References a Gateway
627-
- providerRefs: DNS provider credentials
628-
- loadBalancing: Geographic and weighted load balancing
629-
- healthCheck: Endpoint health monitoring
630-
631-
## Example: Multi-region DNS
632-
633-
apiVersion: kuadrant.io/v1
634-
kind: DNSPolicy
635-
metadata:
636-
name: multi-region-dns
637-
spec:
638-
targetRef:
639-
group: gateway.networking.k8s.io
640-
kind: Gateway
641-
name: prod-gateway
642-
providerRefs:
643-
- name: aws-route53
644-
loadBalancing:
645-
geo:
646-
defaultGeo: true
647-
zones:
648-
- id: us-east-1
649-
weight: 100
650-
- id: eu-west-1
651-
weight: 100
652-
healthCheck:
653-
endpoint: /health
654-
interval: 30s
655-
threshold: 3
656-
`
657-
return &mcp.ReadResourceResult{
658-
Contents: []*mcp.ResourceContents{
659-
{
660-
URI: params.URI,
661-
MIMEType: "text/plain",
662-
Text: content,
663-
},
664-
},
665-
}, nil
666-
}
667-
668-
func rateLimitPolicyResourceHandler(ctx context.Context, ss *mcp.ServerSession, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error) {
669-
content := `# RateLimitPolicy
670-
671-
RateLimitPolicy provides fine-grained rate limiting for APIs.
672-
673-
## Specification
674-
675-
apiVersion: kuadrant.io/v1
676-
kind: RateLimitPolicy
677-
678-
Key concepts:
679-
- limits: Named rate limit definitions
680-
- when: Conditions for applying limits
681-
- counters: What to count (requests, unique users, etc.)
682-
683-
## Example: API Rate Limiting
684-
685-
apiVersion: kuadrant.io/v1
686-
kind: RateLimitPolicy
687-
metadata:
688-
name: api-limits
689-
spec:
690-
targetRef:
691-
group: gateway.networking.k8s.io
692-
kind: HTTPRoute
693-
name: api-route
694-
limits:
695-
per_user:
696-
rates:
697-
- limit: 100
698-
window: 60s
699-
counters:
700-
- auth.identity.userid
701-
per_ip:
702-
rates:
703-
- limit: 1000
704-
window: 60s
705-
counters:
706-
- request.headers.x-forwarded-for
707-
708-
## Selector Syntax
709-
710-
when:
711-
- predicate: request.path == "/api/v1/expensive"
712-
limits:
713-
expensive_endpoint:
714-
rates:
715-
- limit: 10
716-
window: 60s
717-
`
718-
return &mcp.ReadResourceResult{
719-
Contents: []*mcp.ResourceContents{
720-
{
721-
URI: params.URI,
722-
MIMEType: "text/plain",
723-
Text: content,
724-
},
725-
},
726-
}, nil
727-
}
728-
729-
func authPolicyResourceHandler(ctx context.Context, ss *mcp.ServerSession, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error) {
730-
content := `# AuthPolicy
731-
732-
AuthPolicy provides authentication and authorization for APIs.
733-
734-
## Specification
735-
736-
apiVersion: kuadrant.io/v1
737-
kind: AuthPolicy
738-
739-
Key sections:
740-
- authentication: Identity verification (JWT, API keys, etc.)
741-
- authorization: Access control (OPA, simple patterns)
742-
- response: Custom response handling
743-
744-
## Example: JWT Authentication with RBAC
745-
746-
apiVersion: kuadrant.io/v1
747-
kind: AuthPolicy
748-
metadata:
749-
name: api-auth
750-
spec:
751-
targetRef:
752-
group: gateway.networking.k8s.io
753-
kind: HTTPRoute
754-
name: api-route
755-
rules:
756-
authentication:
757-
jwt:
758-
jwt:
759-
issuerUrl: https://auth.example.com
760-
audiences:
761-
- api.example.com
762-
authorization:
763-
opa:
764-
rego: |
765-
allow = true {
766-
input.auth.identity.realm_access.roles[_] == "api-user"
767-
}
768-
response:
769-
unauthorized:
770-
headers:
771-
WWW-Authenticate: Bearer realm="api"
772-
body: "Unauthorized"
773-
code: 401
774-
`
775-
return &mcp.ReadResourceResult{
776-
Contents: []*mcp.ResourceContents{
777-
{
778-
URI: params.URI,
779-
MIMEType: "text/plain",
780-
Text: content,
781-
},
782-
},
783-
}, nil
784-
}
785-
786-
func tlsPolicyResourceHandler(ctx context.Context, ss *mcp.ServerSession, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error) {
787-
content := `# TLSPolicy
788-
789-
TLSPolicy automates TLS certificate management for Gateways.
790-
791-
## Specification
792-
793-
apiVersion: kuadrant.io/v1alpha1
794-
kind: TLSPolicy
795-
796-
Integrates with cert-manager for certificate lifecycle management.
797-
798-
## Example: Let's Encrypt Wildcard Certificate
799-
800-
apiVersion: kuadrant.io/v1alpha1
801-
kind: TLSPolicy
802-
metadata:
803-
name: wildcard-tls
804-
spec:
805-
targetRef:
806-
group: gateway.networking.k8s.io
807-
kind: Gateway
808-
name: prod-gateway
809-
issuerRef:
810-
group: cert-manager.io
811-
kind: ClusterIssuer
812-
name: letsencrypt-prod
813-
commonName: "*.example.com"
814-
duration: 90d
815-
renewBefore: 30d
816-
dnsNames:
817-
- "*.example.com"
818-
- "example.com"
819-
secretTemplate:
820-
annotations:
821-
kuadrant.io/tlspolicy: wildcard-tls
822-
`
823-
return &mcp.ReadResourceResult{
824-
Contents: []*mcp.ResourceContents{
825-
{
826-
URI: params.URI,
827-
MIMEType: "text/plain",
828-
Text: content,
829-
},
830-
},
831-
}, nil
832-
}
833-
834-
// addKuadrantResources adds MCP resources for Kuadrant documentation
835-
func addKuadrantResources(server *mcp.Server) {
836-
// Add resources
837-
server.AddResources(
838-
&mcp.ServerResource{
839-
Resource: &mcp.Resource{
840-
URI: "kuadrant://docs/gateway-api",
841-
Name: "Gateway API Overview",
842-
Description: "Overview of Gateway API and Kuadrant integration",
843-
MIMEType: "text/plain",
844-
},
845-
Handler: gatewayAPIResourceHandler,
846-
},
847-
&mcp.ServerResource{
848-
Resource: &mcp.Resource{
849-
URI: "kuadrant://docs/dnspolicy",
850-
Name: "DNSPolicy Reference",
851-
Description: "DNSPolicy specification and examples",
852-
MIMEType: "text/plain",
853-
},
854-
Handler: dnsPolicyResourceHandler,
855-
},
856-
&mcp.ServerResource{
857-
Resource: &mcp.Resource{
858-
URI: "kuadrant://docs/ratelimitpolicy",
859-
Name: "RateLimitPolicy Reference",
860-
Description: "RateLimitPolicy specification and examples",
861-
MIMEType: "text/plain",
862-
},
863-
Handler: rateLimitPolicyResourceHandler,
864-
},
865-
&mcp.ServerResource{
866-
Resource: &mcp.Resource{
867-
URI: "kuadrant://docs/authpolicy",
868-
Name: "AuthPolicy Reference",
869-
Description: "AuthPolicy specification and examples",
870-
MIMEType: "text/plain",
871-
},
872-
Handler: authPolicyResourceHandler,
873-
},
874-
&mcp.ServerResource{
875-
Resource: &mcp.Resource{
876-
URI: "kuadrant://docs/tlspolicy",
877-
Name: "TLSPolicy Reference",
878-
Description: "TLSPolicy specification and examples",
879-
MIMEType: "text/plain",
880-
},
881-
Handler: tlsPolicyResourceHandler,
882-
},
883-
)
884-
}

0 commit comments

Comments
 (0)