python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

fix: implemented exception handling for client indefinite blocks

Open kavinkumar807 opened this issue 8 months ago • 10 comments

This PR fixes #447 #642

Mismatch URL

Screenshot 2025-04-13 at 9 04 39 PM

Connection Error

Screenshot 2025-04-13 at 10 14 42 PM

Motivation and Context

This PR solves the indefinite blocking issue of the client by handling the exception thrown by url mismatch and also all the exceptions happens during connection:

  • by propagating the error once value error is raised instead of sending it via stream
  • by adding exception groups to handle value error as well as connection error etc with exception groups
  • by adding errors list to add the exception groups and convert it to normal exception and throw to client
  • It also fixes the yield placement issue

How Has This Been Tested?

  • Tested with local python servers and typescript servers.
  • Tested by building the package and installing it in local usinguv pip install /dist/mcp-1.6.1.dev12+70115b9-py3-none-any.whl in the local servers.
  • Tested URL mismatch scenarios, connection errors.
  • Tested success scenarios too.

Breaking Changes

There are no breaking changes.

Types of changes

  • [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 change)
  • [ ] Documentation update

Checklist

  • [x] I have read the MCP Documentation
  • [x] My code follows the repository's style guidelines
  • [x] New and existing tests pass locally
  • [x] I have added appropriate error handling
  • [ ] I have added or updated documentation as needed

kavinkumar807 avatar Apr 13 '25 16:04 kavinkumar807

Screenshot 2025-04-13 at 10 26 41 PM

Seems like except* is not compatible with python 3.10 version will check with it and change it

kavinkumar807 avatar Apr 13 '25 17:04 kavinkumar807

@jerome3o-anthropic @jspahrsummers @dsp-ant Adding here for PR review

kavinkumar807 avatar Apr 14 '25 06:04 kavinkumar807

@Kludex Synced the PR. It’s up to date with main

kavinkumar807 avatar Apr 16 '25 04:04 kavinkumar807

@Kludex @jerome3o-anthropic Synced the PR. It's up to date with main

kavinkumar807 avatar Apr 23 '25 05:04 kavinkumar807

@Kludex Synced the PR.

kavinkumar807 avatar Apr 26 '25 18:04 kavinkumar807

@dsp-ant @jerome3o-anthropic @Kludex Synced the PR with main

kavinkumar807 avatar Apr 30 '25 04:04 kavinkumar807

@dsp-ant @jerome3o-anthropic @Kludex @ihrpr Synced the PR with main. Guys I've been following this PR and syncing for past 3 weeks I'm not getting any feedback and suggestions on this. I'd be happy to know the status of this PR

kavinkumar807 avatar May 02 '25 15:05 kavinkumar807

@dsp-ant @jerome3o-anthropic @Kludex @ihrpr Synced the PR with main.

kavinkumar807 avatar May 02 '25 18:05 kavinkumar807

@dsp-ant @jerome3o-anthropic @Kludex @ihrpr Synced the PR with main.

kavinkumar807 avatar May 07 '25 04:05 kavinkumar807

I'm not sure why test cases are failing. @ihrpr

kavinkumar807 avatar May 07 '25 04:05 kavinkumar807

Closing this PR, looks stale now. Please re-open if the changes are still needed and suggestions applied.

ihrpr avatar Jul 09 '25 15:07 ihrpr