loading…
Search for a command to run...
loading…
Enables Claude Desktop to query a PostgreSQL brand database through MCP. Supports local stdio and remote HTTP/SSE deployments with API key authentication for se
Enables Claude Desktop to query a PostgreSQL brand database through MCP. Supports local stdio and remote HTTP/SSE deployments with API key authentication for secure database access.
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.
min_size=3, max_size=7) to permanently resolve ECONNREFUSED timeout errors.chumbak_config.json for granular performance insights across ad placement, product, and search-term levels.saleorders to ensure reliance on the dedicated ebo_sales raw feed. Established standardized metric rules (e.g., online unit quantity as COUNT(*)).To add a new brand to the MCP server, create a JSON file inside src/brands/ (e.g., brand_config.json). The JSON file dictates the specific instructions, schema context, and access rules for the AI analyst.
General Structure (brand_config.json):
{
"brand_id": "unique_brand_identifier",
"display_name": "Brand Business Insights",
"tool_name": "brand_insights",
"allowed_db_user": [
"brand_db_user",
"mcp_superuser"
],
"description": "Short description of the AI persona and what it analyzes.",
"specific_instructions": "[[[ PROFESSIONAL COMMUNICATION GUIDELINES ]]]\n- Instructions on persona and tone.\n\n[[[ ANALYST LOGIC & CASTING RULES ]]]\n- Date parsing, casting rules, logic exceptions.\n\n[[[ MANDATORY FILTERS ]]]\n- Rules for excluding specific channels or testing environments.\n\n[[[ PER-TABLE COLUMN REFERENCE ]]]\n- Detailed descriptions of tables, join keys, and specific column logic.",
"schema_details": "[[[ SCHEMA OVERVIEW ]]]\n- High-level list of tables and their business purpose to help the AI write accurate SQL.",
"common_questions": [
"Top 10 selling SKUs for last month?",
"Offline vs Online revenue split?"
]
}
This server uses Bearer Token Authentication. Access to the /sse and /messages endpoints requires a valid API key with the gbl- prefix.
Before running any commands, ensure your virtual environment is active:
macOS / Linux / EC2:
source .venv/bin/activate
Windows (Local):
.\.venv\Scripts\activate
Manage your keys locally or on EC2 using the built-in auth module:
To provision API keys and map them to brand permissions, we host an internal Admin Dashboard and REST API. This dashboard automatically fetches the underlying database credentials from the .env file on the server and attaches them to an end_user token.
This API handles sensitive token generation, so it should only be accessed from localhost on your EC2 instance (binds to :8001).
You can build a secure tunnel from your local PC directly to your EC2 instance so you can interact with the Admin Dashboard UI in your local browser:
# Run this on your local Windows PC
ssh -i "path/to/your/key.pem" -L 8001:127.0.0.1:8001 ubuntu@YOUR_EC2_IP
Now, you can interact with the UI right from your local machine: http://127.0.0.1:8001/admin
From the UI, you can select multiple brands at once to provision under a single end-user email! An email with the token will be automatically sent to the user.
To start the Admin API on EC2:
python3 -m src.admin_api
With the Admin API running, you can create a new key via a direct curl request:
curl -X POST http://127.0.0.1:8001/keys/generate \
-H "Content-Type: application/json" \
-d '{"end_user": "[email protected]", "brand_names": ["chumbak", "imara"]}'
(The response will contain the unified api_key assigned to [email protected].)
Other utility endpoints:
curl http://127.0.0.1:8001/keyscurl -X DELETE http://127.0.0.1:8001/[email protected]&db_user=chumbak_userTo access the EC2 instance remotely:
ssh [email protected] -i mcp_server_gbl.pem
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.txt
Create 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.service
Paste 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.target
sudo systemctl daemon-reload
sudo systemctl enable mcp-server
sudo systemctl start mcp-server
sudo systemctl status mcp-server
Because 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.
[!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"
]
}
}
}
Update your ~/Library/Application Support/Claude/claude_desktop_config.json.
{
"mcpServers": {
"gbl-data-lake": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://mcpforgbl.duckdns.org/sse?token=gbl-YOUR_KEY_HERE"
]
}
}
}
If you prefer to connect directly to the EC2 instance's IP without using the DuckDNS URL or want to pass the token as a header instead of a URL parameter, use this configuration:
{
"mcpServers": {
"gbl-data-lake": {
"command": "C:\\PROGRA~1\\nodejs\\npx.cmd",
"args": [
"-y",
"mcp-remote",
"http://YOUR-EC2-PUBLIC-IP:8000/sse",
"--allow-http",
"--header",
"Authorization: Bearer gbl-YOUR_KEY_HERE"
]
}
}
}
Our platform is designed to scale securely and efficiently through a unified, token-per-user model.
Instead of an analyst managing multiple tokens for different brands, one user receives one API key. Within our api_keys.json registry, that token securely maps to any number of database credentials. At runtime, the MCP server dynamically retrieves the correct underlying database login from the EC2 .env file based on which tool the AI calls, ensuring rigorous multi-tenant data isolation.
If you are migrating the codebase between organizations (e.g., from intern-analytics to GOATBrandLabsTech) but want to keep both repositories strictly synchronized from your local machine, you can configure git to push to both simultaneously with a single git push command.
Run these commands in your local terminal:
git remote set-url --add --push origin https://github.com/intern-analytics/MCPforGBL.git
git remote set-url --add --push origin https://github.com/GOATBrandLabsTech/MCPforGBL.git
Once configured, any git push executed locally will automatically upload your code to both organization repositories at the exact same time.
python -m src.server (Standard stdio)python -m src.server2 (HTTP/SSE via FastAPI)src/auth.pysrc/db.pyRun in your terminal:
claude mcp add brand-mcp-server -- npx CSA PROJECT - FZCO © 2026 IFZA Business Park, DDP, Premises Number 31174 - 001
Security
Low riskAutomated heuristic from public metadata — not a security guarantee.