This project deploys an MCP (Model Context Protocol) client-server architecture where:
- The client spawns the server as a subprocess using stdio communication
- The client exposes a REST API for remote interaction
- The server provides tools for accessing strategic planning data
┌─────────────────────────────────────────┐
│ Render Web Service │
│ ├─ app.py (FastAPI - Client) │
│ │ ├─ REST API endpoints │
│ │ ├─ Talks to Groq/LLM │
│ │ └─ Calls MCP server via stdio │
│ │ │
│ └─ db.py (MCP Server - subprocess) │
│ └─ Provides MCP tools: │
│ - get_institute_about │
│ - list_strategic_plans │
│ - get_strategic_map │
└─────────────────────────────────────────┘
- Python 3.13
uvpackage manager
- Install dependencies:
# Using uv (recommended)
cd db_chat && uv sync
cd ../mcp-client && uv sync
# Or using pip
pip install -r requirements.txt- Create
.envfile in the root with:
# Groq API Configuration
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama-3.3-70b-versatile
# API Configuration
GENERAL_BASE_URL=your_general_base_url_here
STRATEGIC_BASE_URL=your_strategic_base_url_here
API_USERNAME=your_username_here
API_PASSWORD=your_password_here
# Optional
MAX_TURNS=10cd mcp-client
uv run python client.py ../db_chat/db.pypython app.pyThen access at http://localhost:8000
GET /
GET /healthGET /toolsResponse:
{
"tools": [
{
"name": "get_institute_about",
"description": "Return the Arabic 'about institute' text",
"input_schema": {}
},
...
]
}POST /query
Content-Type: application/json
{
"query": "What is the institute about?"
}Response:
{
"response": "The institute is...",
"error": null
}- Push code to GitHub
- Connect your GitHub repo to Render
- Render will auto-detect
render.yaml - Set environment variables in Render dashboard:
GROQ_API_KEYGENERAL_BASE_URLSTRATEGIC_BASE_URLAPI_USERNAMEAPI_PASSWORD
- Deploy!
- Create a new Web Service on Render
- Connect your repository
- Configure:
- Environment: Python
- Build Command:
pip install -r requirements.txt - Start Command:
python app.py - Python Version: 3.13.0
- Add environment variables (see above)
- Deploy
# Health check
curl https://your-app.onrender.com/health
# List tools
curl https://your-app.onrender.com/tools
# Query
curl -X POST https://your-app.onrender.com/query \
-H "Content-Type: application/json" \
-d '{"query": "List the latest 5 strategic plans"}'import requests
url = "https://your-app.onrender.com/query"
response = requests.post(url, json={"query": "What is the institute about?"})
print(response.json()["response"]).
├── app.py # FastAPI web service (entry point)
├── requirements.txt # Python dependencies
├── render.yaml # Render deployment config
├── runtime.txt # Python version
├── db_chat/ # MCP Server
│ ├── db.py # MCP server implementation
│ ├── external_api_service.py # API client
│ └── pyproject.toml # Server dependencies
├── mcp-client/ # MCP Client
│ ├── client.py # MCP client implementation
│ ├── llm_service.py # LLM integration
│ └── pyproject.toml # Client dependencies
└── README.md # This file
| Variable | Description | Required |
|---|---|---|
GROQ_API_KEY |
Groq API key for LLM | Yes |
GROQ_MODEL |
Groq model name | No (default: llama-3.3-70b-versatile) |
GENERAL_BASE_URL |
General API base URL | Yes |
STRATEGIC_BASE_URL |
Strategic API base URL | Yes |
API_USERNAME |
API username | Yes |
API_PASSWORD |
API password | Yes |
MAX_TURNS |
Max conversation turns | No (default: 10) |
PORT |
Server port | No (default: 8000) |
-
Startup: When
app.pystarts, it:- Creates an
MCPClientinstance - Spawns
db.pyas a subprocess - Establishes stdio communication between them
- Creates an
-
Query Processing: When you send a query:
- FastAPI receives the HTTP request
- Passes it to the MCP client
- Client sends it to Groq LLM
- LLM decides if it needs tools
- If yes, calls the MCP server via stdio
- Server fetches data from external APIs
- Response flows back: Server → Client → LLM → API response
-
Shutdown: When the service stops:
- MCP client gracefully closes the connection
- Server subprocess terminates
- Resources are cleaned up
- Check that all environment variables are set
- Review Render logs for startup errors
- Ensure
requirements.txtincludes all dependencies - Rebuild the service on Render
- Verify
GROQ_API_KEYis valid - Check that the query actually requires tool usage
MIT