Blog

Context7: Fixing the One Thing Every AI Coding Assistant Gets Wrong

Johannes Hayer
Johannes Hayer
·2 min read·en

Ask an LLM to generate code for a framework that's shipped a breaking change since training, and you get the old pattern back — confidently, and wrong. In the video, it's Next.js 15: params, cookies, and headers went from synchronous to asynchronous. Ask for the new API and the model still hands you the old, synchronous version, because that's what it learned.

That's not a prompting problem. It's a training-data problem, and no amount of rephrasing fixes it on its own.

What Context7 actually does#

Context7 is an MCP server with a browsable, per-framework knowledge base — Next.js, Elasticsearch, and a long list of others, including several built specifically for working with AI agents. Instead of relying on whatever the model learned at training time, it fetches the current documentation for the specific library you're using, right before the answer gets generated.

It exposes two tools:

  • resolve-library-id — give it a name like "Next.js," get back Context7's internal ID for it.
  • get-library-docs — pass that ID, get back the current documentation for exactly that library.

In the video#

  • 00:12 — The problem, concretely: Next.js 15's sync-to-async breaking change, and the model generating the old pattern anyway
  • 01:36 — What Context7 is and what it solves
  • 02:17 — Setup: adding the Context7 MCP server config (same pattern works across MCP-compatible tools)
  • 03:40 — Confirming the server's live, and the two tools it exposes
  • 04:43 — Retrying the query with Context7 in the loop — correct, current code comes back

Setting it up#

Context7 ships as an MCP server, so setup is the same generic config-drop you'd do for any MCP server — add the entry to your tool's config JSON, pointing at the Context7 start command with the version you want. Once it's running, your IDE or agent shows the two tools listed above, ready to be called.

The part that actually matters: being explicit#

Wiring up the MCP server isn't the whole story. The model still decides on its own whether to call resolve-library-id and get-library-docs — it's not automatic just because the tool exists. Being explicit in your prompt about wanting current documentation, and even naming the library up front, makes a real difference in whether Context7 actually gets used. It's not foolproof — some models still skip it under certain conditions — but the more explicit you are, the more consistently it kicks in.

Once it does: the first call resolves the library ID, the second pulls the actual current docs, that gets folded into the prompt, and only then does the model generate — this time with await in the right places, because it's now working from documentation instead of memory.

The actual point#

Training data is frozen the moment training stops. Frameworks aren't. The fix isn't a better prompt about a frozen snapshot — it's pulling the current source at generation time, and being explicit enough that the model actually reaches for it.

AI engineering, weekly.

Join developers getting practical AI engineering in their inbox.