npm package: @mcp-deployment/server
Description: MCP server for deploying static websites and AWS infrastructure
Author: rachcorp
Latest version: 1.5.0

# MCP Deployment Server

Deploy static websites and AWS infrastructure instantly from your IDE using MCP (Model Context Protocol).

## Features

- 🌐 **Static Website Deployment**: Deploy HTML, CSS, JavaScript sites to the cloud instantly
- 🏗️ **Infrastructure Deployment**: Deploy AWS CloudFormation templates directly from your IDE
- 📊 **Infrastructure Validation**: Validate CloudFormation templates against security and compliance rules
- 🔒 **Security-First**: Built-in validation for encryption, tagging, and security best practices
- ⚡ **Framework Support**: Automatic detection and building of Next.js, React, and other framework projects
- 🔄 **Stack Management**: Create, update, delete, and monitor CloudFormation stacks
- 📋 **Real-time Status**: Get deployment progress and stack outputs instantly

## Quick Start

### 1. Install

```bash
npm install -g @mcp-deployment/server
```

### 2. Configure

**Option A: Environment Variables**
```bash
export MCP_DEPLOYMENT_API_ENDPOINT="https://api.example.com/dev"
export MCP_DEPLOYMENT_API_KEY="your-api-key"
```

**Option B: Config File**
```json
{
  "apiEndpoint": "https://api.example.com/dev",
  "apiKey": "your-api-key"
}
```

### 3. Set up AWS Credentials (for infrastructure deployment)

```bash
# Method 1: Environment variables
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"

# Method 2: AWS CLI
aws configure

# Method 3: AWS credentials file
# ~/.aws/credentials
[default]
aws_access_key_id = your-access-key
aws_secret_access_key = your-secret-key
```

### 4. Use in Your IDE

The server provides these MCP tools:

## Available Tools

### Website Deployment

#### `deploy`
Deploy static websites or framework projects to the cloud.

**Parameters:**
- `directory` (required): Full path to your project directory
- `outputDir` (optional): Path to built files (e.g., "dist", "build", "out")
- `projectName` (optional): Custom name for deployment

**Example:**
```javascript
// Deploy a static site
deploy({
  directory: "/Users/username/my-website",
  projectName: "my-awesome-site"
})

// Deploy a built Next.js app
deploy({
  directory: "/Users/username/my-nextjs-app",
  outputDir: "out"
})
```

### Infrastructure Management

#### `validate-infrastructure`
Validate CloudFormation templates against security and compliance rules.

**Parameters:**
- `template` (required): CloudFormation template (YAML or JSON)
- `stackName` (required): Name for the stack
- `appType` (optional): Application type for additional validation

**Example:**
```javascript
validate_infrastructure({
  template: `
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256
      Tags:
        - Key: Environment
          Value: production
        - Key: Project
          Value: my-app
  `,
  stackName: "my-infrastructure-stack"
})
```

#### `deploy-infrastructure`
Deploy CloudFormation templates to AWS. Creates or updates stacks automatically.

**Parameters:**
- `template` (required): CloudFormation template content
- `stackName` (required): Stack name
- `parameters` (optional): Stack parameters as key-value pairs
- `tags` (optional): Additional tags for the stack
- `region` (optional): AWS region (default: us-east-1)
- `capabilities` (optional): IAM capabilities required

**Example:**
```javascript
deploy_infrastructure({
  template: cloudformation_template,
  stackName: "my-app-infrastructure",
  parameters: {
    "Environment": "production",
    "InstanceType": "t3.micro"
  },
  tags: {
    "Project": "my-app",
    "Owner": "team-backend"
  },
  region: "us-west-2"
})
```

#### `delete-infrastructure`
Delete a CloudFormation stack and all its resources.

**Parameters:**
- `stackName` (required): Name of the stack to delete
- `region` (optional): AWS region (default: us-east-1)

#### `stack-status`
Get the current status and outputs of a CloudFormation stack.

**Parameters:**
- `stackName` (required): Name of the stack
- `region` (optional): AWS region (default: us-east-1)

#### `list-stacks`
List all CloudFormation stacks in your AWS account.

**Parameters:**
- `region` (optional): AWS region (default: us-east-1)

### Deployment History

#### `status`
Get the status of your last deployment in this session.

#### `list`
List your recent deployments.

## Validation Rules

The infrastructure validator checks for:

### Security Requirements
- ✅ S3 bucket encryption enabled
- ✅ RDS encryption at rest
- ✅ EBS volume encryption
- ✅ Lambda environment variable encryption
- ✅ DynamoDB encryption at rest
- ✅ Proper VPC security group configurations

### Tagging Requirements
- ✅ All resources have required tags: `Environment`, `Project`, `Owner`
- ✅ Consistent tagging across resources

### Compliance Rules
- ✅ Public access prevention
- ✅ Secure default configurations
- ✅ Resource naming conventions
- ✅ IAM least privilege principles

## Complete Workflow Example

Here's how to deploy a full-stack application:

### 1. Validate Infrastructure
```javascript
// First, validate your CloudFormation template
validate_infrastructure({
  template: your_cloudformation_template,
  stackName: "my-app-backend"
})
```

### 2. Deploy Infrastructure
```javascript
// Deploy your AWS resources
deploy_infrastructure({
  template: your_cloudformation_template,
  stackName: "my-app-backend",
  parameters: {
    "Environment": "production"
  },
  tags: {
    "Project": "my-app",
    "Owner": "backend-team"
  }
})
```

### 3. Build and Deploy Frontend
```javascript
// Build your React/Next.js app first (if needed)
// Then deploy the frontend
deploy({
  directory: "/path/to/my-frontend-app",
  outputDir: "build",
  projectName: "my-app-frontend"
})
```

### 4. Monitor Status
```javascript
// Check your infrastructure status
stack_status({
  stackName: "my-app-backend"
})

// Check deployment status
status()
```

## Configuration

### MCP Configuration

Add to your MCP settings:

```json
{
  "mcpServers": {
    "mcp-deployment": {
      "command": "mcp-deployment",
      "env": {
        "MCP_DEPLOYMENT_API_ENDPOINT": "https://api.example.com/dev",
        "MCP_DEPLOYMENT_API_KEY": "your-api-key"
      }
    }
  }
}
```

### AWS Regions

Supported AWS regions:
- `us-east-1` (default)
- `us-west-2`
- `eu-west-1`
- `ap-southeast-1`
- And all other AWS regions

## Troubleshooting

### AWS Credentials Issues
If you get credential errors:

1. **Check AWS credentials setup:**
   ```bash
   aws sts get-caller-identity
   ```

2. **Verify IAM permissions** - Your AWS user/role needs:
   - `cloudformation:*`
   - `s3:*`
   - `iam:PassRole`
   - Other service permissions based on your template

3. **Regional access** - Ensure you have permissions in the target region

### Template Validation Failures
- Fix all validation errors before deployment
- Ensure all resources have required tags
- Enable encryption for data storage resources
- Follow AWS security best practices

### Stack Deployment Issues
- Check CloudFormation events in AWS Console
- Review stack parameters and template syntax
- Ensure IAM capabilities are granted if needed
- Verify resource limits and quotas

## Development

### Local Development

```bash
git clone https://github.com/rachcorp/mcp-deployment-server
cd mcp-deployment-server
npm install
npm run dev
```

### Build

```bash
npm run build
```

### Test

```bash
npm test
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Support

- 📧 Email: support@rachcorp.com
- 🐛 Issues: [GitHub Issues](https://github.com/rachcorp/mcp-deployment-server/issues)
- 📖 Docs: [Documentation](https://docs.rachcorp.com/mcp-deployment)