Skip to content

fix: fall back to SGAI_API_KEY env var in get_api_key - #29

Open
peterbircak wants to merge 1 commit into
ScrapeGraphAI:mainfrom
peterbircak:peterbircak-vennre/tw9l7
Open

peterbircak wants to merge 1 commit into
ScrapeGraphAI:mainfrom
peterbircak:peterbircak-vennre/tw9l7

Conversation

@peterbircak

Copy link
Copy Markdown

Problem

get_api_key() only looked for the X-API-Key HTTP header and the Smithery scrapegraphApiKey session config. The README, the ConfigSchema field description, and the .agent docs all say a local stdio server can read its key from SGAI_API_KEY, but it never did. If you run the server locally without Smithery (Claude Desktop/Cursor/Claude Code command configs from the README), every tool call fails with:

ScapeGraph API key is required. Please provide it via: ...

Fix

get_api_key() now checks SGAI_API_KEY as a last resort, after the header and the session config. The header and Smithery config still take priority, so remote and Smithery deployments work exactly as before. The error message now lists the env var as an option.

Also adds .agent/sop/local_mcp_setup.md, which covers setting up the server with uv and a project .mcp.json for Claude Code, and links it from .agent/README.md.

Testing

  • Ran the server over stdio with SGAI_API_KEY set and called credits over JSON-RPC. Before the fix it returned the "API key is required" error; after the fix it returned the account balance.
  • Registered it in Claude Code through .mcp.json; credits and scrape (markdown on example.com) both succeeded.
  • ruff check src/ passes.

🤖 Generated with Claude Code

Local stdio runs (e.g. Claude Code via .mcp.json) had no way to pass the
key: get_api_key only checked the X-API-Key header and Smithery session
config, despite README/ConfigSchema documenting SGAI_API_KEY. Every tool
call failed with "API key is required".

Also adds a local-setup SOP under .agent/sop.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant