An unofficial command-line tool for reading and writing MCP (Model Context Protocol) configurations to mcpnest.dev.
π‘ Manage MCP templates with ease: Use
buildmcpto organize your MCP servers into reusable templates and profiles, then deploy them to MCPNest or local configs with built-in change detection. Perfect for managing multiple MCP configurations across environments.
- π Read MCP configurations from MCPNest
- π Write MCP configurations to MCPNest
- π Automatic format conversion from Claude Code to MCPNest format
- β Validation of server configurations against MCPNest requirements
- π Environment variable expansion for sensitive values
- π― Smart exit codes for CI/CD integration
npm install -g mcpnest-clinpx mcpnest-cli [command]git clone https://github.com/starbased-co/mcpnest-cli.git
cd mcpnest-cli
npm install
npm link # Creates global symlink for developmentTo get started, you need to get your cookie string from your browser:
-
Log into mcpnest.dev
-
Open browser DevTools (F12)
-
Go to one of these places:
- Application tab β Storage β Cookies β mcpnest.dev
- Network tab β Any request to mcpnest.dev β Request Headers β Cookie
-
Copy the entire Cookie header value, which typically looks like:
_mcpnest_key=SFMyNTY...; other_cookie=value; ...
You can provide cookies via the MCPNEST_COOKIE environment variable:
# Set the cookie once
export MCPNEST_COOKIE="your_cookie_string_here"
# Then use the commands without -c
mcpnest read
mcpnest write -f config.json
cat config.json | mcpnest write
mcpnest read | mcpnest write # Copy current configOr with the -c command-line option:
# Read Configuration
mcpnest read -c "YOUR_COOKIE_STRING"
# Write Configuration from file
mcpnest write -c "YOUR_COOKIE_STRING" -f config.json
# Write Configuration from stdin
mcpnest read -c "YOUR_COOKIE_STRING" | mcpnest write -c "YOUR_COOKIE_STRING"
echo '{"mcpServers": {}}' | mcpnest write -c "YOUR_COOKIE_STRING"
# Using npx without installation
npx mcpnest-cli read -c "YOUR_COOKIE_STRING"
npx mcpnest-cli write -c "YOUR_COOKIE_STRING" -f config.json
npx mcpnest-cli read | npx mcpnest-cli writeBoth commands output the current MCP configuration as JSON to stdout.
If you get authentication errors:
- Make sure you're logged into MCPNest
- Check that your cookie string is complete and current (should contain
_mcpnest_keyor similar session cookie) - Cookies may expire - get fresh ones if needed
- Make sure you're copying the entire Cookie header value, not just individual cookie values
- If using environment variable, ensure it's properly exported:
echo $MCPNEST_COOKIE
The write command automatically validates and converts Claude Code MCP configurations to MCPNest-compatible format.
- Transport Syntax: Converts top-level
typefield totransport: {type: "stdio"} - Environment Variables: Expands
${VAR}and${VAR:-default}to actual values - Field Cleanup: Removes invalid fields while preserving valid ones
Input (Claude Code format):
{
"mcpServers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"API_KEY": "${GITHUB_TOKEN:-ghp_default}"
}
}
}
}Output (MCPNest format):
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"transport": {
"type": "stdio"
},
"env": {
"API_KEY": "ghp_actual_value"
}
}
}
}MCPNest has strict requirements for security. The CLI validates each server configuration:
- Commands: Only
npxanduvx - Transport: Only
stdio(no HTTP/SSE) - Fields:
command,args,transport,env
- Custom paths:
/usr/bin/python,./script.sh - Direct commands:
python,node,deno - HTTP/SSE servers: Servers with
urlorheadersfields - Invalid fields: Any fields not in the allowed list
β Validation Results:
β 3 servers validated successfully
β 2 servers rejected:
β’ "github-http": HTTP transport not supported by MCPNest
Suggestion: Use stdio-based alternative or deploy server separately
β’ "custom-python": Command '/home/user/venv/bin/python' not allowed
Suggestion: Package as PyPI package and use 'uvx' command
Proceeding with 3 valid servers...
The CLI uses specific exit codes for different scenarios, useful for CI/CD:
| Code | Meaning | Description |
|---|---|---|
| 0 | Success | All servers valid and saved |
| 1 | Partial Success | Some servers rejected but valid ones saved |
| 2 | Validation Failure | All servers rejected, nothing saved |
| 3 | Fatal Error | Authentication failure or connection error |
#!/bin/bash
# Try to write config
mcpnest write -f config.json
case $? in
0) echo "β
All servers uploaded successfully" ;;
1) echo "β οΈ Some servers were rejected but valid ones saved" ;;
2) echo "β All servers rejected - check your configuration" ;;
3) echo "π₯ Fatal error - check authentication/connection" ;;
esacTo test validation without actually uploading (dry run):
# Use the test validation script
node test-validation.js
# Or use DEBUG mode to see what would be sent
DEBUG=1 mcpnest write -f config.json# Set environment variables
export GITHUB_TOKEN="ghp_abc123"
export OPENAI_KEY="sk-xyz789"
# Config with variables
cat > config.json << 'EOF'
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}",
"DEFAULT_BRANCH": "${DEFAULT_BRANCH:-main}"
}
}
}
}
EOF
# Variables are automatically expanded during write
mcpnest write -f config.json# Process multiple configs
for config in configs/*.json; do
echo "Processing $config..."
if mcpnest write -f "$config"; then
echo "β $config uploaded"
else
echo "β $config failed with exit code $?"
fi
done