Add authentication and update MCP server setup #4

Merged
NyxiumYuuki merged 1 commit from claude/add-mcp-authentication-01V5tbppGEtXc3tvjRGoTcfh into master 2025-11-29 23:24:50 +01:00
NyxiumYuuki commented 2025-11-29 23:16:52 +01:00 (Migrated from github.com)

This commit implements several key improvements to the GeoGuessr MCP server:

MCP Server Authentication

  • Add Bearer token authentication for MCP server access control
  • New middleware in src/geoguessr_mcp/middleware/auth.py
  • Configuration via MCP_AUTH_ENABLED and MCP_API_KEYS environment variables
  • Support for multiple API keys (comma-separated)
  • Optional authentication - can be disabled for trusted deployments
  • Clients connect using Authorization: Bearer YOUR_API_KEY header

Docker Configuration Updates

  • Update to use official pre-built image: nyxiumyuuki/geoguessr-mcp:latest
  • Remove DOCKER_USERNAME and IMAGE_TAG from environment variables
  • Simplify docker-compose.yml and docker-compose.prod.yml
  • Remove healthcheck configuration (not necessary for the deployment)

Deployment Improvements

  • Move deploy.sh to scripts/deploy.sh for better organization
  • Update deploy.sh to use official Docker image
  • Add authentication validation in deployment script
  • Improve deployment logging and error messages

Documentation Updates

  • Update README.md with authentication configuration examples
  • Add MCP server authentication section with setup instructions
  • Update environment variables table
  • Simplify deployment instructions
  • Update CLAUDE.md with new authentication architecture
  • Add .env.example configuration for MCP authentication

Technical Details

  • Authentication middleware integrates with FastMCP's Starlette ASGI app
  • Middleware validates Bearer tokens on all requests except /health
  • Logs authentication attempts and failures
  • Returns proper 401/403 HTTP status codes
  • Validates configuration on startup to prevent misconfiguration

Resolves TODO items:

  • Fix Docker username in compose files and env vars
  • Add authentication to MCP server to allow access only to specific users

Pull Request

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test improvement

Fixes #

Changes Made

Testing Performed

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Test Details

# Example test commands
pytest tests/

Screenshots (if applicable)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked my code and corrected any misspellings

Additional Context

Breaking Changes

Performance Impact


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.

This commit implements several key improvements to the GeoGuessr MCP server: ## MCP Server Authentication - Add Bearer token authentication for MCP server access control - New middleware in src/geoguessr_mcp/middleware/auth.py - Configuration via MCP_AUTH_ENABLED and MCP_API_KEYS environment variables - Support for multiple API keys (comma-separated) - Optional authentication - can be disabled for trusted deployments - Clients connect using Authorization: Bearer YOUR_API_KEY header ## Docker Configuration Updates - Update to use official pre-built image: nyxiumyuuki/geoguessr-mcp:latest - Remove DOCKER_USERNAME and IMAGE_TAG from environment variables - Simplify docker-compose.yml and docker-compose.prod.yml - Remove healthcheck configuration (not necessary for the deployment) ## Deployment Improvements - Move deploy.sh to scripts/deploy.sh for better organization - Update deploy.sh to use official Docker image - Add authentication validation in deployment script - Improve deployment logging and error messages ## Documentation Updates - Update README.md with authentication configuration examples - Add MCP server authentication section with setup instructions - Update environment variables table - Simplify deployment instructions - Update CLAUDE.md with new authentication architecture - Add .env.example configuration for MCP authentication ## Technical Details - Authentication middleware integrates with FastMCP's Starlette ASGI app - Middleware validates Bearer tokens on all requests except /health - Logs authentication attempts and failures - Returns proper 401/403 HTTP status codes - Validates configuration on startup to prevent misconfiguration Resolves TODO items: - [x] Fix Docker username in compose files and env vars - [x] Add authentication to MCP server to allow access only to specific users # Pull Request ## Description <!-- Provide a clear and concise description of your changes --> ## Type of Change <!-- Mark the relevant option with an 'x' --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test improvement ## Related Issues <!-- Link related issues using keywords: Fixes #123, Closes #456, Related to #789 --> Fixes # ## Changes Made <!-- List the main changes in bullet points --> - - - ## Testing Performed <!-- Describe the testing you've done --> - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [ ] All existing tests pass ### Test Details <!-- Provide details about how you tested your changes --> ```bash # Example test commands pytest tests/ ``` ## Screenshots (if applicable) <!-- Add screenshots to help explain your changes --> ## Checklist <!-- Ensure all items are completed before submitting --> - [ ] My code follows the project's style guidelines - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published - [ ] I have checked my code and corrected any misspellings ## Additional Context <!-- Add any other context about the pull request here --> ## Breaking Changes <!-- If this is a breaking change, describe the impact and migration path --> ## Performance Impact <!-- Describe any performance implications of your changes --> --- **By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.**
Sign in to join this conversation.
No description provided.