DEPLOYMENT.md•3.07 kB
# AWS Lambda Deployment Guide
This guide will help you deploy the Weather MCP server to AWS Lambda + API Gateway.
## Prerequisites
1. **AWS Account** - You need an AWS account
2. **AWS CLI** - Install from https://aws.amazon.com/cli/
3. **AWS SAM CLI** - Install from https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
4. **AWS Credentials** - Configure with `aws configure`
## Installation Steps
### 1. Install AWS CLI
**Windows:**
```bash
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
```
**Mac:**
```bash
brew install awscli
```
**Linux:**
```bash
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
```
### 2. Install AWS SAM CLI
**Windows:**
```bash
msiexec.exe /i https://github.com/aws/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi
```
**Mac:**
```bash
brew install aws-sam-cli
```
**Linux:**
```bash
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
sudo ./sam-installation/install
```
### 3. Configure AWS Credentials
Run:
```bash
aws configure
```
Enter:
- AWS Access Key ID
- AWS Secret Access Key
- Default region (e.g., `us-east-1`)
- Default output format (use `json`)
## Deploy to AWS
### First Deployment (Guided)
```bash
npm run deploy
```
This will:
1. Build your TypeScript code
2. Package the Lambda function
3. Ask you configuration questions
4. Deploy to AWS
5. Show you the API endpoint URL
**Answer the prompts:**
- Stack name: `weather-mcp` (or choose your own)
- AWS Region: `us-east-1` (or your preferred region)
- Confirm changes: `Y`
- Allow SAM CLI IAM role creation: `Y`
- Save arguments to config: `Y`
### Subsequent Deployments
After the first deployment, use:
```bash
npm run deploy:quick
```
This skips the guided questions and uses saved configuration.
## Testing Your Deployment
After deployment, you'll see output like:
```
Outputs
---------------------------------------------------------
WeatherMcpApi = https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/mcp
```
Test with curl:
```bash
curl -X POST https://YOUR-API-URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
```
## Monitoring and Logs
View logs:
```bash
sam logs -n WeatherMcpFunction --stack-name weather-mcp --tail
```
## Cleanup (Delete Everything)
When done testing:
```bash
sam delete --stack-name weather-mcp
```
This removes all AWS resources and stops billing.
## Cost Estimate
- **Free tier**: 1M requests/month FREE
- **Beyond free tier**: ~$0.20 per 1M requests
- **For testing**: Should be $0
## Troubleshooting
**Error: "AWS credentials not found"**
- Run `aws configure` and enter your credentials
**Error: "sam: command not found"**
- Install AWS SAM CLI (see step 2)
**Build errors:**
- Run `npm run build` first to check for TypeScript errors
- Ensure all dependencies are installed: `npm install`