Connect to servers
Configuring MCP servers: command, args, and env
Most connection problems come down to a small config. Here is what each field does and the mistakes that bite people.
The fields #
- command is the executable that launches the server (
npx,uvx,python, a path to a binary). - args is the argument list. This is where the package name and any non-secret flags go.
- env is a map of environment variables passed to the server process. API keys and tokens belong here.
Keep secrets in env #
Security
Never put API keys or tokens in args. Arguments can show up in process listings and logs. Put every secret in env, where the server reads it as an environment variable.
json{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "ghp_..." }
}
}
}
Common pitfalls #
- Command not on PATH. GUI apps often have a minimal PATH; use an absolute path to the interpreter if
npxorpythonis not found. - Wrong working directory. Servers that take a path argument (like filesystem) resolve it relative to where they launch. Pass absolute paths.
- Forgot to restart. Most clients read the config only at startup. Restart after editing.
Resources & further reading
- modelcontextprotocol.io MCPThe official Model Context Protocol site: concepts, quickstarts, and client list.