8.6 KiB
Development Guide: GeoGuessr MCP Server
This guide covers multiple ways to develop the GeoGuessr MCP Server using PyCharm, including remote development options.
Table of Contents
- Option 1: PyCharm Remote Development (Gateway)
- Option 2: PyCharm with Docker Interpreter
- Option 3: Dev Containers
- Option 4: SSH Remote Interpreter
- Running Tests
- Debugging
Option 1: PyCharm Remote Development (Gateway)
Best for: Full IDE experience on a remote server with PyCharm Professional.
Prerequisites
- PyCharm Professional 2023.2+ or JetBrains Gateway
- SSH access to your VPS
Setup Steps
-
Install JetBrains Gateway (or use PyCharm Professional's remote dev feature)
- Download from: https://www.jetbrains.com/remote-development/gateway/
-
Connect to your VPS
Gateway → New Connection → SSH Host: your-vps-ip User: your-username Authentication: Key pair or password -
Clone the project on the server
ssh user@your-vps git clone https://github.com/yourusername/geoguessr-mcp.git cd geoguessr-mcp -
Open in Gateway
- Select IDE: PyCharm Professional
- Project directory:
/home/user/geoguessr-mcp - Click "Download and Start IDE"
-
Configure the environment
- Gateway will install a remote IDE backend
- Set up your Python interpreter (see below)
- Copy
.env.exampleto.envand add your cookie
Configure Python Interpreter in Gateway
- File → Settings → Project → Python Interpreter
- Add Interpreter → Add Local Interpreter
- Select "Virtualenv Environment" → New
- Location:
/home/user/geoguessr-mcp/.venv - Base interpreter:
/usr/bin/python3.12 - Click OK
Option 2: PyCharm with Docker Interpreter
Best for: Consistent dev environment, running PyCharm locally with Docker.
Prerequisites
- PyCharm Professional
- Docker installed locally
- Docker Compose installed
Setup Steps
-
Open the project locally in PyCharm
-
Build the dev container
cd geoguessr-mcp docker compose -f .devcontainer/docker-compose.dev.yml build -
Configure Docker Interpreter
a. File → Settings → Project → Python Interpreter
b. Click the gear icon → Add
c. Select "Docker Compose"
d. Configuration file:
.devcontainer/docker-compose.dev.ymle. Service:
devf. Python interpreter:
/usr/local/bin/pythong. Click OK
-
Configure Environment Variables
a. Run → Edit Configurations
b. Select your run configuration
c. Environment variables: Add
GEOGUESSR_NCFA_COOKIE=your_cookieOr create a
.envfile:cp .env.example .env # Edit .env with your cookie -
Run/Debug
- Use the run configurations provided in
.idea/runConfigurations/
- Use the run configurations provided in
Docker Compose Commands
# Start dev container
docker compose -f .devcontainer/docker-compose.dev.yml up -d
# View logs
docker compose -f .devcontainer/docker-compose.dev.yml logs -f
# Stop
docker compose -f .devcontainer/docker-compose.dev.yml down
# Rebuild
docker compose -f .devcontainer/docker-compose.dev.yml build --no-cache
Option 3: Dev Containers
Best for: VS Code users or PyCharm 2024.1+ with Dev Containers support.
Using VS Code
-
Install the "Dev Containers" extension
-
Open the project folder
-
Click "Reopen in Container" when prompted (or F1 → "Dev Containers: Reopen in Container")
-
VS Code will build and connect to the dev container
Using PyCharm (2024.1+)
PyCharm 2024.1+ has experimental Dev Containers support:
-
File → Remote Development → Dev Containers
-
Select the
.devcontainer/devcontainer.jsonfile -
PyCharm will build and connect to the container
Manual Container Development
If your IDE doesn't support dev containers natively:
# Start the dev container
docker compose -f .devcontainer/docker-compose.dev.yml up -d
# Exec into the container
docker exec -it geoguessr-mcp-dev-1 bash
# Inside container: run the server
cd /workspace
python server.py
# Inside container: run tests
pytest -v
Option 4: SSH Remote Interpreter
Best for: PyCharm Professional users who want to run code directly on VPS.
Setup Steps
-
Prepare your VPS
ssh user@your-vps # Install Python 3.12 sudo apt update sudo apt install python3.12 python3.12-venv python3.12-dev # Clone the project git clone https://github.com/yourusername/geoguessr-mcp.git cd geoguessr-mcp # Create virtual environment python3.12 -m venv .venv source .venv/bin/activate pip install -r requirements.txt -r requirements-dev.txt -
Configure PyCharm SSH Interpreter
a. File → Settings → Project → Python Interpreter
b. Click gear → Add → SSH Interpreter
c. New server configuration:
- Host: your-vps-ip
- Username: your-username
- Authentication: Key pair
d. Next → Interpreter path:
/home/user/geoguessr-mcp/.venv/bin/pythone. Sync folders:
- Local: Your local project path
- Remote:
/home/user/geoguessr-mcp
-
Configure deployment
a. Tools → Deployment → Configuration
b. Add SFTP server
c. Enable automatic upload (Tools → Deployment → Automatic Upload)
Running Tests
From PyCharm
- Use the "Run Tests" configuration
- Or right-click on
tests/→ Run 'pytest in tests'
From Command Line
# Run all tests
pytest -v
# Run with coverage
pytest -v --cov=. --cov-report=html
# Run specific test file
pytest tests/test_server.py -v
# Run only unit tests (skip integration)
pytest -v -m "not integration"
# Run integration tests (requires real cookie)
GEOGUESSR_NCFA_COOKIE=your_real_cookie pytest -v -m integration
Debugging
PyCharm Debugger
-
Set breakpoints by clicking in the gutter
-
Run → Debug 'Debug MCP Server'
-
Use the debugger panel to:
- Step through code (F8)
- Step into functions (F7)
- Evaluate expressions
- View variables
Remote Debugging (debugpy)
For debugging in Docker or remote environments:
-
Modify server.py to enable debugpy:
import debugpy debugpy.listen(("0.0.0.0", 5678)) print("Waiting for debugger...") debugpy.wait_for_client() -
Configure PyCharm Remote Debug
a. Run → Edit Configurations → Add → Python Debug Server
b. IDE host name:
localhostc. Port:
5678d. Path mappings:
- Local:
/path/to/local/project - Remote:
/workspace
- Local:
-
Start debugging
- Start the server (it will wait for debugger)
- Run the "Python Debug Server" configuration in PyCharm
- Server will continue execution
Logging
The server uses Python's logging module. Increase verbosity:
# In server.py, change:
logging.basicConfig(level=logging.DEBUG)
Or via environment:
export LOG_LEVEL=DEBUG
python server.py
Code Quality
Format Code
# Black
black .
# Ruff (lint + fix)
ruff check --fix .
Type Checking
mypy server.py
Pre-commit Hooks
# Install hooks
pre-commit install
# Run manually
pre-commit run --all-files
Project Structure
geoguessr-mcp/
├── .devcontainer/ # Dev container configuration
│ ├── devcontainer.json
│ ├── docker-compose.dev.yml
│ └── Dockerfile.dev
├── .idea/ # PyCharm settings
│ └── runConfigurations/
├── tests/ # Test files
│ ├── __init__.py
│ └── test_server.py
├── server.py # Main MCP server
├── requirements.txt # Production dependencies
├── requirements-dev.txt # Development dependencies
├── pyproject.toml # Project configuration
├── Dockerfile # Production Dockerfile
├── docker-compose.yml # Production compose
└── README.md
Tips
-
Hot Reload: Use
watchfilesfor auto-restart during development:pip install watchfiles watchfiles "python server.py" . -
Test MCP Connection: Use the test script:
python test_server.py http://localhost:8000/mcp -
Environment Variables: Always use
.envfile locally, never commit secrets -
Cookie Expiration: GeoGuessr cookies expire - if tests start failing, get a fresh cookie