Skip to content

feat: use contextvar to pass process for easier access #513

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

Conversation

adamwen829
Copy link

Motivation and Context

Sometimes, client developers need to check the status of the current process. This change makes it easier by allowing the process object to be accessed directly from anywhere in the code.

How Has This Been Tested?

I have tested under stdio_client contextmanager to get process and process's return code

Breaking Changes

This change introduces no breaking changes.

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

Copy link

@mcp-shadow mcp-shadow bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution to MCP Python SDK.

We are closing this PR because:

  1. It introduces a global state dependency without strong justification for why this is preferable to explicit dependency injection.
  2. The maintenance cost outweighs the minor convenience benefit - we would need to document this "magic" global state and ensure it's properly used.
  3. It creates a hidden coupling in the codebase where components can implicitly depend on being run within a specific context.

@mcp-shadow mcp-shadow bot closed this May 13, 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.

1 participant