Fix middleware schema caching error #7

Merged
NyxiumYuuki merged 13 commits from claude/fix-middleware-schema-cache-01SXnBSQQ8ptLgqViF4UsUYx into master 2025-12-01 03:03:24 +01:00
NyxiumYuuki commented 2025-11-30 01:11:37 +01:00 (Migrated from github.com)

This commit addresses two critical issues in the MCP server:

  1. CORS Middleware Fix:

    • Move CORS middleware outside the auth check so it's always enabled
    • CORS is required for browser-based MCP clients, regardless of auth
    • Fixes "OPTIONS /mcp HTTP/1.1 405 Method Not Allowed" error
  2. Schema Cache Improvements:

    • Add specific handling for corrupted JSON cache files
    • Automatically remove corrupted cache files and log the action
    • Prevents startup failures due to malformed JSON
    • Better error messages to help diagnose cache issues
  3. Configuration Updates:

    • Change default SCHEMA_CACHE_DIR from /app/data/schemas to ./data/schemas
    • Better default for local development (Docker still uses /app/data/schemas)
    • Update .env.example with clearer documentation

These fixes improve robustness and make local development easier.

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 addresses two critical issues in the MCP server: 1. CORS Middleware Fix: - Move CORS middleware outside the auth check so it's always enabled - CORS is required for browser-based MCP clients, regardless of auth - Fixes "OPTIONS /mcp HTTP/1.1 405 Method Not Allowed" error 2. Schema Cache Improvements: - Add specific handling for corrupted JSON cache files - Automatically remove corrupted cache files and log the action - Prevents startup failures due to malformed JSON - Better error messages to help diagnose cache issues 3. Configuration Updates: - Change default SCHEMA_CACHE_DIR from /app/data/schemas to ./data/schemas - Better default for local development (Docker still uses /app/data/schemas) - Update .env.example with clearer documentation These fixes improve robustness and make local development easier. # 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.