home / mcp / context7 mcp server

Context7 MCP Server

Context7 MCP Server

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "2511319-context7": {
      "url": "https://mcp.context7.com/mcp"
    }
  }
}

Context7 MCP provides up-to-date code documentation and sample prompts in your prompts, allowing you to fetch current library docs and code examples directly in your development workflow. It integrates with multiple MCP clients and supports both remote HTTP and local STDIO server configurations, giving you fast access to accurate, context-specific information for libraries you use.

How to use

You enable Context7 MCP in your prompt by telling your MCP client to load Context7. Then you ask for up-to-date library docs or code samples, and the MCP server returns precise, context-aware results. Start by configuring a Context7 MCP server in your client, choose a remote HTTP connection if you want a centralized server, or a local STDIO setup to run Context7 directly from your machine.

How to install

Prerequisites: Node.js 18 or newer and your preferred MCP client (Cursor, Windsurf, Claude Desktop, or any compatible MCP client). Follow the concrete steps below to set up either a remote HTTP connection or a local STDIO server.

Configure a remote HTTP Context7 MCP server

{
  "mcpServers": {
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "args": []
    }
  }
}

Configure a local STDIO Context7 MCP server using NPX

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"]
    }
  }
}

Alternative local STDIO configurations you can use

If you prefer different runtimes, you can run the Context7 MCP server with these local configurations as examples. Use the same mcpServers structure and replace the command/args as shown.

{
  "mcpServers": {
    "context7": {
      "command": "bunx",
      "args": ["-y", "@upstash/context7-mcp"]
    }
  }
}
{
  "mcpServers": {
    "context7": {
      "command": "deno",
      "args": ["run","--allow-env=NO_DEPRECATION,TRACE_DEPRECATION","--allow-net","npm:@upstash/context7-mcp"]
    }
  }
}
{
  "mcpServers": {
    "context7": {
      "command": "docker",
      "args": ["run","-i","--rm","context7-mcp"]
    }
  }
}

Note about Windows and other clients

Some clients show Windows-specific commands. For example, you can start from a Windows CMD shell with the following structure, translating it into your client’s configuration format.

{
  "mcpServers": {
    "context7": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"]
    }
  }
}

Notes on security and maintenance

Run Context7 MCP with the least-privilege environment possible. Use a dedicated port when configuring HTTP transport if your client supports port control, and prefer secure URLs (https). Keep the MCP server version up to date and monitor for updates in your MCP client as well.

Troubleshooting tips

If you encounter module resolution or TLS-related issues, try alternative runtimes like bunx or deno, ensure you are using Node.js v18 or higher, and consider using the latest package name in your command.

Development

To run your own Context7 MCP server locally, follow the development flow: install dependencies, build, and run the server. Use the provided CLI will you run the server with your chosen transport.

Examples of available endpoints and tools

Context7 provides two core tools you can call from your prompts: resolve-library-id to map a library name to a Context7-compatible ID, and get-library-docs to fetch documentation for a specific library ID. You can fine-tune the results with an optional topic and adjust the tokens limit.

Security and policy considerations

Keep your API surface minimal by only enabling the MCP server for trusted clients. Rotate any credentials used for access and monitor usage to prevent exposure of sensitive project information.

Appendix: Quick tool references

- resolve-library-id: Converts a library name to a Context7-compatible library ID. - get-library-docs: Retrieves documentation for a given library ID.

Available tools

resolve-library-id

Resolves a general library name into a Context7-compatible library ID.

get-library-docs

Fetches documentation for a library using a Context7-compatible library ID, with optional topic and token limits.