# Docker Setup for MCP Weather Server
This guide explains how to run the weather MCP server in a Docker container.
## Quick Start
### Build and Run with Docker Compose
```bash
# Build the image
docker-compose build
# Run the container
docker-compose up -d
# View logs
docker-compose logs -f weather-mcp
```
### Manual Docker Build and Run
```bash
# Build the image
docker build -t weather-mcp-server .
# Run the container
docker run -it --name weather-mcp-server weather-mcp-server
```
## Integration with Claude Desktop
To use the containerized server with Claude Desktop, update your `claude_desktop_config.json`:
### Option 1: Using Docker (Recommended)
```json
{
"mcpServers": {
"weather": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"weather-mcp-server"
]
}
}
}
```
**Note:** You must build the image first with `docker build -t weather-mcp-server .`
### Option 2: Using docker-compose
```json
{
"mcpServers": {
"weather": {
"command": "docker-compose",
"args": [
"-f",
"/absolute/path/to/weather/docker-compose.yml",
"run",
"--rm",
"weather-mcp"
]
}
}
}
```
## What the Docker Setup Includes
- **Dockerfile**: Multi-stage build using Python 3.12 slim image
- Installs UV package manager
- Installs dependencies from pyproject.toml
- Runs the weather server with STDIO transport
- **docker-compose.yml**: Orchestration file that:
- Builds and runs the weather-mcp service
- Sets up proper networking
- Keeps stdin/stdout open for MCP communication
- Auto-restarts on failure
- **.dockerignore**: Excludes unnecessary files from the build context
## Troubleshooting
### Container won't start
```bash
docker-compose logs weather-mcp
```
### Need to rebuild after code changes
```bash
docker-compose down
docker-compose build --no-cache
docker-compose up -d
```
### Test the server directly
```bash
docker-compose run --rm weather-mcp
```
## Environment Variables
To add environment variables, update `docker-compose.yml`:
```yaml
environment:
- SOME_VAR=value
```
Or pass them at runtime:
```bash
docker run -e SOME_VAR=value weather-mcp-server
```
## System Requirements
- Docker and Docker Compose installed
- Docker daemon running
- Python 3.12 or higher (in the container)
For more information on running MCP servers, see the [MCP documentation](https://modelcontextprotocol.io).