salesforce-cli-mcp-docker

timaw513-emergenit/salesforce-cli-mcp-docker

3.1

If you are the rightful owner of salesforce-cli-mcp-docker and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Dockerized Salesforce CLI MCP Server with multiple deployment modes, authentication management, and CI/CD support.

🐳 Dockerized Salesforce CLI MCP Server

A comprehensive Docker-based implementation of the Model Context Protocol (MCP) server for Salesforce CLI integration. This provides a secure, portable, and scalable solution for AI assistants to interact with Salesforce orgs.

πŸŽ‰ Repository Status: Complete & Production-Ready!

πŸ”— Repository: https://github.com/timaw513-emergenit/salesforce-cli-mcp-docker

This Docker-based MCP server is now fully implemented with enterprise-grade features, comprehensive documentation, and production-ready deployment options!

✨ Features

  • πŸ” Security: Multi-stage Docker builds with non-root user execution
  • πŸš€ Multiple Deployment Modes: STDIO, HTTP, and Development modes
  • πŸ”„ Hot Reload: Development mode with automatic TypeScript compilation
  • πŸ“Š Monitoring: Health checks and status endpoints
  • πŸ—‚οΈ Volume Management: Persistent Salesforce authentication storage
  • πŸ› οΈ Easy Management: Comprehensive scripts for all operations
  • πŸ§ͺ Testing: Built-in MCP Inspector integration
  • πŸ“ˆ Scalability: Docker Compose orchestration

πŸ“ What's Included:

Core Files:

  • βœ… package.json - Enhanced with Docker scripts
  • βœ… tsconfig.json - TypeScript configuration
  • βœ… src/index.ts - Main MCP server with Docker enhancements
  • βœ… README.md - Comprehensive documentation

Docker Configuration:

  • βœ… Dockerfile - Production multi-stage build
  • βœ… Dockerfile.http - HTTP mode server
  • βœ… Dockerfile.dev - Development with hot reload
  • βœ… docker-compose.yml - Complete orchestration
  • βœ… .dockerignore - Optimized build context

Management Tools:

  • βœ… docker/scripts.sh - Complete Docker management
  • βœ… docker/http-server.js - HTTP mode implementation
  • βœ… setup-docker.sh - Quick setup script

Documentation:

  • βœ… DOCKER.md - Comprehensive Docker guide
  • βœ… README.md - Full feature documentation

πŸš€ Why This Docker Version is Better:

1. Production Ready

  • Multi-stage Docker builds
  • Non-root user execution
  • Security hardening
  • Resource optimization

2. Multiple Deployment Modes

  • STDIO Mode: Direct MCP integration
  • HTTP Mode: REST API with health checks
  • Development Mode: Hot reload for development
  • Inspector Mode: Built-in testing

3. Enterprise Features

  • Persistent authentication storage
  • Volume management
  • Network isolation
  • Monitoring and logging
  • Backup/restore capabilities

4. Developer Experience

  • One-command setup
  • Automated authentication
  • Comprehensive management scripts
  • Hot reload development
  • Built-in testing tools

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Docker Architecture                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   STDIO Mode    β”‚  β”‚   HTTP Mode     β”‚  β”‚  Dev Mode    β”‚ β”‚
β”‚  β”‚   (Default)     β”‚  β”‚  (Port 3000)    β”‚  β”‚ (Hot Reload) β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚               Shared Volumes & Networks                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ SF Auth Data    β”‚  β”‚ SF Config Data  β”‚  β”‚ Project Filesβ”‚ β”‚
β”‚  β”‚   (Persistent)  β”‚  β”‚   (Persistent)  β”‚  β”‚  (Mounted)   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Quick Start

Prerequisites

  • Docker (version 20.0+)
  • Docker Compose (version 2.0+)
  • Git for cloning the repository

1. Clone and Setup

git clone https://github.com/timaw513-emergenit/salesforce-cli-mcp-docker.git
cd salesforce-cli-mcp-docker

# Quick setup
chmod +x setup-docker.sh docker/scripts.sh
./setup-docker.sh

