Returns only the environment variables that are safe to inherit.
()
| 73 | |
| 74 | |
| 75 | def 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 | |
| 93 | class StdioServerParameters(BaseModel): |