Add MCP servers to Claude Code configuration at user level (~/.claude). Supports stdio, HTTP, and SSE transports with environment variable prompting. Use when "add mcp server", "install mcp", "configure mcp server", "new mcp", or "setup mcp server".
/plugin marketplace add daispacy/py-claude-marketplace/plugin install py-plugin@py-claude-marketplaceThis skill is limited to using the following tools:
templates.mdAutonomously add MCP (Model Context Protocol) servers to Claude Code configuration at the user level (~/.claude/mcp.json).
Ask user for:
Server name (e.g., "mobile-mcp-server")
Transport type:
stdio - Local command execution (most common)http - Remote HTTP serversse - Server-Sent Events (deprecated but supported)Based on transport type:
For stdio:
["@daipham/mobile-mcp-server@latest"])For http:
{"Authorization": "Bearer ${API_KEY}"})For sse:
Always ask user: "Does this MCP server require any environment variables?"
If yes, for each variable:
Document in output: List all required environment variables with instructions on where to set them.
Check for existing .mcp.json at user level:
cat ~/.claude/mcp.json
If file doesn't exist, create new structure. If exists, parse and merge.
Use templates from templates.md to generate the server configuration based on transport type.
Apply environment variable syntax:
${VAR} - Required variable (will error if not set)${VAR:-default} - Optional variable with default valueMerge strategy:
mcpServers objectWrite to ~/.claude/mcp.json.
If environment variables are needed, inform user:
⚠️ Environment Variables Required:
Set these in your shell profile (~/.zshrc or ~/.bashrc):
export VAR_NAME="value"
export ANOTHER_VAR="value"
Or create a project-specific .env file and reference it:
"envFile": "${workspaceFolder}/.env"
Run validation:
claude mcp list
Show the newly added server in the output.
✅ MCP Server Added: [server-name]
📁 Configuration: ~/.claude/mcp.json
🔧 Transport: [stdio/http/sse]
📦 Command: [command with args] (if stdio)
🌐 URL: [url] (if http/sse)
📋 Configuration Added:
```json
{
"server-name": {
// configuration here
}
}
⚠️ Environment Variables Required:
💡 Set environment variables:
Add to ~/.zshrc or ~/.bashrc: export VAR_NAME="your-value"
Or use project .env file: "envFile": "${workspaceFolder}/.env"
✅ Restart Claude Code to activate the new MCP server.
🧪 Test with: claude mcp list
## Error Handling
- **Invalid JSON**: Show parsing error, ask user to verify configuration
- **Duplicate server name**: Ask if user wants to overwrite existing server
- **Missing required fields**: Prompt for missing information
- **File permission errors**: Suggest checking ~/.claude directory permissions
## Important Notes
1. **User-level scope**: Servers added at `~/.claude/mcp.json` are available across all projects
2. **Environment variables**: Always prompt for environment variables - many MCP servers require API keys or configuration
3. **Restart required**: Claude Code must be restarted after adding MCP servers
4. **Validation**: Use `claude mcp list` to verify the server was added successfully
5. **Security**: Never log or display actual environment variable values
## Reference
See `templates.md` for configuration templates for each transport type.