Add dotenv loader for CLI + MCP entry points - #20
Merged
Conversation
Introduces `yieldagent.env.load_dotenv`, a small `.env` reader so the campaign-setup CLI and the Meta MCP server pick up local secrets without `set -a; source .env`. No behavior change beyond env loading at startup. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 tasks
There was a problem hiding this comment.
Pull request overview
This PR adds a lightweight .env loader to the YieldAgent codebase and wires it into key local entry points so developers can run the campaign-setup CLI and Meta MCP server without manually sourcing environment variables.
Changes:
- Add
yieldagent.env.load_dotenvto locate and load.envfiles intoos.environwithout introducing a dependency. - Invoke
load_dotenv()in the campaign-setup CLImain()and the Meta MCP servermain(). - Minor import ordering cleanup in the Meta MCP server module.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/yieldagent/env.py |
Introduces the .env discovery and parsing utility used by local entry points. |
src/yieldagent/agents/campaign_setup/cli.py |
Loads .env automatically before parsing CLI args / running the agent. |
src/yieldagent/integrations/meta/server.py |
Loads .env automatically before starting the MCP stdio server. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+38
to
+42
| dotenv_path = path or _find_dotenv() | ||
| if dotenv_path is None: | ||
| return None | ||
|
|
||
| for line in dotenv_path.read_text().splitlines(): |
Comment on lines
+31
to
+35
| def load_dotenv(path: Path | None = None, *, override: bool = False) -> Path | None: | ||
| """Load KEY=VALUE pairs from `.env` into `os.environ`. | ||
|
|
||
| This intentionally handles the simple format used by this repo without | ||
| adding a runtime dependency. Existing shell variables win unless |
th0rz05
added a commit
that referenced
this pull request
Jun 9, 2026
Introduces `yieldagent.env.load_dotenv`, a small `.env` reader so the campaign-setup CLI and the Meta MCP server pick up local secrets without `set -a; source .env`. No behavior change beyond env loading at startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
yieldagent.env.load_dotenv, a small.envreader.main()so local secrets load withoutset -a; source .env.First of 3 small PRs splitting up the LinkedIn slice work. This one is the foundational env-loader infra that later PRs build on.
Test plan
PYTHONPATH=src pytest -q(13 passed)ruff checkon changed files