Skip to content

Move uvicorn import to usage #502

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 1 commit into from
Apr 15, 2025

Conversation

danlapid
Copy link
Contributor

@danlapid danlapid commented Apr 13, 2025

Motivation and Context

uvicorn is an optional dependency only used in one function but is imported at the global scope meaning mcp imports will fail if uvicorn is not available. This commit moves uvicorn import to usage in run_sse_async. It would be ideal to mark uvicorn as a default-on optional dependency but that isn't supported yet by pyproject.toml.

Pyodide and Emscripten don't support uvicorn but still work really well with the mcp package with this tiny change.

How Has This Been Tested?

It was tested locally.

Breaking Changes

Shouldn't be a breaking change.

Types of changes

  • 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

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

Additional context

@danlapid
Copy link
Contributor Author

Can I have a review on this please?

@hoodmane
Copy link

Also change to this line:
https://github.com/modelcontextprotocol/python-sdk/blob/main/pyproject.toml#L32
to:

    "uvicorn>=0.23.1; sys_platform != 'emscripten'",

@danlapid danlapid force-pushed the danlapid/move_uvicorn branch from 7f5f8b5 to 78c217a Compare April 15, 2025 13:29
uvicorn is an optional dependency only used in one function but is imported at the global scope meaning mcp imports will fail if uvicorn is not available.
This commit moves uvicorn import to usage in run_sse_async.
It would be ideal to mark uvicorn as a default-on optional dependency but that isn't supported yet by pyproject.toml.
@danlapid danlapid force-pushed the danlapid/move_uvicorn branch from 78c217a to 2240530 Compare April 15, 2025 13:31
@Kludex Kludex merged commit 8c9269c into modelcontextprotocol:main Apr 15, 2025
7 checks passed
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.

3 participants