@@ -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