npm package: @plugix/mcp-aws
Description: MCP Server for AWS - EC2, Cost Management, Resource Optimization
Author: Plugix
Latest version: 0.1.0

# @plugix/mcp-aws

MCP server for AWS infrastructure management and cost optimization.

## Features

- **get_ec2_instances** - List EC2 instances with filters
- **get_cost_report** - AWS cost analysis by service
- **get_idle_resources** - Find wasteful resources (EBS, EIPs)
- **stop_instances** - Stop EC2 instances (with confirmation)
- **delete_volumes** - Delete unused EBS volumes (with confirmation)

## Installation

```bash
npm install @plugix/mcp-aws
```

Or run directly:

```bash
npx @plugix/mcp-aws
```

## Configuration

Set environment variables:

```env
# Plugix API connection
API_URL=wss://api.plugix.ai
API_TOKEN=plx_live_your_token_here

# AWS credentials
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
```

Or use IAM roles (recommended for EC2/ECS):

```env
API_URL=wss://api.plugix.ai
API_TOKEN=plx_live_your_token_here
AWS_REGION=us-east-1
# No access keys needed - uses instance role
```

## Usage

### Development

```bash
npm run dev
```

### Production

```bash
npm run build
npm start
```

### Docker (ECS/Fargate)

```bash
docker build -t plugix-mcp-aws .
docker run --env-file .env plugix-mcp-aws
```

### Claude Desktop Integration

Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "aws": {
      "command": "npx",
      "args": ["@plugix/mcp-aws"],
      "env": {
        "API_URL": "wss://api.plugix.ai",
        "API_TOKEN": "plx_live_your_token",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}
```

## Tools Reference

### get_ec2_instances

List EC2 instances with optional filters.

**Parameters:**

| Name | Type | Description |
|------|------|-------------|
| state | string | Filter: running, stopped, pending, terminated |
| instanceType | string | Filter by type (t3.micro, m5.large, etc.) |
| tagName | string | Filter by Name tag (partial match) |

**Example:**

```json
{
  "name": "get_ec2_instances",
  "arguments": {
    "state": "running",
    "tagName": "production"
  }
}
```

### get_cost_report

Get AWS cost breakdown for a date range.

**Parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| startDate | string | Yes | YYYY-MM-DD |
| endDate | string | Yes | YYYY-MM-DD |
| granularity | string | No | DAILY or MONTHLY |

**Example:**

```json
{
  "name": "get_cost_report",
  "arguments": {
    "startDate": "2024-01-01",
    "endDate": "2024-01-31",
    "granularity": "DAILY"
  }
}
```

### get_idle_resources

Find resources that could be deleted to save costs.

Checks:
- Stopped EC2 instances (EBS charges continue)
- Unattached EBS volumes
- Unassociated Elastic IPs

**Parameters:** None

### stop_instances

Stop one or more EC2 instances. Requires confirmation.

**Parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| instanceIds | array | Yes | List of instance IDs |
| confirmed | boolean | Yes | Must be `true` to stop |

**Example:**

```json
{
  "name": "stop_instances",
  "arguments": {
    "instanceIds": ["i-1234567890abcdef0"],
    "confirmed": true
  }
}
```

### delete_volumes

Delete unattached EBS volumes. HIGH RISK - requires confirmation.

**Parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| volumeIds | array | Yes | List of volume IDs |
| confirmed | boolean | Yes | Must be `true` to delete |

## IAM Permissions

Minimum required IAM policy:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeInstances",
        "ec2:DescribeVolumes",
        "ec2:DescribeAddresses",
        "ec2:StopInstances",
        "ec2:DeleteVolume"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "ce:GetCostAndUsage"
      ],
      "Resource": "*"
    }
  ]
}
```

For read-only access, remove `StopInstances` and `DeleteVolume`.

## Testing

```bash
npm test
```

## License

MIT