GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use default environment even when `env` is provided by maxguru · Pull Request #327 · modelcontextprotocol/python-sdk

Conversation

@maxguru

@maxguru maxguru commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

Fixed issue #326 - MCP client with npx not working when env parameter of StdioServerParameters is set

Motivation and Context

See issue #326
Discarding the output of get_default_environment() when server.env has additional variables doesn't make sense. A reasonable assumption is that setting env variables adds to what was there otherwise.

How Has This Been Tested?

I tested it and it fixed the issue for me.

Breaking Changes

If somebody relied on setting the env parameter to clear default environment variables then they would need to change their code.

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

None

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@maxguru maxguru mentioned this pull request Mar 20, 2025
MCP client with npx not working when env parameter of StdioServerParameters is set #326
Closed
@dsp-ant

dsp-ant commented Mar 20, 2025

Copy link
Copy Markdown
Member

Can you please fix the formatting issue? You should be able to run uv run ruff format

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maxguru maxguru closed this Mar 20, 2025
@maxguru
maxguru force-pushed the maxguru-patch-issue-326 branch from b226a0d to e2a7338 Compare March 20, 2025 18:42
@maxguru
Fixed issue modelcontextprotocol#326 - MCP client with npx not workin…
422267e
…g when env parameter of StdioServerParameters is set
@maxguru maxguru reopened this Mar 20, 2025
@Kludex Kludex changed the title Fixed issue #326 Use default environment even when env is provided Mar 21, 2025
Kludex
Kludex approved these changes Mar 21, 2025
View reviewed changes
@Kludex
Kludex merged commit 9ae4df8 into modelcontextprotocol:main Mar 21, 2025
This was referenced Mar 21, 2025
Cannot start client with npx #240
Closed
PATH lost and npx not found when proxying MCP servers because get_default_environment() is not used when user provides env in StdioServerParameters #185
Closed
MCPServerStdio bug when passing env vars as param pydantic/pydantic-ai#1200
Closed
@sunrabbit123 sunrabbit123 mentioned this pull request Jun 27, 2025
fix(client): Some mcp server need default env(#393, #196) modelcontextprotocol/typescript-sdk#394
Merged
6 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Kludex Kludex Kludex approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@maxguru @dsp-ant @Kludex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.