Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions opc/scripts/setup/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,21 @@ async def prompt_api_keys() -> dict[str, str]:
"""Prompt user for optional API keys.

Returns:
dict with keys: perplexity, nia, braintrust
dict with keys: perplexity, nia, braintrust, firecrawl
"""
console.print("\n[bold]API Keys (optional)[/bold]")
console.print("Press Enter to skip any key you don't have.\n")

perplexity = Prompt.ask("Perplexity API key (web search)", default="")
nia = Prompt.ask("Nia API key (documentation search)", default="")
braintrust = Prompt.ask("Braintrust API key (observability)", default="")
firecrawl = Prompt.ask("Firecrawl API key (web scraping)", default="")

return {
"perplexity": perplexity,
"nia": nia,
"braintrust": braintrust,
"firecrawl": firecrawl,
}


Expand Down Expand Up @@ -500,6 +502,8 @@ def generate_env_file(config: dict[str, Any], env_path: Path) -> None:
lines.append(f"NIA_API_KEY={api_keys['nia']}")
if api_keys.get("braintrust"):
lines.append(f"BRAINTRUST_API_KEY={api_keys['braintrust']}")
if api_keys.get("firecrawl"):
lines.append(f"FIRECRAWL_API_KEY={api_keys['firecrawl']}")
lines.append("")

# Write file
Comment on lines 502 to 509

This comment was marked as outdated.

Comment on lines 502 to 509
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The setup wizard writes FIRECRAWL_API_KEY to the project .env file, but firecrawl_scrape.py only reads from ~/.claude/.env when run standalone, causing authentication failure.
Severity: MEDIUM

Suggested Fix

Modify the load_api_key function in opc/scripts/mcp/firecrawl_scrape.py to also check for the API key in the project root's .env file (Path.cwd() / ".env"). This would align its behavior with other scripts like nia_docs.py and ensure the key is found regardless of how the script is invoked.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: opc/scripts/setup/wizard.py#L502-L509

Potential issue: The setup wizard in `wizard.py` writes the `FIRECRAWL_API_KEY` to the
project root's `.env` file. However, the `firecrawl_scrape.py` script's `load_api_key`
function only checks for the key in environment variables or the `~/.claude/.env` file.
This creates a discrepancy. If a user follows the setup wizard and then attempts to run
`firecrawl_scrape.py` as a standalone tool, as documented in its docstring, the script
will not find the API key, resulting in an authentication failure. While the script
works when invoked via the MCP server, the documented standalone usage is broken.

Expand Down Expand Up @@ -616,7 +620,7 @@ async def run_setup_wizard() -> None:
if Confirm.ask("Configure API keys?", default=False):
api_keys = await prompt_api_keys()
else:
api_keys = {"perplexity": "", "nia": "", "braintrust": ""}
api_keys = {"perplexity": "", "nia": "", "braintrust": "", "firecrawl": ""}

# Step 5: Generate .env
console.print("\n[bold]Step 5/13: Generating configuration...[/bold]")
Expand Down