Context7 in Claude Code: Einrichtung, Test-Wiederholung und MCP gegen CLI
Ein Praxisleitfaden zur Integration von Context7 in Claude Code: Installation, Wiederholung des Messverfahrens und die Frage, ob MCP Server oder CLI Skill die bessere Wahl ist. Der Test ist klein und leicht nachzubauen.

Dies ist ein praktischer Leitfaden zu Context7 in Claude Code: wie man es installiert, wie man den Test, den ich zur Messung verwendet habe, erneut ausführt, und ob man den MCP-Server oder den CLI-Skill wählen sollte. Der Test ist klein und leicht zu reproduzieren. Bei upstash-redis 1.9.0, einem SDK-Release, das neuer ist als das Modell und dort, wo der Agent arbeitete, nicht installiert war, bestand Claude Code ohne Hilfe 0 von 9 Durchläufen und mit Context7 7 von 9.
Die Claude-Code-Seite von Context7 empfiehlt einen einzigen Befehl:
npx ctx7 setup --claude Vollbildmodus öffnen Vollbildmodus beenden Er fragt, ob der MCP-Server oder ein CLI-Skill installiert werden soll. Füge --cli hinzu, um direkt zum Skill zu gelangen, der die ctx7-CLI aufruft und überhaupt kein MCP benötigt. Es gibt außerdem ein Plugin mit Browser-Anmeldung.
ctx7 setup verlangt eine Anmeldung mit einem einmaligen Geräteschlüssel (device code) und erstellt anschließend einen API-Schlüssel auf deinem Context7-Konto. Ein Hinweis: Es schreibt in $CLAUDE_CONFIG_DIR, wenn diese Variable gesetzt ist, nicht in $HOME/.claude, also prüfe zuerst diese Variable.
Du kannst Context7 auch vor der Anmeldung ausprobieren. Der lokale MCP-Server sowie die Befehle ctx7 library und ctx7 docs benötigten in meinen Durchläufen weder Schlüssel noch Anmeldung:
npx -y ctx7 library langgraph "interrupt and resume with Command" npx -y ctx7 docs /langchain-ai/langgraph "interrupt resume Command SqliteSaver" Vollbildmodus öffnen Vollbildmodus beenden Der erste Befehl listet passende Library-IDs auf. Der zweite liefert die aktuellen Dokumente für eine davon. In meinem Durchlauf vom 23. November dauerte eine ctx7-docs-Abfrage etwa 1,6 Sekunden und lieferte etwa 800 bis 900 Wörter, klein genug, um sie in den Kontext eines Agenten einzufügen. Der MCP-Server läuft lokal mit npx -y @upstash/context7-mcp.
Jeder Durchlauf läuft headless, in einem frischen Scratch-Verzeichnis außerhalb jedes Repositorys, sodass keiner der beiden Zweige meine Projektnotizen oder die Referenzlösungen sieht (Einstellungen auf Nutzerebene könnten dennoch geladen werden, in beiden Zweigen gleichermaßen):
claude -p "$PROMPT" --setting-sources project \ --strict-mcp-config --mcp-config mcp.json \ --permission-mode acceptEdits \ --allowedTools "Write" "Edit" "Read" "Bash(.venv/bin/python:*)" \ --output-format stream-json --verbose --max-budget-usd 2 Vollbildmodus öffnen Vollbildmodus beenden Die beiden Zweige unterscheiden sich nur in mcp.json:
--strict-mcp-config lädt nur diese Datei, sodass kein anderer MCP-Server hineinsickert. Web-Tools sind nicht in --allowedTools enthalten, daher werden Web-Recherchen in beiden Zweigen verweigert. Kosten und Durchgangszahlen stammen aus dem finalen Ergebnisobjekt des Durchlaufs. Ich verwendete 3 Durchläufe pro Aufgabe, 9 pro Zelle, auf claude-opus-5-5.
Die drei upstash-redis-1.9.0-Aufgaben (PyPI, veröffentlicht am 2. November 2026):
Aufgabe 1 und 2 nannten die API-Familie ("die eigene Vektor-API des SDK", "die Array-Befehle des SDK"). Alle drei endeten mit "Verwende nur APIs, die in dieser Version existieren." Ich bestätigte durch einen Diff der Pakete 1.8.0 und 1.9.0, dass redis.vector und die Array-Befehle (arring, arlastitems, …) in 1.9.0 neu sind.
Die Erfolgsprüfung läuft danach, außerhalb des Agenten. Ein kleiner Recorder ersetzt den HTTP-Aufruf des SDK und verwendet den eigenen Antwort-Parser des SDK. Die Prüfung sieht also exakt, welche Redis-Befehle eine Lösung senden würde, zum Beispiel VECTOR.CREATE notes DIM 3 METRIC COSINE, ohne Server und ohne Zugangsdaten. Anschließend vergleicht sie diese mit den erwarteten Befehlen.
Ohne Context7 versuchte der Agent in 8 von 9 Durchläufen das Web und wurde abgewiesen (der Context7-Zweig versuchte es in 5 von 9, ebenfalls abgewiesen). Bei den beiden Vektor-Aufgaben weigerte er sich dann, Code zu schreiben, und für den Ring schrieb er die alte Antwort, eine Liste mit LPUSH und LTRIM. Mit Context7 führte er zwei oder drei Dokumentabfragen pro Durchlauf aus und verwendete die neue API.
Context7 lieferte die aktuellen upstash-redis-Dokumente, die diese bereits enthalten. Auch die beiden anderen Durchläufe arbeiteten mit den aktuellen Dokumenten: Einer fügte vor der Indexerstellung eine EXISTS-Prüfung hinzu, die meine Prüfung auf exakte Befehlsfolgen zurückweist, und einer sendete die richtigen VECTOR.*-Befehle über rohes execute(), weil er die Existenz der SDK-Methode nicht bestätigen konnte.
Eine Kontrolle mit einer API, die das Modell bereits kannte, LangGraph 1.2.17 mit interrupt und Command(resume=...) sowie SqliteSaver, bestand in beiden Zweigen 2 von 2 Mal. Mit installiertem SDK las der Agent dessen Quellcode und bestand in beiden Fällen 9 von 9, wobei Context7 rund 6 Cent pro Durchlauf zusätzlich kostete. Der Nutzen zeigt sich dort, wo der benötigte Code noch nicht auf der Festplatte liegt: eine Version, auf die du gerade upgraden willst, oder eine Library, die du nicht installiert hast.
Die Wahl hängt also vom Client ab. Verwende den MCP-Server, wo MCP unterstützt wird, und den CLI-Skill überall dort, wo es eine Shell gibt. Ich verwendete den MCP-Server für den A/B-Test und die ctx7-CLI für echte Arbeit: Sie lieferte mir LangGraphs RetryPolicy und runtime.execution_info.node_attempt, was ich gegen das installierte LangGraph 1.2.12 prüfte, für einen Retry-Fix in meiner eigenen Event-Harvesting-Pipeline.
Dieser Beitrag wurde von Upstash gesponsert; die Tests und Meinungen sind meine eigenen.
Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.
Original (Englisch) anzeigen
This is a practical guide to Context7 in Claude Code: how to install it, how to rerun the test I used to measure it, and whether to pick the MCP server or the CLI skill. The test is small and easy to copy. On upstash-redis 1.9.0, an SDK release newer than the model and not installed where the agent worked, Claude Code passed 0 of 9 runs on its own and 7 of 9 with Context7.
Context7's Claude Code page recommends one command:
npx ctx7 setup --claude Enter fullscreen mode Exit fullscreen mode It asks whether to install the MCP server or a CLI skill. Add --cli to go straight to the skill, which calls the ctx7 CLI and needs no MCP at all. There is also a plugin with browser sign-in.
ctx7 setup asks you to sign in with a one-time device code, then creates an API key on your Context7 account. One tip: it writes into $CLAUDE_CONFIG_DIR when that is set, not into $HOME/.claude, so check that variable first.
You can try Context7 before signing in. The local MCP server and the ctx7 library / ctx7 docs commands needed no key and no login in my runs:
npx -y ctx7 library langgraph "interrupt and resume with Command" npx -y ctx7 docs /langchain-ai/langgraph "interrupt resume Command SqliteSaver" Enter fullscreen mode Exit fullscreen mode The first command lists matching library ids. The second returns current docs for one of them. In my 23 November run, a ctx7 docs query took about 1.6 s and returned about 800–900 words, small enough to drop into an agent's context. The MCP server runs locally with npx -y @upstash/context7-mcp.
Each run is headless, in a fresh scratch directory outside any repo, so neither arm sees my project notes or the reference answers (user-level settings may still load, the same in both arms):
claude -p "$PROMPT" --setting-sources project \ --strict-mcp-config --mcp-config mcp.json \ --permission-mode acceptEdits \ --allowedTools "Write" "Edit" "Read" "Bash(.venv/bin/python:*)" \ --output-format stream-json --verbose --max-budget-usd 2 Enter fullscreen mode Exit fullscreen mode The two arms differ only in mcp.json:
--strict-mcp-config loads only that file, so no other MCP server leaks in. Web tools are not in --allowedTools, so web lookups are denied in both arms. Cost and turns come from the run's final result object. I used 3 runs per task, 9 per cell, on claude-opus-5-5.
The three upstash-redis 1.9.0 tasks ( PyPI, released 2 November 2026):
Tasks 1 and 2 named the API family ("the SDK's own vector API", "the SDK's array commands"). All three ended with "Use only APIs that exist in that version." I confirmed redis.vector and the array commands ( arring, arlastitems, …) are new in 1.9.0 by diffing the 1.8.0 and 1.9.0 packages.
The pass check runs afterwards, outside the agent. A small recorder replaces the SDK's HTTP call and uses the SDK's own response parser. So the check sees exactly which Redis commands a solution would send, for example VECTOR.CREATE notes DIM 3 METRIC COSINE, with no server and no credentials. Then it compares them with the expected ones.
Without Context7, the agent tried the web in 8 of 9 runs and was denied (the Context7 arm tried it in 5 of 9, also denied). On the two vector tasks it then declined to write code, and for the ring it wrote the old answer, a list with LPUSH and LTRIM. With Context7 it made two or three docs queries per run and used the new API. Context7 served the current upstash-redis docs, which already include it. The other two runs also worked from the current docs: one added an EXISTS check before creating the index, which my exact-sequence check rejects, and one sent the right VECTOR.* commands through raw execute() because it could not confirm the SDK method existed.
A control on an API the model already knew, LangGraph 1.2.17 's interrupt with Command(resume=...) and SqliteSaver, passed 2 of 2 in both arms. With the SDK installed, the agent read its source and passed 9 of 9 either way, and Context7 added about 6 cents per run. The payoff is where the code you need is not on disk yet: a version you are about to upgrade to, or a library you have not installed.
So pick by client. Use the MCP server where MCP is supported, and the CLI skill anywhere with a shell. I used the MCP server for the A/B test and the ctx7 CLI for real work: it gave me LangGraph's RetryPolicy and runtime.execution_info.node_attempt, which I checked against the installed LangGraph 1.2.12, for a retry fix in my own event-harvesting pipeline.
This post was sponsored by Upstash; the tests and opinions are mine.