8000 Fix auth session handling by McPuser044 · Pull Request #135 · punkpeye/fastmcp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix auth session handling #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

McPuser044
Copy link
Contributor

his pull request addresses a critical issue where the server would fail to establish a connection for new, unauthenticated users. Previously, an initial authentication failure would throw an unhandled error, preventing the FastMCPSession from being created and causing the connection to be rejected prematurely.

This fix makes the session creation process more robust and non-blocking, ensuring that a session is always established, which aligns with the expected behavior for servers that need to manage sessions dynamically.

Changes
Modified src/FastMCP.ts:

Wrapped the await this.#authenticate(request) call within the createServer function in a try...catch block.
This change gracefully handles initial authentication errors, allowing the session to be created successfully even if the user is not yet authenticated.
Adapted src/FastMCP.test.ts:

Updated the test case previously named blocks unauthorized requests.
The test now correctly asserts that a connection succeeds (the promise resolves) when an initial authentication error occurs, reflecting the new, correct behavior of the application. The test was renamed to allows connection even if initial auth fails to better describe its purpose.

@punkpeye punkpeye merged commit 1638c00 into punkpeye:main Jun 26, 2025
1 check passed
@punkpeye
Copy link
Owner

Thank you

punkpeye added a commit that referenced this pull request Jun 26, 2025
punkpeye added a commit that referenced this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0