@@ -319,7 +319,7 @@ You can get started by copying the provided `.env.examples` to `.env` and making
319
319
> 🔐 ` BASIC_AUTH_USER ` /` PASSWORD ` are used for:
320
320
>
321
321
> * Logging into the web-based Admin UI
322
- > * Accessing APIs via Basic Auth (` curl -u admin:changeme ` )
322
+ > * Accessing APIs via Basic Auth (` curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" ` )
323
323
>
324
324
> 🔑 ` JWT_SECRET_KEY ` is used to:
325
325
>
@@ -576,11 +576,30 @@ make ibmcloud-ce-logs
576
576
577
577
# # API Endpoints
578
578
579
+ Generate an API Bearer token, and test the various API endpoints:
580
+
581
+ ` ` ` bash
582
+ # Generate a bearer token using the configured secret key (use the same as your .env)
583
+ export MCPGATEWAY_BEARER_TOKEN=$( python -m mcpgateway.utils.create_jwt_token -u admin --secret my-test-key)
584
+ echo ${MCPGATEWAY_BEARER_TOKEN}
585
+
586
+ # Quickly confirm that authentication works and the gateway is healthy
587
+ curl -s -k -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " https://localhost:4444/health
588
+
589
+ # Quickly confirm the gateway version & DB connectivity
590
+ curl -s -k -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " https://localhost:4444/version | jq
591
+ ` ` `
592
+
593
+ You can test the API endpoints through curl, or Swagger UI, and check detailed documentation on ReDoc:
594
+
595
+ * ** Swagger UI** → [http://localhost:4444/docs](http://localhost:4444/docs)
596
+ * ** ReDoc** → [http://localhost:4444/redoc](http://localhost:4444/redoc)
597
+
579
598
# ## Protocol APIs (MCP)
580
599
581
600
` ` ` bash
582
601
# Initialize MCP session
583
- curl -X POST -u admin:changeme \
602
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
584
603
-H " Content-Type: application/json" \
585
604
-d ' {
586
605
"protocol_version":"2025-03-26",
@@ -590,13 +609,13 @@ curl -X POST -u admin:changeme \
590
609
http://localhost:4444/protocol/initialize
591
610
592
611
# Ping (JSON-RPC style)
593
- curl -X POST -u admin:changeme \
612
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
594
613
-H " Content-Type: application/json" \
595
614
-d ' {"jsonrpc":"2.0","id":1,"method":"ping"}' \
596
615
http://localhost:4444/protocol/ping
597
616
598
617
# Completion for prompt/resource arguments
599
- curl -X POST -u admin:changeme \
618
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
600
619
-H " Content-Type: application/json" \
601
620
-d ' {
602
621
"ref":{"type":"ref/prompt","name":"example_prompt"},
@@ -605,7 +624,7 @@ curl -X POST -u admin:changeme \
605
624
http://localhost:4444/protocol/completion/complete
606
625
607
626
# Sampling (streaming)
608
- curl -N -X POST -u admin:changeme \
627
+ curl -N -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
609
628
-H " Content-Type: application/json" \
610
629
-d ' {
611
630
"messages":[{"role":"user","content":{"type":"text","text":"Hello"}}],
@@ -620,7 +639,7 @@ curl -N -X POST -u admin:changeme \
620
639
621
640
` ` ` bash
622
641
# Generic JSON-RPC calls (tools, gateways, roots, etc.)
623
- curl -X POST -u admin:changeme \
642
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
624
643
-H " Content-Type: application/json" \
625
644
-d ' {"jsonrpc":"2.0","id":1,"method":"list_tools"}' \
626
645
http://localhost:4444/rpc
@@ -634,7 +653,7 @@ Handles any method name: `list_tools`, `list_gateways`, `prompts/get`, or invoke
634
653
635
654
` ` ` bash
636
655
# Register a new tool
637
- curl -X POST -u admin:changeme \
656
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
638
657
-H " Content-Type: application/json" \
639
658
-d ' {
640
659
"name":"clock_tool",
@@ -649,23 +668,23 @@ curl -X POST -u admin:changeme \
649
668
http://localhost:4444/tools
650
669
651
670
# List tools
652
- curl -u admin:changeme http://localhost:4444/tools
671
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/tools
653
672
654
673
# Get tool by ID
655
- curl -u admin:changeme http://localhost:4444/tools/1
674
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/tools/1
656
675
657
676
# Update tool
658
- curl -X PUT -u admin:changeme \
677
+ curl -X PUT -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
659
678
-H " Content-Type: application/json" \
660
679
-d ' { "description":"Updated desc" }' \
661
680
http://localhost:4444/tools/1
662
681
663
682
# Toggle active status
664
- curl -X POST -u admin:changeme \
683
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
665
684
http://localhost:4444/tools/1/toggle? activate=false
666
685
667
686
# Delete tool
668
- curl -X DELETE -u admin:changeme http://localhost:4444/tools/1
687
+ curl -X DELETE -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/tools/1
669
688
` ` `
670
689
671
690
---
@@ -674,29 +693,29 @@ curl -X DELETE -u admin:changeme http://localhost:4444/tools/1
674
693
675
694
` ` ` bash
676
695
# Register a peer gateway
677
- curl -X POST -u admin:changeme \
696
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
678
697
-H " Content-Type: application/json" \
679
698
-d ' {"name":"peer_gateway","url":"http://peer:4444"}' \
680
699
http://localhost:4444/gateways
681
700
682
701
# List gateways
683
- curl -u admin:changeme http://localhost:4444/gateways
702
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/gateways
684
703
685
704
# Get gateway by ID
686
- curl -u admin:changeme http://localhost:4444/gateways/1
705
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/gateways/1
687
706
688
707
# Update gateway
689
- curl -X PUT -u admin:changeme \
708
+ curl -X PUT -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
690
709
-H " Content-Type: application/json" \
691
710
-d ' {"description":"New description"}' \
692
711
http://localhost:4444/gateways/1
693
712
694
713
# Toggle active status
695
- curl -X POST -u admin:changeme \
714
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
696
715
http://localhost:4444/gateways/1/toggle? activate=false
697
716
698
717
# Delete gateway
699
- curl -X DELETE -u admin:changeme http://localhost:4444/gateways/1
718
+ curl -X DELETE -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/gateways/1
700
719
` ` `
701
720
702
721
---
@@ -705,7 +724,7 @@ curl -X DELETE -u admin:changeme http://localhost:4444/gateways/1
705
724
706
725
` ` ` bash
707
726
# Register resource
708
- curl -X POST -u admin:changeme \
727
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
709
728
-H " Content-Type: application/json" \
710
729
-d ' {
711
730
"uri":"config://app/settings",
@@ -715,22 +734,22 @@ curl -X POST -u admin:changeme \
715
734
http://localhost:4444/resources
716
735
717
736
# List resources
718
- curl -u admin:changeme http://localhost:4444/resources
737
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/resources
719
738
720
739
# Read a resource
721
- curl -u admin:changeme http://localhost:4444/resources/config://app/settings
740
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/resources/config://app/settings
722
741
723
742
# Update resource
724
- curl -X PUT -u admin:changeme \
743
+ curl -X PUT -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
725
744
-H " Content-Type: application/json" \
726
745
-d ' {"content":"new=value"}' \
727
746
http://localhost:4444/resources/config://app/settings
728
747
729
748
# Delete resource
730
- curl -X DELETE -u admin:changeme http://localhost:4444/resources/config://app/settings
749
+ curl -X DELETE -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/resources/config://app/settings
731
750
732
751
# Subscribe to updates (SSE)
733
- curl -N -u admin:changeme http://localhost:4444/resources/subscribe/config://app/settings
752
+ curl -N -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/resources/subscribe/config://app/settings
734
753
` ` `
735
754
736
755
---
@@ -739,7 +758,7 @@ curl -N -u admin:changeme http://localhost:4444/resources/subscribe/config://app
739
758
740
759
` ` ` bash
741
760
# Create prompt template
742
- curl -X POST -u admin:changeme \
761
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
743
762
-H " Content-Type: application/json" \
744
763
-d ' {
745
764
"name":"greet",
@@ -753,29 +772,29 @@ curl -X POST -u admin:changeme \
753
772
http://localhost:4444/prompts
754
773
755
774
# List prompts
756
- curl -u admin:changeme http://localhost:4444/prompts
775
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/prompts
757
776
758
777
# Get prompt (with args)
759
- curl -X POST -u admin:changeme \
778
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
760
779
-H " Content-Type: application/json" \
761
780
-d ' {"user":"Alice"}' \
762
781
http://localhost:4444/prompts/greet
763
782
764
783
# Get prompt (no args)
765
- curl -u admin:changeme http://localhost:4444/prompts/greet
784
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/prompts/greet
766
785
767
786
# Update prompt
768
- curl -X PUT -u admin:changeme \
787
+ curl -X PUT -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
769
788
-H " Content-Type: application/json" \
770
789
-d ' {"template":"Hi, {{ user }}!"}' \
771
790
http://localhost:4444/prompts/greet
772
791
773
792
# Toggle active
774
- curl -X POST -u admin:changeme \
793
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
775
794
http://localhost:4444/prompts/5/toggle? activate=false
776
795
777
796
# Delete prompt
778
- curl -X DELETE -u admin:changeme http://localhost:4444/prompts/greet
797
+ curl -X DELETE -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/prompts/greet
779
798
` ` `
780
799
781
800
---
@@ -784,19 +803,19 @@ curl -X DELETE -u admin:changeme http://localhost:4444/prompts/greet
784
803
785
804
` ` ` bash
786
805
# List roots
787
- curl -u admin:changeme http://localhost:4444/roots
806
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/roots
788
807
789
808
# Add root
790
- curl -X POST -u admin:changeme \
809
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
791
810
-H " Content-Type: application/json" \
792
811
-d ' {"uri":"/data","name":"Data Root"}' \
793
812
http://localhost:4444/roots
794
813
795
814
# Remove root
796
- curl -X DELETE -u admin:changeme http://localhost:4444/roots/%2Fdata
815
+ curl -X DELETE -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/roots/%2Fdata
797
816
798
817
# Subscribe to root changes (SSE)
799
- curl -N -u admin:changeme http://localhost:4444/roots/changes
818
+ curl -N -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/roots/changes
800
819
` ` `
801
820
802
821
---
@@ -805,25 +824,25 @@ curl -N -u admin:changeme http://localhost:4444/roots/changes
805
824
806
825
` ` ` bash
807
826
# List servers
808
- curl -u admin:changeme http://localhost:4444/servers
827
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/servers
809
828
810
829
# Get server
811
- curl -u admin:changeme http://localhost:4444/servers/1
830
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/servers/1
812
831
813
832
# Create server
814
- curl -X POST -u admin:changeme \
833
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
815
834
-H " Content-Type: application/json" \
816
835
-d ' {"name":"db","description":"Database"}' \
817
836
http://localhost:4444/servers
818
837
819
838
# Update server
820
- curl -X PUT -u admin:changeme \
839
+ curl -X PUT -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
821
840
-H " Content-Type: application/json" \
822
841
-d ' {"description":"Updated"}' \
823
842
http://localhost:4444/servers/1
824
843
825
844
# Toggle active
826
- curl -X POST -u admin:changeme \
845
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " \
827
846
http://localhost:4444/servers/1/toggle? activate=false
828
847
` ` `
829
848
@@ -833,11 +852,11 @@ curl -X POST -u admin:changeme \
833
852
834
853
` ` ` bash
835
854
# Get aggregated metrics
836
- curl -u admin:changeme http://localhost:4444/metrics
855
+ curl -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/metrics
837
856
838
857
# Reset metrics (all or per-entity)
839
- curl -X POST -u admin:changeme http://localhost:4444/metrics/reset
840
- curl -X POST -u admin:changeme http://localhost:4444/metrics/reset? entity=tool& id=1
858
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/metrics/reset
859
+ curl -X POST -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/metrics/reset? entity=tool& id=1
841
860
` ` `
842
861
843
862
---
@@ -846,7 +865,7 @@ curl -X POST -u admin:changeme http://localhost:4444/metrics/reset?entity=tool&i
846
865
847
866
` ` ` bash
848
867
# SSE: all events
849
- curl -N -u admin:changeme http://localhost:4444/events
868
+ curl -N -H " Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN " http://localhost:4444/events
850
869
851
870
# WebSocket
852
871
wscat -c ws://localhost:4444/ws \
0 commit comments