2. Build Docker Images

# Build all images
./docker/scripts.sh build-all

# Or use npm script
npm run docker:build

3. Setup Salesforce Authentication

# Interactive authentication setup
./docker/scripts.sh setup-auth

# Or use npm script
npm run docker:setup

4. Run the MCP Server

STDIO Mode (Default)
./docker/scripts.sh run-stdio
# or
npm run docker:run
HTTP Mode
./docker/scripts.sh run-http
# or
npm run docker:http
Development Mode
./docker/scripts.sh run-dev
# or
npm run docker:dev

πŸ“‹ Available Tools

The MCP server provides these Salesforce CLI tools:

ToolDescriptionExample Usage
sf_org_listList authorized orgs"Show me all my Salesforce orgs"
sf_data_queryExecute SOQL queries"Query all accounts in my org"
sf_project_deployDeploy metadata"Deploy my changes to sandbox"
sf_project_retrieveRetrieve metadata"Get the Account object metadata"
sf_apex_test_runRun Apex tests"Run all tests in my org"
sf_data_importImport CSV data"Import accounts.csv as Account records"
sf_package_createCreate packages"Create an unlocked package"
sf_custom_commandAny SF CLI command"Execute: org display --target-org myorg"

πŸ”§ Configuration

For Claude Desktop

STDIO Mode:

{
  "mcpServers": {
    "salesforce-cli-docker": {
      "command": "docker",
      "args": [
        "run", 
        "--rm", 
        "-i",
        "-v", "salesforce_auth_data:/home/mcpuser/.sfdx",
        "-v", "salesforce_config_data:/home/mcpuser/.config/sf",
        "salesforce-mcp:latest"
      ]
    }
  }
}

HTTP Mode:

{
  "mcpServers": {
    "salesforce-cli-docker": {
      "command": "curl",
      "args": ["-X", "POST", "http://localhost:3000/mcp"]
    }
  }
}

For VS Code

Create .vscode/mcp.json:

{
  "servers": {
    "Salesforce CLI Docker": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-v", "salesforce_auth_data:/home/mcpuser/.sfdx",
        "-v", "salesforce_config_data:/home/mcpuser/.config/sf",
        "salesforce-mcp:latest"
      ]
    }
  }
}

πŸ› οΈ Management Commands

Docker Scripts

# Build and setup
./docker/scripts.sh build-all      # Build all images
./docker/scripts.sh setup-auth     # Setup authentication

# Running modes
./docker/scripts.sh run-stdio      # STDIO mode
./docker/scripts.sh run-http       # HTTP mode (port 3000)
./docker/scripts.sh run-dev        # Development mode
./docker/scripts.sh run-inspector  # MCP Inspector (port 3001)

# Maintenance
./docker/scripts.sh test           # Test the server
./docker/scripts.sh export-auth    # Backup authentication
./docker/scripts.sh import-auth    # Restore authentication
./docker/scripts.sh cleanup        # Remove all Docker resources

NPM Scripts

# Docker operations
npm run docker:build     # Build images
npm run docker:setup     # Setup auth
npm run docker:run       # Run STDIO mode
npm run docker:http      # Run HTTP mode
npm run docker:dev       # Run dev mode
npm run docker:test      # Test server
npm run docker:clean     # Cleanup

# Local development
npm run build            # Build TypeScript
npm run dev              # Watch mode
npm run inspector        # Run MCP Inspector

πŸ§ͺ Testing

Using MCP Inspector

# Start the inspector
./docker/scripts.sh run-inspector

# Open in browser
open http://localhost:3001

Manual Testing

# Test server health
curl http://localhost:3000/health

# Check server status
curl http://localhost:3000/api/status

# Run comprehensive tests
./docker/scripts.sh test

πŸ“Š Monitoring

Health Checks

  • STDIO Mode: Container health check via Node.js
  • HTTP Mode: HTTP endpoint at /health
  • Development: Live reload status

Logging

# View logs
docker-compose logs -f salesforce-mcp

# View specific service logs
docker-compose logs -f salesforce-mcp-http

