Concepts covered:
- Direct
hatch mcp configurefor non-Hatch MCP servers - Local vs. remote server configuration
- Manual dependency management requirements
- Advanced configuration for specialized use cases
Skills you will practice:
- Using
hatch mcp configurecommand for arbitrary servers - Configuring both local and remote servers
- Understanding manual dependency management limitations
- Handling third-party MCP servers
This article covers the advanced method for configuring MCP servers that are not packaged with Hatch. This approach provides maximum control but requires manual dependency management and is typically used for third-party servers or specialized configurations.
Use Direct Configuration For:
- ✅ Third-party MCP servers not available as Hatch packages
- ✅ Existing server infrastructure you want to integrate
- ✅ Specialized configurations requiring custom setup
- ✅ Remote MCP servers hosted elsewhere
- ✅ Legacy servers that cannot be easily packaged
Prefer Package Deployment For:
- ✅ Servers you developed (see Tutorial 04-02)
- ✅ Servers available as Hatch packages
- ✅ Servers requiring complex dependencies
- ✅ Servers you want to deploy across multiple environments
Direct Configuration:
- ✅ Maximum control over configuration
- ✅ Works with any MCP server
- ✅ No packaging requirements
- ❌ Manual dependency management
- ❌ No automatic compatibility checking
Package Deployment:
- ✅ Automatic dependency resolution
- ✅ Guaranteed compatibility
- ✅ Environment isolation
- ❌ Requires Hatch package format
- ❌ Less configuration flexibility
Configure a local MCP server that you have already installed:
# Configure a local Python MCP server
hatch mcp configure weather-api \
--host claude-desktop \
--command python \
--args /path/to/weather_server.py
# Configure with environment variables
hatch mcp configure news-api \
--host claude-desktop \
--command python \
--args /path/to/news_server.py \
--env API_KEY=your_api_key \
--env DEBUG=trueExpected Output:
Server 'weather-api' created for host 'claude-desktop':
name: UPDATED None --> 'weather-api'
command: UPDATED None --> 'python'
args: UPDATED None --> ['/path/to/weather_server.py']
env: UPDATED None --> {'API_KEY': 'your_api_key', 'DEBUG': 'true'}
Configuring MCP server 'weather-api' on host 'claude-desktop'? [y/N]: y
[SUCCESS] Successfully configured MCP server 'weather-api' on host 'claude-desktop'
# Check that the server is configured
hatch mcp list servers --host claude-desktop
# Test the configuration
python /path/to/weather_server.py --helpImportant: Unlike package deployment, you must ensure all dependencies are installed manually:
# Install Python dependencies manually
pip install requests numpy pandas
# Install system dependencies (Linux/macOS)
sudo apt-get install curl git # Ubuntu/Debian
brew install curl git # macOS
# Verify dependencies
python -c "import requests, numpy, pandas; print('Dependencies available')"Configure an MCP server hosted on a remote URL:
# Configure remote MCP server
hatch mcp configure remote-api \
--host gemini \
--url https://api.example.com/mcp \
--header "Authorization=Bearer_your_token" \
--header "Content-Type=application/json"# Configure with multiple headers for authentication
hatch mcp configure secure-api \
--host gemini \
--url https://secure-api.example.com/mcp \
--header "Authorization=Bearer_token" \
--header "X-API-Key=your_api_key" \
--header "User-Agent=HatchMCP/1.0"Expected Output:
Server 'secure-api' created for host 'gemini':
name: UPDATED None --> 'secure-api'
url: UPDATED None --> 'https://secure-api.example.com/mcp'
headers: UPDATED None --> {'Authorization': 'Bearer_token', 'X-API-Key': 'your_api_key', 'User-Agent': 'HatchMCP/1.0'}
Configuring MCP server 'secure-api' on host 'gemini'? [y/N]: y
[SUCCESS] Successfully configured MCP server 'secure-api' on host 'gemini'
# Test remote server connectivity
curl -H "Authorization: Bearer_token" \
-H "X-API-Key: your_api_key" \
https://secure-api.example.com/mcp/health
# Check configuration
hatch mcp list servers --host cursorConfigure the same server across multiple host platforms:
# Configure on multiple hosts simultaneously
hatch mcp configure file-manager \
--host claude-desktop,cursor,vscode \
--command python \
--args /path/to/file_manager.py \
--env HOME_DIR=/home/user
# Configure on all available hosts
hatch mcp configure system-tools \
--host all \
--command python \
--args /path/to/system_tools.pyClaude Desktop Requirements:
- Must use absolute paths for commands
- Environment variables fully supported
- JSON configuration format
VS Code Requirements:
- Can use relative paths in workspace context
- Limited environment variable support
- JSONC configuration format
Cursor Requirements:
- Similar to VS Code but with AI-specific features
- Custom configuration location
# Server with multiple arguments
hatch mcp configure data-processor \
--host claude-desktop \
--command python \
--args /path/to/processor.py \
--args --config=/path/to/config.json \
--args --verbose \
--args --workers=4# Testing configuration
hatch env use package_testing
hatch mcp configure test-server \
--host claude-desktop \
--command python \
--args /path/to/test_server.py \
--env DEBUG=true \
--env LOG_LEVEL=debug
# Team standard configuration
hatch env use team_standard_2024q4
hatch mcp configure team-server \
--host claude-desktop \
--command python \
--args /path/to/team_server.py \
--env DEBUG=false \
--env LOG_LEVEL=infoPath Resolution Problems:
# Use absolute paths for Claude Desktop
hatch mcp configure my-server \
--host claude-desktop \
--command python \
--args $(pwd)/server.py # Converts to absolute path
# Check path accessibility
ls -la /path/to/server.py
python /path/to/server.py --helpDependency Issues:
# Verify Python environment
which python
python --version
# Check module availability
python -c "import required_module"
# Install missing dependencies
pip install missing_packagePermission Problems:
# Check file permissions
ls -la /path/to/server.py
chmod +x /path/to/server.py
# Check directory permissions
ls -la /path/to/# Preview configuration before applying
hatch mcp configure test-server \
--host claude-desktop \
--command python \
--args /path/to/server.py \
--dry-run
# Validate existing configuration
hatch mcp list servers --host claude-desktopRemove Problematic Configuration:
# Remove specific server
hatch mcp remove server problematic-server --host claude-desktop
# Remove all servers from host
hatch mcp remove host claude-desktopRestore from Backup:
# Backups are created automatically
# Location: ~/.hatch/mcp_backups/
# Format: <hostname>_<timestamp>.json
# Manual restoration (if needed)
cp ~/.hatch/mcp_backups/claude-desktop_20231201_143022.json \
~/.config/claude/claude_desktop_config.json- Document Dependencies: Maintain clear documentation of required dependencies
- Version Pinning: Use specific versions for critical dependencies
- Environment Testing: Test in clean environments to verify dependencies
- Dependency Scripts: Create installation scripts for complex setups
- Use Absolute Paths: Especially for Claude Desktop configurations
- Environment Variables: Use environment variables for sensitive data
- Configuration Validation: Always test configurations before deployment
- Backup Strategy: Rely on automatic backups, but verify they're created
- Sensitive Data: Use environment variables, not command arguments
- File Permissions: Ensure proper permissions on server files
- Network Security: Use HTTPS for remote servers
- Authentication: Implement proper authentication for remote servers
Direct Configuration Excels For:
- Third-party servers you cannot modify
- Existing infrastructure integration
- Maximum configuration control
- Remote server integration
Package Deployment Excels For:
- Servers you develop or control
- Complex dependency requirements
- Multi-environment deployments
- Automated deployment workflows
You now understand how to configure arbitrary MCP servers using direct configuration. This advanced method provides maximum flexibility but requires careful dependency management.
Continue to: Tutorial 04-04: Environment Synchronization to learn how to synchronize MCP configurations across environments and hosts.
Related Documentation:
- MCP Commands Reference - Complete command syntax
- Package Deployment Tutorial - Preferred deployment method