Get the FREE Ultimate OpenClaw Setup Guide →

context7

Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio upstash-context7 npx -y @upstash/context7-mcp --api-key YOUR_API_KEY

How to use

Context7 MCP is designed to provide up-to-date, version-specific documentation and code examples for libraries directly into your prompts. To utilize its capabilities, simply add 'use context7' to your prompt when asking for code generation or library documentation. For example, you can ask for a Next.js middleware implementation or a Cloudflare Worker script, and Context7 will fetch the relevant information without any need for tab-switching or outdated references. Additionally, you can set up rules in your MCP client to automatically invoke Context7 for code-related queries, streamlining your workflow.

How to install

To install Context7, ensure you have Node.js installed as a prerequisite. You can then use the following commands to set up the MCP server:

  1. For Cursor:

    • Go to Settings -> Cursor Settings -> MCP -> Add new global MCP server.
    • Paste the following configuration into your ~/.cursor/mcp.json:
    {
      "mcpServers": {
        "context7": {
          "command": "npx",
          "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
        }
      }
    }
    
  2. For Claude Code:

    • Run the command:
    claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
    
  3. For Opencode:

    • Add to your configuration file:
    "mcp": {
      "context7": {
        "type": "local",
        "command": ["npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
        "enabled": true
      }
    }
    

Additional notes

It's recommended to obtain a free API key from context7.com/dashboard for higher rate limits. If you want to avoid typing 'use context7' in every prompt, consider adding a rule in your MCP client settings to automatically invoke Context7 for relevant queries. Additionally, you can specify a library ID or version in your prompt to get the most accurate documentation for your needs. If you encounter issues, ensure your API key is correctly configured and that you are using the appropriate endpoint for OAuth if needed.

Related MCP Servers

Sponsor this space

Reach thousands of developers