Skip to main content
The ctx7 setup command configures Context7’s Model Context Protocol (MCP) server and installs the Context7 rule and skill for your AI coding agent.

Usage

Options

Agent Selection

--claude

Set up Context7 for Claude Code.
Configures:
  • MCP server in ~/.config/claude/mcp.json
  • Rule in ~/.config/claude/rules/context7.md
  • Skill in ~/.config/claude/skills/context7/SKILL.md

--cursor

Set up Context7 for Cursor.
Configures:
  • MCP server in ~/.cursor/mcp.json
  • Rule in ~/.cursor/rules/context7.md
  • Skill in ~/.cursor/skills/context7/SKILL.md

--opencode

Set up Context7 for OpenCode.
Configures:
  • MCP server in ~/.config/opencode/mcp.json
  • Rule in ~/.config/opencode/rules/context7.md
  • Skill in ~/.config/opencode/skills/context7/SKILL.md

Scope

-p, --project

Configure Context7 for the current project instead of globally.
When used, configuration files are created in the current directory:
  • .claude/mcp.json (for Claude Code)
  • .cursor/mcp.json (for Cursor)
  • .config/opencode/mcp.json (for OpenCode)
Project-level configuration overrides global configuration for that specific project.

Authentication

--api-key <key>

Use API key authentication instead of OAuth.
This configures the MCP server with your API key for authentication.
Store API keys securely. Never commit them to version control.

--oauth

Use OAuth endpoint where the IDE handles the authentication flow.
This is useful for IDEs that support OAuth authentication natively.

Other Options

-y, --yes

Skip confirmation prompts and use detected agents.
Useful for automation and scripts.

Interactive Mode

When run without options, ctx7 setup enters interactive mode:

Step 1: Agent Selection

The CLI detects installed agents and prompts you to select which ones to configure:

Step 2: Authentication

The CLI automatically authenticates you with Context7:
  1. Opens your browser to the login page
  2. You authenticate with Context7
  3. The CLI receives the authentication token
  4. Generates an API key for the MCP server

Step 3: Configuration

The CLI configures each selected agent:

What Gets Configured

MCP Server

The MCP server entry is added to your agent’s configuration file:

Rule File

A rule file is created that instructs your agent on how to use Context7:

Skill File

A skill file is created that provides specialized instructions for using Context7:

Examples

Global Setup for Claude Code

Output:

Project-Level Setup for Multiple Agents

Configures Context7 for both Cursor and OpenCode in the current project directory.

Setup with Custom API Key

Skips the authentication flow and uses the provided API key directly.

Automated Setup

Automatically detects installed agents and configures them without prompts.

Troubleshooting

Already Configured

If Context7 is already configured for an agent, it will be marked as such:
You can still select it to reconfigure or update the configuration.

Permission Errors

If you encounter permission errors:

Authentication Failed

If authentication fails:
  1. Check your internet connection
  2. Try again: ctx7 setup
  3. Use a custom API key: ctx7 setup --api-key <key>

MCP Server Not Working

After setup, restart your AI coding agent to load the new MCP configuration.

Configuration Files

Global Configuration Paths

Project Configuration Paths

Next Steps

After setup:
  1. Restart your AI coding agent
  2. Test the Context7 MCP server by asking your agent to search for documentation
  3. Install additional skills: ctx7 skills search <topic>

See Also