Repository navigation
fix: fall back to SGAI_API_KEY env var in get_api_key - #29
Open
peterbircak wants to merge 1 commit into
Open
peterbircak wants to merge 1 commit into
peterbircak wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_api_key()only looked for theX-API-KeyHTTP header and the SmitheryscrapegraphApiKeysession config. The README, theConfigSchemafield description, and the.agentdocs all say a local stdio server can read its key fromSGAI_API_KEY, but it never did. If you run the server locally without Smithery (Claude Desktop/Cursor/Claude Codecommandconfigs from the README), every tool call fails with:Fix
get_api_key()now checksSGAI_API_KEYas 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.jsonfor Claude Code, and links it from.agent/README.md.Testing
SGAI_API_KEYset and calledcreditsover JSON-RPC. Before the fix it returned the "API key is required" error; after the fix it returned the account balance..mcp.json;creditsandscrape(markdown on example.com) both succeeded.ruff check src/passes.🤖 Generated with Claude Code