feat(keys): pass local keys to the session by default

This commit is contained in:
2025-03-11 11:39:21 -06:00
parent e36f4540bf
commit f83c49c0f3
2 changed files with 11 additions and 2 deletions

View File

@@ -47,6 +47,11 @@ mc session create -e VAR1=value1 -e VAR2=value2
# Shorthand for creating a session with a project repository
mc github.com/username/repo
# Local development with API keys
# OPENAI_API_KEY, ANTHROPIC_API_KEY, and OPENROUTER_API_KEY from your
# local environment are automatically passed to the container
mc session create
```
## Driver Management

View File

@@ -123,6 +123,12 @@ class ContainerManager:
if project:
env_vars["MC_PROJECT_URL"] = project
# Pass API keys from host environment to container for local development
api_keys = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"]
for key in api_keys:
if key in os.environ and key not in env_vars:
env_vars[key] = os.environ[key]
# Pull image if needed
try:
self.client.images.get(driver.image)
@@ -136,8 +142,6 @@ class ContainerManager:
# If no project URL and mount_local is True, mount local directory to /app
if not project and mount_local:
# Mount current directory to /app in the container
import os
current_dir = os.getcwd()
volumes[current_dir] = {"bind": "/app", "mode": "rw"}
print(f"Mounting local directory {current_dir} to /app")