-
Notifications
You must be signed in to change notification settings - Fork 132
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
MCP Client Environment Variables in StdioServerParameters #99
Comments
You need to make sure to include the necessary default env vars for it to find the uv program. When you set env to python-sdk/src/mcp/client/stdio.py Lines 13 to 51 in aaf32b5
As a fast workaround, if you copy over the above code for the get_default_environment and use that as the base env dict, then update with your new env vars and pass that through to the mcp then you should see it working, something like this:
|
I believe it would be much better to apply the above code into the sdk. https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/client/stdio.py#L100-L103 |
Describe the bug
Passing environment variables to the MCP Server - I am trying to test the example Weather MCP Server with both the MCP Inspector and a simple Python MCP Client, and when I try to pass the Open Weather API key using the 'env' field - I cannot it to work.
To Reproduce
Steps to reproduce the behavior:
[Errno 2] No such file or directory: 'uv'
Here is the code snippet from the Python Client:
If I do not pass any environment by either commenting the
env
field or remove it all together, then the Client is able to connect with the Server.Are there any examples on using
StdioServerParameters
in Python Clients? I could not find any examples (other thanenv=None
) in example MCP Client code.The text was updated successfully, but these errors were encountered: