mcp add
Adds a new MCP server to the 1MCP configuration.
For a complete overview of server management, see the Server Management Guide.
Synopsis
bash
# Standard syntax
npx -y @1mcp/agent mcp add <name> --type <type> [options]
# Quick syntax with " -- " pattern (auto-detects type as stdio)
npx -y @1mcp/agent mcp add <name> [options] -- <command> [args...]Arguments
<name>- A unique name for the new server.
- Required: Yes
Global Options
This command supports all global options:
--config, -c <path>- Specify configuration file path--config-dir, -d <path>- Path to the config directory
Command-Specific Options
--type <type>- The transport type for the server.
- Required: Yes (or auto-detected when using " -- " pattern)
- Values:
stdio,http,sse
--command <command>- The command to execute for
stdioservers. - Required for
stdio
- The command to execute for
--args <args>- One argument for the
stdiocommand. Repeat the flag for each argument:--args=--root --args=./.
- One argument for the
--url <url>- The URL for
httporsseservers. - Required for
httpandsse
- The URL for
--tags <tags>- Comma-separated list of tags for organization.
--env <key=value>- Environment variables for
stdioservers. Can be specified multiple times.
- Environment variables for
--timeout <ms>- Connection timeout in milliseconds.
--disabled- Add the server in disabled state. Use
mcp enable <name>to activate later.
- Add the server in disabled state. Use
--cwd <path>- Working directory for
stdioservers. The process will be started in this directory.
- Working directory for
--headers <key=value>- HTTP headers for
httporsseservers. Repeat the flag for multiple headers.
- HTTP headers for
--restart-on-exit- Enable automatic restart when the process exits (for
stdioservers only).
- Enable automatic restart when the process exits (for
--max-restarts <number>- Maximum automatic restart attempts (for
stdioservers only). The default is5; only0enables unlimited attempts.
- Maximum automatic restart attempts (for
--restart-delay <ms>- Initial delay in milliseconds before the first automatic restart (for
stdioservers only). Each later delay doubles, capped at 16 times this value. Default:1000.
- Initial delay in milliseconds before the first automatic restart (for
Examples
Standard Syntax
bash
# Add a local filesystem server
npx -y @1mcp/agent mcp add files --type=stdio --command=mcp-server-fs --args=--root --args=./
# Add a remote HTTP server with tags
npx -y @1mcp/agent mcp add remote-api --type=http --url="https://api.example.com/mcp" --tags="api,prod"Quick " -- " Pattern Syntax
bash
# Add server using " -- " pattern (type auto-detected as stdio)
npx -y @1mcp/agent mcp add airtable --env AIRTABLE_API_KEY=your_key -- npx -y airtable-mcp-server
# Add server with Windows command wrapper
npx -y @1mcp/agent mcp add my-server -- cmd /c npx -y @some/package
# Combine environment variables with " -- " pattern
npx -y @1mcp/agent mcp add context7 --env API_TOKEN=secret --tags=ai,tools -- npx -y @context7/server
# Add server with restart configuration
npx -y @1mcp/agent mcp add robust-server --type=stdio --command=node --args=unstable-server.js --restart-on-exit --max-restarts=5 --restart-delay=2000
# Add disabled server with custom working directory
npx -y @1mcp/agent mcp add dev-server --type=stdio --command=python --args=dev-server.py --cwd=/app/development --disabled