Install MCP (Model Context Protocol) servers from a configuration file using the Claude CLI.
# Run directly without installing
npx @berrydev-ai/install-mcp-servers ./path/to/mcp.json
# Or with bunx
bunx @berrydev-ai/install-mcp-servers ./path/to/mcp.json
# Or install globally
npm install -g @berrydev-ai/install-mcp-servers- Claude CLI must be installed and available in your PATH
- Node.js 18+ or Bun
install-mcp-servers [options] [config-file]| Option | Description |
|---|---|
-f, --file <path> |
Path to the MCP config file (default: .mcp.json) |
-s, --scope <scope> |
Installation scope: user, project, or local (default: user) |
-d, --dry-run |
Print commands without executing |
-h, --help |
Show help message |
# Install servers from .mcp.json in current directory
install-mcp-servers
# Install from a specific config file
install-mcp-servers my-servers.json
install-mcp-servers -f ./config/mcp.json
# Preview what will be installed (dry run)
install-mcp-servers -d
# Install to project scope instead of user scope
install-mcp-servers -s project
# Combine options
install-mcp-servers -s project -d ./config/mcp.jsonThe configuration file should be a JSON file with the following structure:
{
"mcpServers": {
"server-name": {
"command": "npx",
"args": ["-y", "package-name"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}| Field | Type | Description |
|---|---|---|
command |
string | The command to run (e.g., npx, bunx, uvx, docker) |
args |
string[] | Arguments to pass to the command |
env |
object | Environment variables for the server |
{
"mcpServers": {
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
},
"mastra": {
"command": "npx",
"args": ["-y", "@mastra/mcp-docs-server"]
},
"oracle-mcp": {
"command": "bunx",
"args": ["-y", "@bercastle/oracle-mcp@0.4.0", "--mcp"],
"env": {
"SOURCEGRAPH_ACCESS_TOKEN": "${SOURCEGRAPH_ACCESS_TOKEN}",
"XAI_API_KEY": "${XAI_API_KEY}"
}
},
"duckdb-analytics": {
"command": "uvx",
"args": ["mcp-server-motherduck", "--db-path", ":memory:"],
"env": {
"AWS_ACCESS_KEY_ID": "${AWS_ACCESS_KEY_ID}",
"AWS_SECRET_ACCESS_KEY": "${AWS_SECRET_ACCESS_KEY}"
}
},
"playwright": {
"command": "docker",
"args": [
"run", "-i", "--rm", "--init",
"mcr.microsoft.com/playwright/mcp"
]
}
}
}The --scope flag determines where the MCP server configuration is stored:
user(default): Installs to your user-level Claude configurationproject: Installs to the current project's Claude configurationlocal: Installs to the local Claude configuration
This tool reads your MCP configuration file and executes the equivalent claude mcp add commands for each server. For example, a server configured as:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "my-package"],
"env": {
"API_KEY": "secret"
}
}
}
}Will execute:
claude mcp add my-server npx -y my-package --env API_KEY=secretMIT