A secure, multi-tenant Model Context Protocol (MCP) server for accessing brand-specific Postgres databases. This server supports both local execution and authenticated remote access via HTTP/SSE.
This server uses Bearer Token Authentication. Access to the /sse and /messages endpoints requires a valid API key with the gbl- prefix.
Manage your keys locally or on EC2 using the built-in auth module:
# Activate your environment first
source .venv/bin/activate # Linux/EC2
.\.venv\Scripts\activate # Windows
# Generate a new key for a brand
python -m src.auth generate "Chumbak"
# List all active brands and keys
python -m src.auth list
# Revoke access for a brand
python -m src.auth revoke "OldBrand"For production, we use systemd to ensure the server starts automatically on reboot and restarts if it crashes.
git clone https://github.com/intern-analytics/MCPforGBL.git
cd MCPforGBL
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate a .env file for database credentials (gitignored):
nano .env
# Add DB_USER, DB_PASS, DB_HOST, etc.Create a service file:
sudo nano /etc/systemd/system/mcp-server.servicePaste the following (adjust paths if necessary):
[Unit]
Description=Brand MCP FastAPI Server
After=network.target
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/projects/MCPforGBL
ExecStart=/home/ubuntu/projects/MCPforGBL/.venv/bin/python -m src.server2
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable mcp-server
sudo systemctl start mcp-server
sudo systemctl status mcp-serverBecause this server is publicly exposed via Nginx and protected with a Let's Encrypt HTTPS certificate, you can connect directly in your browser.
https://mcpforgbl.duckdns.org/sse?token=gbl-YOUR_KEY_HEREUpdate your %APPDATA%\Claude\claude_desktop_config.json on Windows.
[!IMPORTANT]
UseC:\\PROGRA~1\\nodejs\\npx.cmdto avoid issues with spaces in the Windows file path.
{
"mcpServers": {
"gbl-data-lake": {
"command": "C:\\PROGRA~1\\nodejs\\npx.cmd",
"args": [
"-y",
"mcp-remote",
"https://mcpforgbl.duckdns.org/sse?token=gbl-YOUR_KEY_HERE"
]
}
}
}The server is architected to support multiple brands under one deployment:
WHERE brand_id = '...' into all incoming queries.access.log to monitor which brands are querying at what time.python -m src.server (Standard stdio)python -m src.server2 (HTTP/SSE via FastAPI)src/auth.pysrc/db.pyintern-analytics/MCPforGBL
April 6, 2026
April 13, 2026
Python