Concepts covered:
- Hatch package deployment with automatic dependency resolution
hatch package add --hostandhatch package synccommands- Guaranteed dependency installation (Python, apt, Docker, other Hatch packages)
- Package-first deployment advantages over direct configuration
Skills you will practice:
- Using
hatch package add --hostfor direct deployment - Using
hatch package syncfor existing packages - Validating complete dependency resolution
- Testing package functionality across different host platforms
This article covers the preferred method for deploying MCP servers to host platforms using Hatch packages. This approach guarantees that all dependencies (Python packages, system packages, Docker containers, and other Hatch packages) are correctly installed before MCP host deployment.
Hatch packages include complete dependency specifications that are automatically resolved during deployment:
# Package deployment handles ALL dependencies automatically
hatch package add my-weather-server --host claude-desktop
# ✅ Installs Python dependencies (requests, numpy, etc.)
# ✅ Installs system dependencies (curl, git, etc.)
# ✅ Installs Docker containers if specified
# ✅ Installs other Hatch package dependencies
# ✅ Configures MCP server on Claude DesktopPackage Deployment (Recommended):
- ✅ Automatic dependency resolution
- ✅ Guaranteed compatibility
- ✅ Single command deployment
- ✅ Environment isolation
- ✅ Rollback capabilities
Direct Configuration (Advanced):
- ❌ Manual dependency management required
- ❌ No compatibility guarantees
- ❌ Multiple setup steps
- ❌ Potential environment conflicts
- ❌ Limited rollback options
Use the package you created in Tutorial 03 for this exercise.
Deploy your package directly to a host platform:
# Navigate to your package directory from Tutorial 03
cd my_new_package
# Deploy to Claude Desktop with automatic dependency resolution
hatch package add . --host claude-desktopExpected Output:
[SUCCESS] Operation completed:
[ADDED] Package 'my_new_package'
Configuring MCP server for package 'my_new_package' on 1 host(s)...
✓ Configured my_new_package on claude-desktop
Check that your package is properly configured:
# List configured servers on Claude Desktop
hatch mcp list servers --host claude-desktop
# Verify package installation
hatch package listYou should see your package listed in both the MCP server configuration and the installed packages.
Deploy your package to multiple host platforms simultaneously:
# Deploy to multiple hosts
hatch package add . --host claude-desktop,cursor,vscode
# Deploy to all available hosts
hatch package add . --host allExpected Behavior:
- Dependencies are resolved once and applied to all hosts
- Each host receives appropriate configuration format
- All hosts are updated simultaneously
- Backup files are created for each host
If you have packages already installed in your environment, use hatch package sync to deploy them to hosts:
# See what packages are available for synchronization
hatch package list# Sync a specific package to hosts
hatch package sync my-weather-server --host claude-desktopNote: The hatch package sync command requires a package name. To sync all packages from an environment to hosts, use hatch mcp sync --from-env <env_name> --to-host <hosts> (covered in Tutorial 04-04).
Verify that all dependencies were correctly installed:
# Check Python environment
hatch env current
python -c "import requests, numpy; print('Dependencies available')"
# Check system dependencies (Linux/macOS)
which curl
which git
# Verify package functionality
python -c "
import sys
sys.path.insert(0, '.')
from my_new_package.tools import get_weather
print('Package tools accessible')
"Test that your MCP server works correctly with the host platform:
- Open Claude Desktop (or your target host)
- Check MCP server status in the application settings
- Test server functionality by using the tools you implemented
- Verify error handling by testing edge cases
Deploy packages with environment-specific configurations:
# Switch to development environment
hatch env use development
# Deploy with development settings
hatch package add . --host claude-desktop# Switch to production environment
hatch env use production
# Deploy with production settings
hatch package add . --host claude-desktop,cursorKey Difference: Each environment maintains separate MCP server configurations, allowing you to test different versions or configurations without conflicts.
Dependency Installation Failures:
# Check dependency resolution
hatch package add . --host claude-desktop --dry-run
# View detailed dependency information
hatch validate .Host Configuration Errors:
# Verify host availability
hatch mcp list hosts
# Check host-specific requirements
hatch mcp configure --helpPackage Validation Issues:
# Validate package structure
hatch validate .
# Check package metadata
cat hatch_metadata.jsonRollback Failed Deployment:
# Remove problematic configuration
hatch mcp remove server my-new-package --host claude-desktop
# Restore from backup if needed
# (Backups are created automatically)Clean Environment Reset
# Remove all MCP configurations for host
hatch mcp remove host claude-desktop
# Redeploy packages from the a hatch environment
hatch mcp sync --from-env env_name --to-host claude-desktopNote: The hatch mcp sync command only syncs packages from one environment (or one host) at a time. If you want to re-sync other packages, you must run the command several times.
- Develop and test locally using Tutorial 03 methods
- Validate package structure with
hatch validate . - Deploy to development host with
hatch package add . --host claude-desktop - Test functionality in host application
- Deploy to production hosts when ready
- Use specific version pins for critical dependencies
- Test dependency resolution with
--dry-runbefore deployment - Keep package metadata current as dependencies change
- Document system requirements in package documentation
- Use separate environments for development, testing, and production
- Deploy environment-specific packages to appropriate hosts
- Maintain environment boundaries to prevent configuration conflicts
You now understand the preferred method for deploying MCP servers using Hatch packages with automatic dependency resolution. This approach provides the most reliable and maintainable deployment workflow.
Continue to: Tutorial 04-03: Configuring Arbitrary Servers to learn the alternative direct configuration method for non-Hatch MCP servers.
Related Documentation:
- Package Commands Reference - Complete command syntax
- Package Authoring Tutorial - Creating packages for deployment