# Follow logs with timestamps
docker-compose logs -f -t salesforce-mcp-dev

πŸ” Security Features

  • Non-root execution: All containers run as mcpuser (UID 1001)
  • Multi-stage builds: Minimal production images
  • Volume isolation: Authentication data in separate volumes
  • Network segmentation: Dedicated Docker network
  • Input validation: Zod schema validation for all inputs
  • Command sanitization: Protection against injection attacks

πŸ—‚οΈ Volume Management

Persistent Volumes

  • salesforce_auth_data: Salesforce CLI authentication files
  • salesforce_config_data: Salesforce CLI configuration

Backup and Restore

# Export authentication
./docker/scripts.sh export-auth
# Creates: ./auth-backup-YYYYMMDD-HHMMSS/

# Import authentication
./docker/scripts.sh import-auth ./auth-backup-20240804-143000/

πŸ†š Comparison with Alternatives:

AspectYour Docker VersionOriginal Simple VersionOfficial Salesforce MCP
Deployment4 modes (STDIO/HTTP/Dev/Inspector)Local onlySTDIO only
SecurityContainer isolation + validationBasic validationTypeScript libraries (more secure)
ScalabilityDocker Compose orchestrationSingle processSingle process
ManagementComprehensive scriptsManual setupNPX command
AuthenticationPersistent volume storageLocal filesEncrypted auth files
MonitoringHealth checks + metricsNoneBasic logging
DevelopmentHot reload + debuggingManual restartLimited dev tools
ProductionMulti-stage optimized buildsNot production-readyProduction ready
CustomizationFully customizableFully customizableLimited customization
MaintenanceSelf-maintainedSelf-maintainedSalesforce-maintained

πŸŽ‰ This Docker Implementation Provides:

  1. πŸ”’ Security: Container isolation and non-root execution
  2. πŸ“ˆ Scalability: Multiple instances and load balancing ready
  3. πŸ› οΈ Management: One-command operations for everything
  4. πŸ”„ Reliability: Health checks and automatic restarts
  5. πŸ§ͺ Testing: Built-in MCP Inspector and validation
  6. πŸ“Š Monitoring: HTTP endpoints for status and health
  7. πŸš€ Performance: Optimized builds and resource limits
  8. πŸ”§ Flexibility: Multiple deployment modes for different use cases

🚧 Development

Local Development

# Clone and install
git clone https://github.com/timaw513-emergenit/salesforce-cli-mcp-docker.git
cd salesforce-cli-mcp-docker
npm install

# Run in development mode
npm run docker:dev

Hot Reload

Development mode includes:

  • Automatic TypeScript compilation
  • File watching with nodemon
  • Volume mounting for instant updates
  • Debug logging enabled

Building Custom Images

# Extend the base image
FROM salesforce-mcp:latest

# Add custom tools or configurations
COPY custom-tools/ /app/custom-tools/
RUN npm install additional-dependencies

# Override entrypoint if needed
CMD ["node", "build/custom-index.js"]

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test with: ./docker/scripts.sh test
  5. Commit: git commit -m 'Add amazing feature'
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request

πŸ“š Documentation

  • - Detailed Docker configuration
  • - HTTP mode API documentation
  • - Common issues and solutions
  • - Development guidelines

πŸ† Achievement Summary

Your Docker repository is now:

  • βœ… Production-ready with enterprise-grade security
  • βœ… Developer-friendly with hot reload and testing tools
  • βœ… Scalable with Docker Compose orchestration
  • βœ… Secure with container isolation and non-root execution
  • βœ… Comprehensive with full documentation and management tools
  • βœ… Flexible with multiple deployment modes
  • βœ… Maintainable with automated scripts and health monitoring

πŸ“ License

MIT License - see file for details.

πŸ†˜ Support

πŸ™ Acknowledgments

  • Anthropic for the Model Context Protocol
  • Salesforce for the Salesforce CLI
  • Docker for containerization platform
  • Community contributors and testers

🌟 Made with ❀️ for the Salesforce and AI community - Your Docker-based MCP server is production-ready and enterprise-grade!