Skip to content

Add dotenv loader for CLI + MCP entry points - #20

Merged
th0rz05 merged 1 commit into
mainfrom
pr1-dotenv-loader
Jun 2, 2026
Merged

Add dotenv loader for CLI + MCP entry points#20
th0rz05 merged 1 commit into
mainfrom
pr1-dotenv-loader

Conversation

@th0rz05

@th0rz05 th0rz05 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add yieldagent.env.load_dotenv, a small .env reader.
  • Call it from the campaign-setup CLI and the Meta MCP server main() so local secrets load without set -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 check on changed files

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>
Copilot AI review requested due to automatic review settings June 2, 2026 14:26
@th0rz05
th0rz05 merged commit 86e58cd into main Jun 2, 2026
@th0rz05
th0rz05 deleted the pr1-dotenv-loader branch June 2, 2026 14:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dotenv to locate and load .env files into os.environ without introducing a dependency.
  • Invoke load_dotenv() in the campaign-setup CLI main() and the Meta MCP server main().
  • 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 thread src/yieldagent/env.py
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 thread src/yieldagent/env.py
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants