Context7 LangGraph Test: Claude Code on APIs It Never Saw
I gave Claude Code three tasks on upstash-redis 1.9.0, an SDK release from November 2026. That release is newer than the model's training, and the SDK was not installed where the agent worked. With web access denied and no docs source, it passed 0 of 9 runs. With Context7, it passed 7 of 9. In the baseline, 6 runs declined to write code and 3 wrote an older answer. On an API it already knew (LangGraph 1.2's interrupt), it passed every time either way. In that Context7 LangGraph test, Context7 confirmed the answer for about 6 cents more per run. Setup details are below.
How do you set up Context7 in Claude Code?
Context7's Claude Code page recommends npx ctx7 setup --claude. It asks whether to install the MCP server or a CLI skill. Alternatively, there is a plugin with browser sign-in. With --cli, setup installs a skill that calls the ctx7 CLI and needs no MCP at all. You can also run the MCP server locally (npx -y @upstash/context7-mcp). My A/B tests used it, and the LangGraph pipeline fix below used the ctx7 CLI.
The local MCP server and the ctx7 library / ctx7 docs commands needed no key and no login. ctx7 setup itself asks you to sign in with a one-time device code. Then it creates an API key on your Context7 account. In my 23 November run, a ctx7 docs query took about 1.6 s and returned about 800–900 words. One tip: ctx7 setup writes into the directory set by Claude Code's config-directory environment variable when that is set, not into $HOME/.claude.
Does Context7 help LangGraph code the model already knows?
The task was a LangGraph 1.2.17 graph that pauses for a human with interrupt. It resumes with Command(resume=...) and persists to SqliteSaver. In addition, each run got a fresh venv and headless claude -p, with MCP isolated per arm. I re-ran each script afterwards to check it.
| Without Context7 | With Context7 | |
|---|---|---|
| Passed all 4 criteria (2 runs per arm) | 2 / 2 | 2 / 2 |
| Deprecated or invented APIs | 0 | 0 |
| Mean turns | 4.5 | 6.5 |
| Mean cost | $0.113 | $0.175 (+55%) |
Without any docs tool, the model still wrote interrupt and Command correctly in both runs. Context7 confirmed what the model already knew about LangGraph. So 2 of 2 against 2 of 2 is the baseline for the next test.
Does Context7 help on an SDK newer than the model?
upstash-redis 1.9.0 (PyPI, 2 November 2026) added vector indexes (redis.vector) and array commands (arring, arlastitems, …). I confirmed both are new by diffing the 1.8.0 and 1.9.0 packages. I rejected two other candidates. upstash-redis 1.10.0 changed only its version number in Python. qstash 3.5.0 added no new public API; its flow-control API was already in 3.4.0, released 18 March 2026.
Three tasks:
- Build a 3-dimensional cosine vector index, add three vectors, and return the two nearest.
- Keep the last 5 events per user in a fixed-size ring.
- Report a vector index's count and info, then drop it.
How did I check the upstash-redis answers?
A check script imports the real SDK and records the commands each solution sends (no server, no credentials). Then it compares them with the expected ones. Every check was first shown to fail on a planted wrong answer.
After the runs I changed the checks in four ways and re-ran them on every run in both arms:
- The recorder now uses the SDK's own response parser (it had falsely failed correct code).
exists_okis optional (a try/except also counts).- Any use of
LPUSH,RPUSH,LTRIM,LRANGEorZADDfails the ring task. This also catches a list answer sent as a transaction. - A missing solution file counts as a fail.
There were two conditions and two arms, with 3 runs per task (9 per cell) on claude-opus-5-5. Some runs without the SDK installed also billed a small Haiku call, which is included in the costs. Tasks 1 and 2 named the API family to use ("the SDK's own vector API", "the SDK's array commands"). All three ended with "Use only APIs that exist in that version."
| Without Context7 | With Context7 | |
|---|---|---|
| SDK not installed where the agent works | 0 / 9 | 7 / 9 |
SDK installed in .venv | 9 / 9 | 9 / 9 |
| Mean cost per run, not installed (6 of 9 baseline runs stopped without writing code) | $0.136 | $0.228 |
| Mean cost per run, installed | $0.202 | $0.262 |
What did Claude Code do with and without Context7?
Without Context7 and without the package, the agent tried to look the API up on the web in 8 of 9 runs. Web tools were not permitted in these headless runs, so every attempt was denied. On the two vector tasks it then declined to write code. It could not confirm the API existed, and the prompt asked for only APIs that exist. In 4 of those 6 runs it also said, from memory, that it believed upstash-redis had no vector API. For the ring it wrote the old answer, a list with LPUSH and LTRIM.
With Context7, it looked up the current upstash-redis docs and passed in 7 of 9 runs. Context7 had no docs indexed for 1.9.0 specifically. Instead, it served the current ones, which already include the new API. The agent made two or three docs queries per run. In 5 of those 9 runs it also tried the web after its first Context7 query and was denied, as the baseline was.
Why did two Context7 runs miss?
One miss also used the new vector API but guarded creation with an EXISTS check. However, the check's exact expected sequence does not allow that command. The Upstash docs Context7 served say EXISTS works on a vector index; I did not test it against a server.
The other miss sent the right VECTOR.* commands through raw execute(). That was because it could not confirm redis.vector existed in 1.9.0. That task's prompt did not forbid raw commands, but the check requires the SDK methods.
A note on my setup: in this condition the task text still said the SDK was "in .venv". However, the start of the prompt said it was not installed. Both arms got the same wording, and at least one baseline run pointed out the contradiction while declining. The ring prompt had the same wording, and its baseline still wrote code (the old LPUSH answer). I did not re-run without that wording to confirm it made no difference.
With the package installed, the agent read its source and passed in both arms. The Context7 arm also checked the docs, with two Context7 calls per run, for about 6 cents more. Context7's biggest payoff over a no-web baseline is where the code you need is not on disk yet. That means a version you are about to upgrade to, or a library you have not installed. That's 3 runs per task (9 per cell) on one SDK with one model, so read it as a measurement, not a law.
How did Context7 help fix my own LangGraph pipeline?
I keep a LangGraph pipeline that collects Brașov events from 6 websites, one Send task per site. One network blip would lose a site's events for the day. A plain retry has a catch: if the last attempt raises, the whole run fails, not one site. I checked this on LangGraph 1.2.12 with a two-site graph. The down site was tried 3 times, then the run failed and the healthy site's result was lost.
I asked Context7, through the ctx7 CLI, how RetryPolicy attaches to a LangGraph node. I also asked how a node can know which attempt it is on. The second answer was runtime.execution_info.node_attempt, which I checked against the installed LangGraph 1.2.12 before using. The fix:
def _transient(exc: Exception) -> bool:
if isinstance(exc, httpx.HTTPStatusError):
return exc.response.status_code >= 500
return isinstance(exc, httpx.TransportError)
# inside harvest(payload, runtime): on a fetch error
if _transient(exc) and runtime.execution_info.node_attempt < 3:
raise exc # let RetryPolicy run this site again
# otherwise: record the site as down and return
g.add_node("harvest", harvest, retry_policy=RetryPolicy(
max_attempts=3, initial_interval=2.0, retry_on=_transient))
Finally, three tests cover it. A site that blips once is retried and kept. A site that is down on every attempt is tried 3 times and recorded as down, and the run still finishes. A 404 is tried once.
How can you reproduce the Context7 LangGraph tests?
Everything ran headless, one run per fresh scratch directory outside my repo. So neither arm could see this repo's CLAUDE.md, my notes or the reference answers. The runs loaded only built-in skills and a fresh, per-run memory directory. My user-level CLAUDE.md may still have loaded, the same in both arms.
claude -p "$PROMPT" --setting-sources project \
--strict-mcp-config --mcp-config "$mcp_config" \
--permission-mode acceptEdits \
--allowedTools "Write" "Edit" "Read" "Bash(.venv/bin/python:*)" \
--output-format stream-json --verbose --max-budget-usd 2
The baseline arm's MCP config file is empty. The Context7 arm's has one local server, npx -y @upstash/context7-mcp. Its two tools are added to --allowedTools, and its prompt ends with use context7. --strict-mcp-config loads only that file, so no other MCP server leaks in. Cost and turns come from the run's final result object. Run A-1, the first LangGraph run, used --output-format json. A-1 and B-1 used differently named config files. All other runs used the command above.
The pass checks ran afterwards, outside the agent. For the LangGraph test the script had to run and print a paused line, then DONE approved. I read each generated graph file to confirm it used interrupt, Command(resume=…) and SqliteSaver. For the upstash-redis tests, a small recorder replaces the SDK's HTTP call. So the check sees exactly which Redis commands a solution would send without a server, for example VECTOR.CREATE notes DIM 3 METRIC COSINE. If a solution never wrote its file, that counted as a fail.
Should you use the Context7 MCP server or the CLI skill?
In Claude Code, the idle MCP server added 332 tokens to the first turn (19,083 → 19,415). That's because Claude Code defers MCP tool schemas until they're needed. The CLI lane's always-on rule and skill description come to roughly 800 tokens. However, that figure is estimated from their length rather than measured. Both are cheap, so pick by client: the MCP server where MCP is supported, the CLI skill anywhere with a shell. For Context7 with LangGraph projects, both worked for me.
Who else uses Context7?
I searched GitHub for Context7 config files, then read each file and its commit history in eight organizations' repositories. I kept product-level uses and packaging:
| Organization | What the files show |
|---|---|
| JetBrains | Context7 is the first MCP preset in ThinkRail. IdeaVim's Claude Code settings enable the Context7 plugin. |
| Homebrew | A context7-mcp formula since September 2025, with 2,998 installs in a year. |
| NixOS | A Nixpkgs package since March 2026, which also installs the agent skills. |
| Scale AI | One of 20 default, no-key servers in its MCP Atlas benchmark. |
| Redis | For example, RedisInsight's MCP config runs it, and Redis's official agent skills tell agents to query Context7. |
| Apache | casbin-gateway lists Context7 as a connector. |
| Activepieces | Its engineers' Claude Code settings run it. |
| thoughtbot | Its react-development plugin bundles it. |
Docker also lists it in its MCP registry. The MCP server package was downloaded about 1.2 million times from npm in the week to 22 November 2026. In other words, those are downloads, not unique users.
FAQ
- Is it free? These tests needed no key and hit no rate-limit error. Context7's README recommends a free API key for higher rate limits. The Free plan on Context7's plans page includes 1,000 API calls a month.
- Does it slow the agent down? Only slightly. With the SDK installed, where both arms wrote code, Context7 runs took about 5.5 s and 2.6 turns more on average. Without the SDK the gap was about 12 s (up to about 18 s on one task), partly because the baseline often gave up early.
- Do I need to type "use context7"? My Context7-arm runs always included it. The CLI setup adds a rule meant to make the agent look up library docs without it. I did not measure how often it does.
- Does Context7 work with LangGraph? Yes. I used it to look up LangGraph's RetryPolicy for the pipeline fix above.
Related reading
- LangGraph Deep Agents Human-in-the-Loop Tool Approvals: the
interruptpattern from the LangGraph test. - Durable Execution in LangGraph: Agents That Survive Failure and Resume Where They Left Off: checkpoints and resume, the durability side of LangGraph pipelines.
- Semantic caching for LLMs: cutting the cost side.
This post was sponsored by Upstash; the tests and opinions are mine.
