MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / get_default_environment

Function get_default_environment

src/mcp/client/stdio.py:75–90  ·  view source on GitHub ↗

Returns only the environment variables that are safe to inherit.

()

Source from the content-addressed store, hash-verified

73
74
75def get_default_environment() -> dict[str, str]:
76 """Returns only the environment variables that are safe to inherit."""
77 env: dict[str, str] = {}
78
79 for key in DEFAULT_INHERITED_ENV_VARS:
80 value = os.environ.get(key)
81 if value is None: # pragma: lax no cover
82 continue
83
84 if value.startswith("()"): # pragma: no cover
85 # Skip functions, which are a security risk
86 continue # pragma: no cover
87
88 env[key] = value
89
90 return env
91
92
93class StdioServerParameters(BaseModel):

Callers 1

stdio_clientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected