Retail-MCP-Siting-Engine
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Retail-MCP-Siting-EngineFind top 3 high-traffic transit stations for a new coffee shop near downtown."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Smart Retail Siting & Data Engine
A production-grade, local implementation of an AI-powered retail location intelligence system. The system runs completely locally with zero cloud billing dependencies, using open-source infrastructure to simulate enterprise spatial data capabilities.
๐๏ธ Architecture
Technical Stack
Backend: Python 3.11+ with FastAPI (asynchronous execution)
AI Orchestration: LangChain for LLM integration
Database: SQLite with SpatiaLite extension for spatial operations
MCP Server: Local Model Context Protocol implementation for database tool contracts
LLM Core: Ollama (local) or Google Gemini API (free tier)
Frontend: Responsive dark-mode dashboard with Tailwind CSS and Chart.js
Real-time: WebSocket/SSE for live log streaming
Core Components
1. Local Database & Seed Pipeline
SQLite database with SpatiaLite extension for geospatial operations
Automated ingestion pipeline for mock spatial datasets
Tables: transit stations, commerce points, storefront locations
Spatial queries using Haversine formula for distance calculations
2. Local MCP Server
get_schema: Returns database schema and table structuresexecute_query: Executes SQL queries with security validationget_spatial_examples: Provides example spatial analysis queriesget_table_schema: Detailed schema for specific tables
3. Agentic Execution Controller
Four-phase execution loop:
Phase A: Schema inspection and database learning
Phase B: LLM generates optimized SQL queries
Phase C: Query execution with raw data capture
Phase D: LLM generates strategic business insights
4. Real-time Frontend
Live WebSocket connection for streaming logs
Interactive dashboard with phase progress tracking
Chart.js visualization of spatial analysis results
Database statistics and monitoring
Related MCP server: PostGIS Yukon MCP
๐ Quick Start
Prerequisites
Python 3.11 or higher
Ollama (recommended) or Google Gemini API key
Git
Installation
Windows
# Run the setup script
setup.bat
# Or manually
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python run.py setupLinux/Mac
# Make setup script executable
chmod +x setup.sh
# Run setup
./setup.sh
# Or manually
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 run.py setupConfiguration
Edit the .env file to configure your settings:
# LLM Configuration
LLM_PROVIDER=OLLAMA # or GEMINI
# Ollama Configuration (recommended)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3
# Google Gemini Configuration (alternative)
GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-pro
# Database Configuration
DATABASE_PATH=data/retail_siting.db
# Server Configuration
HOST=0.0.0.0
PORT=8000
LOG_LEVEL=INFORunning Ollama (Recommended)
Install Ollama from ollama.ai
Start the Ollama service:
ollama servePull the model:
ollama pull llama3
Starting the Application
# Development mode (setup + run)
python run.py dev
# Or run directly
python run.py runThe application will be available at:
Backend API: http://localhost:8000
Frontend Dashboard: http://localhost:8000/static/index.html
API Documentation: http://localhost:8000/docs
๐ Usage
Running Analysis
Open the frontend dashboard in your browser
Enter your analysis request in the text area, for example:
"Identify the top 3 high-volume cyclist transit points for a new coffee shop store layout expansion"
Select your LLM provider (Ollama or Gemini)
Click "Run Analysis"
Watch the real-time execution progress in the console
View the results and business insights
API Endpoints
GET /health- Health checkGET /api/schema- Get database schemaPOST /api/analyze- Run analysis requestGET /api/status- Get execution statusPOST /api/ingest-data- Trigger data ingestionWS /ws- WebSocket for real-time logsGET /api/logs- Get recent logsGET /api/logs/stream- SSE log streaming
Example API Usage
# Get database schema
curl http://localhost:8000/api/schema
# Run analysis
curl -X POST http://localhost:8000/api/analyze \
-H "Content-Type: application/json" \
-d '{"prompt": "Find top 5 high-traffic transit stations", "llm_provider": "ollama"}'
# Check execution status
curl http://localhost:8000/api/status๐งช Testing
Run the test suite:
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_database.py
# Run with coverage
pytest tests/ --cov=backend --cov-report=html๐ Project Structure
Retail-MCP-Siting-Engine/
โโโ backend/
โ โโโ app.py # FastAPI server with WebSocket
โ โโโ database.py # SQLite + SpatiaLite database
โ โโโ data_ingestion.py # Mock data generation pipeline
โ โโโ mcp_server.py # MCP server implementation
โ โโโ agent_controller.py # Agentic execution controller
โโโ data/
โ โโโ retail_siting.db # Local database (created on init)
โโโ frontend/
โ โโโ index.html # Main dashboard
โ โโโ app.js # Frontend JavaScript
โโโ tests/
โ โโโ test_database.py # Database tests
โ โโโ test_mcp_server.py # MCP server tests
โโโ requirements.txt # Python dependencies
โโโ run.py # Main setup and run script
โโโ setup.bat # Windows setup script
โโโ setup.sh # Linux/Mac setup script
โโโ .env.example # Environment configuration template
โโโ README.md # This file๏ฟฝ Features
Database Capabilities
Transit Stations: Bike transit routes with capacity scores
Commerce Points: Business locations with revenue metrics
Storefronts: Potential retail locations with accessibility scores
Spatial Queries: Distance calculations, nearby points, spatial joins
AI/LLM Integration
Multi-Provider Support: Ollama (local) or Google Gemini
Dynamic SQL Generation: LLM writes optimized queries based on schema
Business Intelligence: Strategic insights from query results
Error Handling: Graceful failure with informative messages
Real-time Monitoring
Live Logs: WebSocket streaming of application logs
Phase Tracking: Visual progress through execution phases
Status Updates: Real-time execution status and progress
Error Reporting: Immediate feedback on failures
๐ก๏ธ Security
SQL injection protection via query validation
Dangerous SQL keyword blocking (DROP, DELETE, etc.)
Environment variable configuration for sensitive data
No cloud dependencies - everything runs locally
No data leaves your machine
โ๏ธ Configuration Options
LLM Providers
Ollama (Recommended)
Completely free and local
Requires Ollama installation
Supports multiple models (llama3, mistral, etc.)
No API keys needed
Google Gemini
Free tier available
Requires API key
Good alternative if Ollama is not available
Configure via
.envfile
Database Options
SQLite + SpatiaLite (Default)
Lightweight, serverless
Built-in spatial extensions
Portable database file
No additional setup required
DuckDB (Optional)
Alternative database engine
Included in requirements
Can be configured in code
๐ Troubleshooting
Ollama Connection Issues
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Start Ollama service
ollama serve
# Pull required model
ollama pull llama3Database Issues
# Reinitialize database
rm data/retail_siting.db
python run.py setupPort Already in Use
# Change port in .env
PORT=8001
# Or kill the process using the port
# Windows
netstat -ano | findstr :8000
taskkill /PID <PID> /F
# Linux/Mac
lsof -ti:8000 | xargs kill -9Dependency Issues
# Create fresh virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install --upgrade pip
pip install -r requirements.txt๐ Performance
Database Query: < 100ms for typical spatial queries
LLM Generation: 2-10 seconds depending on query complexity
Total Analysis: 5-30 seconds for complete 4-phase execution
Memory Usage: ~500MB for Python + LLM
Disk Usage: ~10MB for database with mock data
๐ค Contributing
This is a demonstration project for local AI-powered spatial analysis. Feel free to extend it with:
Additional spatial analysis functions
More sophisticated mock data generation
Support for other LLM providers
Enhanced frontend visualizations
Additional database backends
๐ License
This project is provided as-is for educational and demonstration purposes.
๐ Acknowledgments
FastAPI - Modern, fast web framework
LangChain - LLM orchestration framework
Ollama - Local LLM runtime
SpatiaLite - Spatial extensions for SQLite
Chart.js - Data visualization library
Tailwind CSS - Utility-first CSS framework
๐ Support
For issues and questions:
Check the troubleshooting section
Review the logs in the frontend console
Ensure all prerequisites are installed
Verify configuration in
.envfile
Built with โค๏ธ for local, privacy-first AI applications
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
AlicenseAqualityBmaintenanceEnables AI assistants to interact with 3DCityDB v5 through natural language, dynamically resolving object classes, properties, and codelists to answer spatial questions and execute SQL queries on CityGML data.1410Apache 2.0- AlicenseNot gradedqualityFmaintenanceEnables natural language and geospatial queries on PostGIS databases, with 32 tools for spatial analysis, geometry operations, and database management.4MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI to query a business database for customers, orders, and revenue using natural language through safe, well-defined tools.
- AlicenseAqualityAmaintenanceTurns CREHQ's live location-intelligence REST API into native tools for AI agents, enabling natural-language queries about franchise brands, store locations, credit signals, and site tenancy history.3351MIT
Related MCP Connectors
Query PostgreSQL databases in plain English โ LLM-generated, safety-validated SQL.
Local business intel for AI agents: audits, lead scoring, tech stack, prospecting.
Bounded tools for rendering, extraction, RAG, enrichment, local discovery and review analysis.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gyanankur23/Retail-MCP-Siting-Engine'
If you have feedback or need assistance with the MCP directory API, please join our Discord server