Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit 7002e42

Browse files
committed
more readme updates and documentation for HTTPS config and example nginx file
1 parent a4e68a3 commit 7002e42

File tree

4 files changed

+141
-45
lines changed

4 files changed

+141
-45
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ flowchart TB
125125
* Python 3.12+ (or compatible version supporting FastAPI and MCP Client)
126126
* [uv](https://github.com/astral-sh/uv) for package management.
127127
* Nginx installed (steps for [`Ubuntu`](https://ubuntu.com/tutorials/install-and-configure-nginx#1-overview)) and configured to use the generated configuration file.
128+
* **You definitely want to run your MCP Gateway and Registry over HTTPS**. Refer to [this guide](secure.md) for steps to install Nginx and secure with an SSL cert.
128129
* One of the example MCP servers packaged in this repo uses the [`Polygon`](https://polygon.io/stocks) API for stock ticker data. Get an API key from [here](https://polygon.io/dashboard/signup?redirect=%2Fdashboard%2Fkeys) and place it in `servers/fininfo/.env` as `POLYGON_API_KEY=your-polygon-key`. The server will still start without the API key but you will get a 401 Unauthorized error when using the tools provided by this server.
129130

130131
## Installation
@@ -203,10 +204,11 @@ flowchart TB
203204
uv run uvicorn registry.main:app --reload --host 0.0.0.0 --port 7860
204205
```
205206

206-
You should be able to see the MCP Registry running on `http://localhost:7860` as shown in the following screenshot.
207+
You should be able to see the MCP Registry running on `http://localhost:7860` as shown in the following screenshot. You should be able to access the Registry over HTTPS as well using the domain name you configured for your server in the [prerequisites](#Prerequisites) section.
207208

208209
![MCP Registry](./img/registry.png)
209210

211+
210212
## Configuration
211213

212214
1. **Environment Variables:** Create a `.env` file in the registry folder (`mcp-gateway/registry`).

examples/nginx_rev_proxy.conf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
server {
2+
listen 80;
3+
server_name ec2-44-192-72-20.compute-1.amazonaws.com;
4+
5+
# Optional: Redirect HTTP to HTTPS
6+
return 301 https://$host$request_uri;
7+
}
8+
9+
server {
10+
listen 443 ssl;
11+
server_name ec2-44-192-72-20.compute-1.amazonaws.com;
12+
13+
# Self-signed certificate paths
14+
ssl_certificate /etc/letsencrypt/live/awscostexplorer-mcp.ddns.net/fullchain.pem;
15+
ssl_certificate_key /etc/letsencrypt/live/awscostexplorer-mcp.ddns.net/privkey.pem;
16+
17+
#ssl_certificate /etc/ssl/certs/ec2-selfsigned.crt;
18+
#ssl_certificate_key /etc/ssl/private/ec2-selfsigned.key;
19+
20+
# Optional: Good practice
21+
ssl_protocols TLSv1.2 TLSv1.3;
22+
ssl_ciphers HIGH:!aNULL:!MD5;
23+
24+
# Route for Cost Explorer service
25+
location / {
26+
proxy_pass http://127.0.0.1:8000/;
27+
proxy_http_version 1.1;
28+
proxy_set_header Host $host;
29+
proxy_set_header X-Real-IP $remote_addr;
30+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31+
}
32+
33+
# Route for Current Time service
34+
location /currenttime/ {
35+
proxy_pass http://127.0.0.1:8001/;
36+
proxy_http_version 1.1;
37+
proxy_set_header Host $host;
38+
proxy_set_header X-Real-IP $remote_addr;
39+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
40+
}
41+
42+
# Route for Financial Information service
43+
location /fininfo/ {
44+
proxy_pass http://127.0.0.1:8002/;
45+
proxy_http_version 1.1;
46+
proxy_set_header Host $host;
47+
proxy_set_header X-Real-IP $remote_addr;
48+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49+
}
50+
51+
location /tsbedrock/ {
52+
# Fix the path handling by adding trailing slash and using $request_uri
53+
proxy_pass https://hwfo2k8szg.execute-api.us-east-1.amazonaws.com/prod/;
54+
55+
# AWS API Gateway often needs Host header to match the API Gateway domain
56+
proxy_set_header Host hwfo2k8szg.execute-api.us-east-1.amazonaws.com;
57+
58+
# These headers help with request routing
59+
proxy_set_header X-Real-IP $remote_addr;
60+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
61+
proxy_set_header X-Forwarded-Proto $scheme;
62+
63+
# API Gateway often requires these settings
64+
proxy_ssl_server_name on;
65+
proxy_buffer_size 16k;
66+
proxy_buffers 4 16k;
67+
68+
# Adjust the rewrite to handle the path correctly
69+
rewrite ^/tsbedrock/(.*)$ /prod/$1 break;
70+
}
71+
error_log /var/log/nginx/error.log debug;
72+
}

nginx_mcp_revproxy.conf

Lines changed: 0 additions & 44 deletions
This file was deleted.

secure.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Secure your MCP Gateway and Registry
2+
3+
A fully functional nginx configuration file is available [here](examples/nginx_rev_proxy.conf) in the examples folder for use as a reference i.e. you would need to edit this configuration file as per the information provided below.
4+
5+
1. Enable access to TCP port 443 from the IP address of your MCP client (your laptop, or anywhere) in the inbound rules in the security group associated with your EC2 instance.
6+
7+
1. You would need to have an HTTPS certificate and private key to proceed. Let's say you use `your-mcp-server-domain-name.com` as the domain for your MCP server then you will need an SSL cert for `your-mcp-server-domain-name.com` and it will be accessible to MCP clients as `https://your-mcp-server-domain-name.com/sse`. _While you can use a self-signed cert but it would require disabling SSL verification on the MCP client, we DO NOT recommend you do that_. If you are hosting your MCP server on EC2 then you could generate an SSL cert using [no-ip](https://www.noip.com/) or [Let' Encrypt](https://letsencrypt.org/) or other similar services. Place the SSL cert and private key files in `/etc/ssl/certs` and `/etc/ssl/privatekey` folders respectively on your EC2 machine.
8+
9+
1. Install `nginx` on your EC2 machine using the following commands.
10+
11+
```{.bashrc}
12+
sudo apt-get install nginx
13+
sudo nginx -t
14+
sudo systemctl reload nginx
15+
```
16+
17+
1. Get the hostname for your EC2 instance, this would be needed for configuring the `nginx` reverse proxy.
18+
19+
```{.bashrc}
20+
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") && curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/public-hostname
21+
```
22+
23+
1. Copy the following content into a new file `/etc/nginx/conf.d/ec2.conf`. Replace `YOUR_EC2_HOSTNAME`, `/etc/ssl/certs/cert.pem` and `/etc/ssl/privatekey/privkey.pem` with values appropriate for your setup.
24+
25+
```{.bashrc}
26+
server {
27+
listen 80;
28+
server_name YOUR_EC2_HOSTNAME;
29+
30+
# Optional: Redirect HTTP to HTTPS
31+
return 301 https://$host$request_uri;
32+
}
33+
34+
server {
35+
listen 443 ssl;
36+
server_name YOUR_EC2_HOSTNAME;
37+
38+
# Self-signed certificate paths
39+
ssl_certificate /etc/ssl/certs/cert.pem;
40+
ssl_certificate_key /etc/ssl/privatekey/privkey.pem;
41+
42+
# Optional: Good practice
43+
ssl_protocols TLSv1.2 TLSv1.3;
44+
ssl_ciphers HIGH:!aNULL:!MD5;
45+
46+
location / {
47+
# Reverse proxy to your local app (e.g., port 8000)
48+
proxy_pass http://127.0.0.1:8000;
49+
proxy_http_version 1.1;
50+
proxy_set_header Host $host;
51+
proxy_set_header X-Real-IP $remote_addr;
52+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
53+
}
54+
}
55+
56+
```
57+
58+
1. Restart `nginx`.
59+
60+
```{.bashrc}
61+
sudo systemctl start nginx
62+
```
63+
64+
1. Start your MCP server as usual as described in the [remote setup](#remote-setup) section.
65+
66+
1. Your MCP server is now accessible over HTTPS as `https://your-mcp-server-domain-name.com/sse` to your MCP client.

0 commit comments

Comments
 (0)