Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jlowin
Copy link
Owner

@jlowin jlowin commented Dec 5, 2024

FastMCP's code will be merged into the main MCP codebase, which is MIT licensed. To facilitate that, I am relicensing the codebase as MIT.

This will be part of a new 0.4 release for clarity.

In preparation for contribution to the MCP SDk
@github-actions github-actions bot added the documentation Updates to docs, examples, or guides. Primary change is documentation-related. label Dec 5, 2024
@jlowin jlowin merged commit 2212d39 into main Dec 5, 2024
2 checks passed
@jlowin jlowin deleted the jlowin-patch-1 branch December 5, 2024 00:48
@sd2k
Copy link
Contributor

sd2k commented Dec 23, 2024

Test Failure Analysis

Summary: Test test_callback_error_returns_html_page times out on Windows due to SQLite locking when creating OAuthProxy without isolated storage.

Root Cause: The test creates an OAuthProxy instance without providing a client_storage parameter (line 1387 in tests/server/auth/test_oauth_proxy.py). When client_storage is None, OAuthProxy defaults to creating a DiskStore at settings.home / "oauth-proxy". On Windows, when tests run in parallel, multiple tests trying to access the same SQLite database causes locking/timeout issues during the SQLite connection initialization.

The stack trace shows the timeout occurs at:

File "diskcache/core.py", line 623, in _con
    con = self._local.con = sqlite3.connect(

Suggested Solution: Provide an isolated in-memory storage for this test to avoid SQLite file contention:

  1. Modify test_callback_error_returns_html_page to use an in-memory key-value store
  2. Add client_storage parameter to the OAuthProxy initialization

Example fix:

from key_value.aio.stores.memory import MemoryStore

async def test_callback_error_returns_html_page(self):
    """Test that OAuth callback errors return styled HTML instead of data: URLs."""
    from unittest.mock import Mock

    from starlette.requests import Request
    from starlette.responses import HTMLResponse

    from fastmcp.server.auth.oauth_proxy import OAuthProxy
    from fastmcp.server.auth.providers.jwt import JWTVerifier

    # Create a minimal OAuth proxy with isolated storage
    provider = OAuthProxy(
        upstream_authorization_endpoint="https://idp.example.com/authorize",
        upstream_token_endpoint="https://idp.example.com/token",
        upstream_client_id="test-client",
        upstream_client_secret="test-secret",
        token_verifier=JWTVerifier(
            jwks_uri="https://idp.example.com/.well-known/jwks.json",
            issuer="https://idp.example.com",
            audience="test-client",
        ),
        base_url="http://localhost:8000",
        jwt_signing_key="test-signing-key",
        client_storage=MemoryStore(),  # Add this line
    )
    # ... rest of test
Detailed Analysis

The test was added/modified in this PR and exposed a Windows-specific issue that wasn't caught because:

  1. Linux/macOS handle SQLite file locking differently than Windows
  2. The test runs without --numprocesses on Windows (see workflow), so it's not parallelized but still conflicts with other tests from previous runs or shared state

Other tests in the file use the oauth_proxy fixture which also doesn't provide isolated storage, but this particular test might be more susceptible due to timing or ordering.

Related Files
  • tests/server/auth/test_oauth_proxy.py:1376 - Failing test that needs isolated storage
  • src/fastmcp/server/auth/oauth_proxy.py:821 - Where DiskStore is created by default
  • tests/server/auth/test_oauth_proxy.py:312 - oauth_proxy fixture that could also benefit from isolated storage

@jlowin
Copy link
Owner Author

jlowin commented Dec 23, 2024

@sd2k modelcontextprotocol/python-sdk#106

@github-actions github-actions bot added the feature Major new functionality. Reserved for 2-4 significant PRs per release. Not for issues. label Dec 23, 2024
jordicore pushed a commit to jordicore/fastmcp that referenced this pull request Jul 2, 2025
Relicense from Apache 2.0 to MIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Updates to docs, examples, or guides. Primary change is documentation-related. feature Major new functionality. Reserved for 2-4 significant PRs per release. Not for issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants