Skip to content

Commit 755a0db

Browse files
committed
Update auth used in README
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 3fe656c commit 755a0db

File tree

2 files changed

+64
-45
lines changed

2 files changed

+64
-45
lines changed

README.md

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ You can get started by copying the provided `.env.examples` to `.env` and making
319319
> 🔐 `BASIC_AUTH_USER`/`PASSWORD` are used for:
320320
>
321321
> * 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"`)
323323
>
324324
> 🔑 `JWT_SECRET_KEY` is used to:
325325
>
@@ -576,11 +576,30 @@ make ibmcloud-ce-logs
576576
577577
## API Endpoints
578578
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+
579598
### Protocol APIs (MCP)
580599
581600
```bash
582601
# Initialize MCP session
583-
curl -X POST -u admin:changeme \
602+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
584603
-H "Content-Type: application/json" \
585604
-d '{
586605
"protocol_version":"2025-03-26",
@@ -590,13 +609,13 @@ curl -X POST -u admin:changeme \
590609
http://localhost:4444/protocol/initialize
591610
592611
# Ping (JSON-RPC style)
593-
curl -X POST -u admin:changeme \
612+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
594613
-H "Content-Type: application/json" \
595614
-d '{"jsonrpc":"2.0","id":1,"method":"ping"}' \
596615
http://localhost:4444/protocol/ping
597616
598617
# Completion for prompt/resource arguments
599-
curl -X POST -u admin:changeme \
618+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
600619
-H "Content-Type: application/json" \
601620
-d '{
602621
"ref":{"type":"ref/prompt","name":"example_prompt"},
@@ -605,7 +624,7 @@ curl -X POST -u admin:changeme \
605624
http://localhost:4444/protocol/completion/complete
606625
607626
# Sampling (streaming)
608-
curl -N -X POST -u admin:changeme \
627+
curl -N -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
609628
-H "Content-Type: application/json" \
610629
-d '{
611630
"messages":[{"role":"user","content":{"type":"text","text":"Hello"}}],
@@ -620,7 +639,7 @@ curl -N -X POST -u admin:changeme \
620639
621640
```bash
622641
# 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" \
624643
-H "Content-Type: application/json" \
625644
-d '{"jsonrpc":"2.0","id":1,"method":"list_tools"}' \
626645
http://localhost:4444/rpc
@@ -634,7 +653,7 @@ Handles any method name: `list_tools`, `list_gateways`, `prompts/get`, or invoke
634653
635654
```bash
636655
# Register a new tool
637-
curl -X POST -u admin:changeme \
656+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
638657
-H "Content-Type: application/json" \
639658
-d '{
640659
"name":"clock_tool",
@@ -649,23 +668,23 @@ curl -X POST -u admin:changeme \
649668
http://localhost:4444/tools
650669
651670
# List tools
652-
curl -u admin:changeme http://localhost:4444/tools
671+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools
653672
654673
# 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
656675
657676
# Update tool
658-
curl -X PUT -u admin:changeme \
677+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
659678
-H "Content-Type: application/json" \
660679
-d '{ "description":"Updated desc" }' \
661680
http://localhost:4444/tools/1
662681
663682
# Toggle active status
664-
curl -X POST -u admin:changeme \
683+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
665684
http://localhost:4444/tools/1/toggle?activate=false
666685
667686
# 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
669688
```
670689
671690
---
@@ -674,29 +693,29 @@ curl -X DELETE -u admin:changeme http://localhost:4444/tools/1
674693
675694
```bash
676695
# Register a peer gateway
677-
curl -X POST -u admin:changeme \
696+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
678697
-H "Content-Type: application/json" \
679698
-d '{"name":"peer_gateway","url":"http://peer:4444"}' \
680699
http://localhost:4444/gateways
681700
682701
# List gateways
683-
curl -u admin:changeme http://localhost:4444/gateways
702+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways
684703
685704
# 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
687706
688707
# Update gateway
689-
curl -X PUT -u admin:changeme \
708+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
690709
-H "Content-Type: application/json" \
691710
-d '{"description":"New description"}' \
692711
http://localhost:4444/gateways/1
693712
694713
# Toggle active status
695-
curl -X POST -u admin:changeme \
714+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
696715
http://localhost:4444/gateways/1/toggle?activate=false
697716
698717
# 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
700719
```
701720
702721
---
@@ -705,7 +724,7 @@ curl -X DELETE -u admin:changeme http://localhost:4444/gateways/1
705724
706725
```bash
707726
# Register resource
708-
curl -X POST -u admin:changeme \
727+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
709728
-H "Content-Type: application/json" \
710729
-d '{
711730
"uri":"config://app/settings",
@@ -715,22 +734,22 @@ curl -X POST -u admin:changeme \
715734
http://localhost:4444/resources
716735
717736
# List resources
718-
curl -u admin:changeme http://localhost:4444/resources
737+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/resources
719738
720739
# 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
722741
723742
# Update resource
724-
curl -X PUT -u admin:changeme \
743+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
725744
-H "Content-Type: application/json" \
726745
-d '{"content":"new=value"}' \
727746
http://localhost:4444/resources/config://app/settings
728747
729748
# 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
731750
732751
# 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
734753
```
735754
736755
---
@@ -739,7 +758,7 @@ curl -N -u admin:changeme http://localhost:4444/resources/subscribe/config://app
739758
740759
```bash
741760
# Create prompt template
742-
curl -X POST -u admin:changeme \
761+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
743762
-H "Content-Type: application/json" \
744763
-d '{
745764
"name":"greet",
@@ -753,29 +772,29 @@ curl -X POST -u admin:changeme \
753772
http://localhost:4444/prompts
754773
755774
# List prompts
756-
curl -u admin:changeme http://localhost:4444/prompts
775+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/prompts
757776
758777
# Get prompt (with args)
759-
curl -X POST -u admin:changeme \
778+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
760779
-H "Content-Type: application/json" \
761780
-d '{"user":"Alice"}' \
762781
http://localhost:4444/prompts/greet
763782
764783
# 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
766785
767786
# Update prompt
768-
curl -X PUT -u admin:changeme \
787+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
769788
-H "Content-Type: application/json" \
770789
-d '{"template":"Hi, {{ user }}!"}' \
771790
http://localhost:4444/prompts/greet
772791
773792
# Toggle active
774-
curl -X POST -u admin:changeme \
793+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
775794
http://localhost:4444/prompts/5/toggle?activate=false
776795
777796
# 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
779798
```
780799
781800
---
@@ -784,19 +803,19 @@ curl -X DELETE -u admin:changeme http://localhost:4444/prompts/greet
784803
785804
```bash
786805
# List roots
787-
curl -u admin:changeme http://localhost:4444/roots
806+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/roots
788807
789808
# Add root
790-
curl -X POST -u admin:changeme \
809+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
791810
-H "Content-Type: application/json" \
792811
-d '{"uri":"/data","name":"Data Root"}' \
793812
http://localhost:4444/roots
794813
795814
# 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
797816
798817
# 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
800819
```
801820
802821
---
@@ -805,25 +824,25 @@ curl -N -u admin:changeme http://localhost:4444/roots/changes
805824
806825
```bash
807826
# List servers
808-
curl -u admin:changeme http://localhost:4444/servers
827+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers
809828
810829
# 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
812831
813832
# Create server
814-
curl -X POST -u admin:changeme \
833+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
815834
-H "Content-Type: application/json" \
816835
-d '{"name":"db","description":"Database"}' \
817836
http://localhost:4444/servers
818837
819838
# Update server
820-
curl -X PUT -u admin:changeme \
839+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
821840
-H "Content-Type: application/json" \
822841
-d '{"description":"Updated"}' \
823842
http://localhost:4444/servers/1
824843
825844
# Toggle active
826-
curl -X POST -u admin:changeme \
845+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
827846
http://localhost:4444/servers/1/toggle?activate=false
828847
```
829848
@@ -833,11 +852,11 @@ curl -X POST -u admin:changeme \
833852
834853
```bash
835854
# Get aggregated metrics
836-
curl -u admin:changeme http://localhost:4444/metrics
855+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/metrics
837856
838857
# 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
841860
```
842861
843862
---
@@ -846,7 +865,7 @@ curl -X POST -u admin:changeme http://localhost:4444/metrics/reset?entity=tool&i
846865
847866
```bash
848867
# 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
850869
851870
# WebSocket
852871
wscat -c ws://localhost:4444/ws \

docs/docs/development/github.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ make compose-up
214214
Quickly confirm that authentication works and the gateway is healthy:
215215

216216
```bash
217-
export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token -u admin)
217+
export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token -u admin --secret my-test-key)
218218
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/health
219219
```
220220

0 commit comments

Comments
 (0)