Skip to content

Improve .env discovery#737

Merged
EricGustin merged 12 commits intomainfrom
ericgustin/improve-env-discovery
Feb 26, 2026
Merged

Improve .env discovery#737
EricGustin merged 12 commits intomainfrom
ericgustin/improve-env-discovery

Conversation

@EricGustin
Copy link
Member

@EricGustin EricGustin commented Jan 2, 2026

Resolves TOO-201

Documentation PR for this is here: ArcadeAI/docs#626


Note

Medium Risk
Changes how environment variables/secrets are discovered and loaded, which can subtly alter runtime behavior depending on directory structure and existing env vars; bounded traversal and added tests reduce but don’t eliminate this risk.

Overview
Improves .env discovery across the MCP server and CLI. Adds find_env_file() (bounded by the nearest pyproject.toml by default) and switches settings loading, arcade deploy, arcade configure stdio env injection, and provider API-key resolution to use it.

Updates dev reload to also watch the discovered .env even when it lives outside the current working directory, adjusts deploy --secrets all to only run when a .env was found, and moves the minimal scaffold’s .env.example to the project root with updated tests/integration checks. Version bumps align examples and top-level deps with arcade-mcp-server 1.17.4 and arcade-mcp 1.11.2.

Written by Cursor Bugbot for commit 40cff17. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

❌ Patch coverage is 84.09091% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/arcade-cli/arcade_cli/deploy.py 16.66% 5 Missing ⚠️
...ibs/arcade-mcp-server/arcade_mcp_server/mcp_app.py 71.42% 2 Missing ⚠️
Files with missing lines Coverage Δ
libs/arcade-cli/arcade_cli/configure.py 70.31% <100.00%> (+0.50%) ⬆️
libs/arcade-cli/arcade_cli/utils.py 55.84% <100.00%> (+0.08%) ⬆️
...bs/arcade-mcp-server/arcade_mcp_server/settings.py 89.34% <100.00%> (+2.47%) ⬆️
...ibs/arcade-mcp-server/arcade_mcp_server/mcp_app.py 90.98% <71.42%> (-0.31%) ⬇️
libs/arcade-cli/arcade_cli/deploy.py 44.70% <16.66%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EricGustin EricGustin changed the title Improve .env discovery Improve .env discovery Jan 2, 2026
@EricGustin EricGustin requested a review from a team January 13, 2026 20:34
EricGustin and others added 5 commits January 14, 2026 17:54
The test and integration smoke test expect .env.example at
src/{{ toolkit_name }}/.env.example, not at the package root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The PR's goal is to make find_env_file() discover .env at higher
directory levels. Move the scaffold template's .env.example to the
package root (next to pyproject.toml) and update tests accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses review concern about unbounded upward traversal finding
unrelated .env files (e.g. ~/.env or C:\.env) and loading their
secrets into memory or uploading them to Arcade Engine.

find_env_file() now defaults to stopping at the nearest ancestor
directory containing pyproject.toml. If no pyproject.toml is found,
falls back to traversing to the filesystem root. An explicit stop_at
parameter still overrides this behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EricGustin
Copy link
Member Author

EricGustin commented Feb 25, 2026

@nbarbettini I've addressed your comment.

find_env_file() now stops at the nearest ancestor directory containing pyproject.toml by default (the project root boundary). If no pyproject.toml is found anywhere in the tree, it falls back to traversing to the filesystem root. An explicit stop_at parameter still overrides both behaviors.

This prevents accidentally loading an unrelated ~/.env or C:\Users\...\.env and its secrets from being loaded into memory, uploaded to Arcade Engine during deploy, or written into MCP client configs.

arcade-mcp-server: 1.17.3 -> 1.17.4 (added _find_project_root, bounded find_env_file)
arcade-mcp: 1.11.1 -> 1.11.2
Update minimum arcade-mcp-server dep across examples and root pyproject.toml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable autofix in the Cursor dashboard.

@EricGustin EricGustin merged commit 4a737b9 into main Feb 26, 2026
43 checks passed
@EricGustin EricGustin deleted the ericgustin/improve-env-discovery branch February 26, 2026 07:20
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