Make AI Use Live Documentation with Context7 MCP

Code A Program951 words

Full Transcript

Hello everyone. AI models do not know what changed yesterday. Frameworks move fast. That is why AI sometimes gives you code that looks correct but is already outdated. Here's a real example. I'm using the anti-gravity IDE here. I asked it to set up the latest Nex.js project with a simple middleware. Anti-gravity actually did the setup correctly. It used the help flag, detected the latest Nex.js JS version and installed Nex.js 16 without any issues. So the project setup is not the problem. The issue starts after that. It generated a middleware file based on my request in Nex.js 16. The middleware file convention is deprecated and has been renamed to proxy. But even when using the clawed opus model, it still created the deprecated middleware file. What's interesting is that when anti-gravity ran the app, Nex.js immediately showed a warning in the terminal saying the middleware file is deprecated. Anti-gravity picked up that warning right away and started validating the app. The middleware still runs and custom headers are added correctly because Nex.js16 still supports middleware for backward compatibility. This means the code works today, but it may break in the future. Anti-gravity noticed the issue only after running the app and seeing the warning. It didn't catch the deprecation while generating the code. And this behavior isn't consistent. Sometimes the issue is detected and sometimes it isn't. This clearly shows the real problem. AI can generate working code, but without live up-to-date documentation, it can still produce deprecated patterns. This is exactly where Context 7 comes in. Context 7 gives LLMs and AI code editors access to up-to-date documentation so they don't rely on outdated training data. Here you can find almost every major library. Nex.js, Langchain, Prisma, Better Off, Shad CN, and many more. In total, context 7 supports 63,400 plus libraries. And this is not limited to JavaScript. You can use it across multiple programming languages. For example, here I'm searching for NumPy, one of the most popular libraries in Python. Here you can find up-to-date context for almost any library. By default, context 7 provides a summarized version of the libraries documentation. If you want, you can simply copy and paste this context directly into your agent instructions, rules, or skills. That's one way to use it. There's also an easier and more powerful way. I'll show that in a moment. One really useful feature is filtering. You can filter the context by specific topics related to the library and get only the relevant parts. For example, here you can see the middleware code reference and it's fully upto-date. You can copy just this context and use it directly. You also have control over token limits. You can increase or decrease them based on how much context you want. More tokens give you more detailed documentation. This is just one way to use Context 7. In the chat tab, you can chat directly with the up-to-date documentation, which is really useful. And one more important feature, you're not limited to the latest docs. You can also access context for specific library versions, which is extremely powerful. And one more useful option, you can add your own documentation. You can connect GitHub repositories or even share documentation from any website URL. Now, let's look at the second way to use Context 7. This time, we'll connect it using MCP, which is the approach we're going to use. Context 7 documentation is really good. I'll share the reference links in the description below. The workflow is simple. First, write your prompt naturally. Then, just add the words use context 7 inside the prompt. And that's the easiest way to call context 7 through MCP. You can set rules to always use context 7, specify the exact library, and even ask for a specific version to get the right documentation. You can find installation steps for claude and cursor in the docs. For cursor, it's very easy. Just click the add button. The same applies to open code and other MCP clients. You can also manually add MCP to your IDE. And Context 7 provides clear MCP integration guides for each supported IDE. Before setting this up though, you need to create an API key. I've already created mine. The documentation clearly explains the installation steps. Right now, I'm on the free plan, which gives 1,000 API calls per month, and the pro plan costs $10 per month with 5,000 API calls plus private repository access. Click the MCP server option. Then open manage MCP servers and select view config file. Now copy the local server connection JSON. Paste it here and replace it with your API key. Save the file and click refresh. You can see the MCP is now added with two available tools. You can follow the same process to add MCP in other like cursor. Now I'm using the same prompt as before, but this time I'm adding use context 7. Let's submit the prompt. After submitting the prompt, the tool starts executing automatically. First, it resolves the library ID for Nex.js. Once it's found, it queries the documentation, reads the latest docs, and collects the required data. As you can see, this time it generated the correct proxy.ts file. AI can generate code, but without the right context, it can still use outdated patterns. Context 7 fixes that by giving AI access to up-to-date version correct documentation. If you don't get the proxy file, just mention the latest middleware proxy in your prompt and it will generate the correct one. All the links are in the description below. If this helped you, like the video, subscribe, and I'll see you in the next

Need a transcript for another video?

Get free YouTube transcripts with timestamps, translation, and download options.

Transcript content is sourced from YouTube's auto-generated captions or AI transcription. All video content belongs to the original creators. Terms of Service · DMCA Contact

Make AI Use Live Documentation with Context7 MCP - YouTub...