Metadata-Version: 2.4
Name: operational-event-insights-mcp-server
Version: 1.0.0
Summary: Read-only sample MCP server for querying AWS Health events and service status
Author: Operational Event Insights MCP Team
License-Expression: MIT-0
Project-URL: Homepage, https://github.com/awslabs/support-solutions-aws/tree/main/Operations/operational-event-insights-mcp-server-on-aws
Project-URL: Repository, https://github.com/awslabs/support-solutions-aws.git
Project-URL: Issues, https://github.com/awslabs/support-solutions-aws/issues
Project-URL: Documentation, https://github.com/awslabs/support-solutions-aws/blob/main/Operations/operational-event-insights-mcp-server-on-aws/README.md
Keywords: aws,health,mcp,monitoring,observability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: boto3>=1.34.0
Requires-Dist: botocore>=1.34.0
Requires-Dist: mcp[cli]<2,>=1.22.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.12.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: pre-commit>=3.0.0; extra == "dev"

# Operational Event Insights MCP Server on AWS

Ask your AI assistant what AWS is telling you about your account: open incidents, affected resources, scheduled maintenance and organization-wide events, from the AWS Health API, read-only.

> **Disclaimer:** Before using this solution, you should consider conducting your own
> independent assessment to ensure that your use would comply with your own specific
> security and quality control practices and standards, as well as the laws, rules, and
> regulations that govern you and your content.

> **Not for production use as-is:** This is sample code for demonstration purposes only. Work with
> your security and legal teams to meet your organizational security, regulatory, and compliance
> requirements before any deployment.

**Contents:** [Overview](#overview) · [Use cases](#use-cases) · [Architecture](#architecture) · [Implementation guide](#implementation-guide) · [Tool reference](#tool-reference) · [Safe by design](#safe-by-design) · [Regions and availability](#regions-and-availability) · [Errors and partial results](#errors-and-partial-results) · [Troubleshooting](#troubleshooting) · [Cost](#cost) · [Development](#development)

## Overview

When something looks wrong in your AWS environment, one of the first questions is *"is this us, or is it AWS?"* The answer lives in [AWS Health](https://docs.aws.amazon.com/health/latest/ug/what-is-aws-health.html): service events, scheduled changes, and the specific resources they affect. Today that means switching to the Health Dashboard, or writing code against the Health API and then reading very long event descriptions.

This server exposes the Health API as [MCP](https://modelcontextprotocol.io) tools, so any MCP-compatible assistant (Claude Desktop, Kiro, Amazon Q CLI, and others) can answer those questions in conversation, using your own credentials, on your own machine.

**What you get**

- **Answers about *your* resources, not just AWS in general.** "Is instance `i-0abc…` affected by anything?" is answered by matching your resource IDs against the events' affected entities.
- **Output sized for an AI assistant.** Event descriptions are long. `summarize_health_events` returns counts only. On one test account, "what is wrong right now?" cost about 113 tokens through the summary tool versus about 40,000 through `get_service_health` (measured once; your numbers will vary with the number of open events).
- **Account and organization views** in one tool set, including events scoped to a single member account.
- **Honest failure handling.** A throttled or denied lookup is reported as a failure or a "partial results" warning, never as "nothing found".
- **Read-only, and nothing to deploy.** Eighteen tools, all annotated read-only; no AWS resources are created.

## Use cases

| Scenario | Example prompt | Main tools |
|---|---|---|
| **Incident triage:** is AWS the cause? | "What's happening with EC2 right now?" / "What's broken in us-west-2?" | `summarize_health_events`, `get_service_events` |
| **Resource impact:** is my resource affected? | "Is instance i-1234567890abcdef0 affected by anything?" | `find_events_for_resources`, `count_affected_entities` |
| **Planned-change awareness:** what is AWS about to change? | "Show me scheduled maintenance for the next few weeks" | `get_scheduled_changes`, `get_org_scheduled_changes` |
| **Organization oversight:** what is hitting my accounts? | "Which accounts does this event affect?" / "What events affect account 123456789012?" | `get_org_health_events`, `list_affected_accounts`, `get_org_account_events` |
| **Post-incident review:** what did AWS report, and when? | "Show recently resolved events for RDS" | `get_completed_events`, `get_event_details` |
| **Discovery:** what can AWS Health tell me about? | "Which event types does Step Functions report?" | `list_event_types` |

### Example ideas

These are ideas for building on the server, not features it ships with:

- **On-call assistant.** Add the server to your incident chat assistant so the first message in an incident can include "any open AWS Health events for the services in this alert?".
- **Pre-change check.** Before a deployment or failover test, ask for open and upcoming events for the services and regions involved.
- **Weekly digest.** Have an agent run `summarize_health_events` and `get_scheduled_changes` on a schedule and post a short summary to a team channel.
- **Maintenance planning.** Ask for scheduled changes that touch resources you own (`find_events_for_resources` with your resource IDs, `include_closed=false`) and turn them into tickets.
- **Customer or account reviews.** For a payer or management account, ask for org-wide open events grouped by service, then drill into individual accounts.

## Architecture

The server is a small local process. Your MCP client launches it and talks to it over stdio; the server calls the AWS Health API with your credentials.

```mermaid
flowchart LR
    U([You]) --> C["MCP client<br/>Claude Desktop · Kiro · Amazon Q CLI"]
    C <-->|"MCP over stdio"| S

    subgraph S["operational-event-insights-mcp-server (local process)"]
        T["server.py<br/>18 read-only tools"] --> H["client.py<br/>cache · batching · concurrency limit"]
        T --> F["formatters.py<br/>service-name resolution · markdown"]
    end

    H -->|"boto3 · SigV4 · your credentials"| G["global.health.amazonaws.com"]
    G -.->|"DNS points at the active region"| A["us-east-1 (active)"]
    G -.->|"failover"| P["us-east-2 (passive)"]
```

**How it works**

1. Your assistant picks a tool and calls it with arguments such as a service, an account or a list of resource IDs.
2. The server resolves service names (`Step Functions` → `STATES`) against the live Health service list.
3. The Health API is queried with paging and batching (10 ARNs per call where the API limits it), under a concurrency limit of 5.
4. Event descriptions are cached per event and last-updated time, so an ongoing event is refreshed when AWS updates it.
5. The result is formatted as compact markdown. If part of the answer could not be retrieved, it carries a "partial results" warning; if the call failed, the tool returns an MCP error.

[ARCHITECTURE.md](ARCHITECTURE.md) has sequence diagrams for a typical request and for a failure, plus the design decisions behind caching, batching and errors.

## Implementation guide

### Step 1: Check the prerequisites

| Requirement | Why |
|---|---|
| AWS **Business, Enterprise On-Ramp or Enterprise Support** plan on the account you query | The Health API returns `SubscriptionRequiredException` without one |
| Python 3.10+ and [`uv`](https://docs.astral.sh/uv/) (or `pip`) | Runs the server |
| AWS credentials on the machine running your MCP client | The server uses the standard credential chain (`AWS_PROFILE`, environment variables, SSO) |
| *Optional:* AWS Organizations with Health service access enabled, and a management or delegated-administrator account | Only for the organization-level tools |

### Step 2: Grant read-only permissions

Attach a policy like this to the user or role you will use. It covers every Health operation the server calls, all read-only; `sts:GetCallerIdentity` needs no permission.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AwsHealthReadOnly",
      "Effect": "Allow",
      "Action": [
        "health:DescribeEvents",
        "health:DescribeEventDetails",
        "health:DescribeAffectedEntities",
        "health:DescribeEventTypes",
        "health:DescribeEventAggregates",
        "health:DescribeEntityAggregates"
      ],
      "Resource": "*"
    },
    {
      "Sid": "AwsHealthOrganizationReadOnly",
      "Effect": "Allow",
      "Action": [
        "health:DescribeEventsForOrganization",
        "health:DescribeEventDetailsForOrganization",
        "health:DescribeAffectedEntitiesForOrganization",
        "health:DescribeAffectedAccountsForOrganization",
        "health:DescribeHealthServiceStatusForOrganization"
      ],
      "Resource": "*"
    }
  ]
}
```

Leave out the second statement if you only need single-account tools. The managed policy `AWSHealthFullAccess` also works but grants more than this server needs.

### Step 3: Configure credentials

Use a named profile (recommended) so credentials refresh without editing the MCP config:

```bash
aws configure --profile aws-health      # or: aws configure sso --profile aws-health
```

Avoid putting `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN` in the MCP config file: they are stored in plain text, and temporary credentials expire.

### Step 4: Install and register the server

Add the server to your MCP client's config file:

- **Claude Desktop:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Kiro:** `~/.kiro/settings/mcp.json`
- **Amazon Q CLI:** `~/.aws/amazonq/mcp.json`

**Option A: `uvx` from PyPI (recommended).** `uvx` caches the package, so use `@latest` to pick up new releases.

```json
{
  "mcpServers": {
    "operational-event-insights": {
      "command": "uvx",
      "args": ["operational-event-insights-mcp-server@latest"],
      "env": { "AWS_PROFILE": "aws-health" }
    }
  }
}
```

**Option B: `pip`.**

```bash
pip install operational-event-insights-mcp-server
```

then use `"command": "operational-event-insights-mcp-server"` (with no `args`) in the config above.

**Option C: from a local clone.**

```json
{
  "mcpServers": {
    "operational-event-insights": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/support-solutions-aws/Operations/operational-event-insights-mcp-server-on-aws", "operational-event-insights-mcp-server"],
      "env": { "AWS_PROFILE": "aws-health" }
    }
  }
}
```

**Optional: auto-approve the tools.** All 18 tools are read-only. In clients that support an `autoApprove` list (for example Kiro) you can avoid a prompt on every call:

```json
"autoApprove": [
  "check_health_access", "summarize_health_events", "get_event_details",
  "find_events_for_resources", "get_service_health", "get_affected_entities",
  "get_service_events", "get_completed_events", "get_scheduled_changes",
  "count_affected_entities", "list_event_types", "get_org_health_events",
  "get_org_service_health", "get_org_affected_entities", "get_org_service_events",
  "get_org_account_events", "get_org_scheduled_changes", "list_affected_accounts"
]
```

Restart the client after editing the config.

### Step 5: Verify

Ask your assistant: *"Run check_health_access."* It reports the calling identity, whether the support plan allows Health API access, whether organization view is enabled, and whether the service catalog loaded. Fix anything it flags before continuing (see [Troubleshooting](#troubleshooting)).

### Step 6: Try it

Start broad, then narrow down:

1. "Give me a summary of current AWS issues by service."
2. "What's happening with EC2 right now?"
3. "Give me the full details of that event."
4. "Is instance i-1234567890abcdef0 affected by anything?"

Service names can be typed however you like: `EC2`, `ec2`, `Step Functions` and `api gateway` all resolve. See [Service names](#service-names).

### Step 7 (optional): Enable organization-level tools

From the management account, once:

```bash
aws health enable-health-service-access-for-organization
```

Then use the org tools with credentials from the management account or a delegated administrator. This changes an organization-wide setting, so do it deliberately; the server itself never calls it.

### Step 8 (optional): Tune

| Variable | Default | Description |
|----------|---------|-------------|
| `AWS_PROFILE` | none | AWS credentials profile |
| `LOG_LEVEL` | `INFO` | Logging level (`DEBUG`, `INFO`, `WARNING`) |
| `HEALTH_API_TIMEOUT` | `30` | API read timeout in seconds |
| `HEALTH_API_MAX_CONCURRENCY` | `5` | Max concurrent Health API calls |
| `ENABLE_CACHE` | `true` | Cache event descriptions and affected accounts |
| `CACHE_TTL` | `300` | Cache lifetime in seconds |
| `SERVICE_LIST_TTL` | `86400` | Cache lifetime for the service catalog |

The region is not configurable; see [Regions and availability](#regions-and-availability).

## Tool reference

All tools are read-only and annotated as such. The Health API's two mutating
operations (`EnableHealthServiceAccessForOrganization` and
`DisableHealthServiceAccessForOrganization`) are deliberately not exposed.

### Start here

| Tool | Description |
|------|-------------|
| `summarize_health_events(group_by?, include_closed?)` | Event **counts** by service, status, category or region. Cheap overview — the listing tools include full descriptions and can be very large. |
| `get_event_details(event_arns)` | Full detail for specific events, by ARN |
| `find_events_for_resources(entity_values, include_closed?)` | Which events affect *your* resources, e.g. `i-1234567890abcdef0` |
| `check_health_access()` | Diagnose credentials, support plan and org access |

### Account-Level

| Tool | Description |
|------|-------------|
| `get_service_health(regions?)` | All active health events |
| `get_affected_entities` | Resources impacted by open events |
| `get_service_events(service, regions?)` | Events for a specific service (e.g., EC2, RDS) |
| `get_completed_events(service?, regions?)` | Recently resolved events |
| `get_scheduled_changes(regions?)` | Upcoming maintenance |
| `count_affected_entities(event_arns)` | How many resources an event hits, without listing them |

### Organization-Level

| Tool | Description |
|------|-------------|
| `get_org_health_events(service?, account_id?, status?, regions?)` | Events across all accounts |
| `get_org_service_health` | Active events org-wide |
| `get_org_affected_entities(account_id?, event_arn?)` | Impacted resources across accounts |
| `get_org_service_events(service, regions?)` | Service-specific events org-wide |
| `get_org_account_events(account_id, regions?)` | Events for a specific account |
| `get_org_scheduled_changes` | Org-wide scheduled maintenance |
| `list_affected_accounts(event_arn)` | Accounts affected by one event |

Filtering by `account_id` is done by the Health API itself. It therefore also returns `PUBLIC`-scope events, which are AWS-wide incidents that apply to every account.

### Discovery

| Tool | Description |
|------|-------------|
| `list_event_types(service?, category?)` | Event types AWS Health reports, and the service codes it uses |

### Service names

Pass service names however you like — `EC2`, `ec2`, `Step Functions`,
`api gateway` all resolve. The valid set comes from the Health API itself, so
every service AWS covers is reachable, and names are mapped to the codes AWS
actually uses (Step Functions is `STATES`, EventBridge is `EVENTS`). Use
`list_event_types` to browse them. Common names resolve in about a second; an
unrecognised name (a typo, say) triggers a one-time ~8 second load of the full
service list, which is then cached.

## Safe by design

- **Read-only.** Every tool is declared `readOnlyHint=true` and `destructiveHint=false`, and only `Describe*` Health operations are called.
- **Mutating operations are not exposed.** `Enable/DisableHealthServiceAccessForOrganization` have no tool, and a test asserts it stays that way.
- **Least privilege.** The [Step 2 policy](#step-2-grant-read-only-permissions) is the full set of permissions needed.
- **Checked by tests.** The test suite asserts the read-only declarations and the absence of mutating tools.
- **Runs locally.** The server runs on your machine and calls only AWS APIs (Health, plus STS for the identity shown by `check_health_access`). What your assistant does with the output depends on your MCP client and model provider.

## Regions and availability

The AWS Health API runs as an active-passive pair: `us-east-1` (active) and
`us-east-2` (passive), behind a single global endpoint,
`global.health.amazonaws.com`, whose DNS (10 second TTL) points at whichever
region is currently active.

- **Which endpoint this server uses.** The client is created for `us-east-1`,
  which boto3/botocore resolve to `https://global.health.amazonaws.com`. This
  holds for every botocore release this package supports (checked on 1.34.162
  and 1.43.89). The server therefore follows AWS's DNS failover; there is no
  region setting because the global endpoint chooses for you.
- **No client-side failover.** The server does not detect a failover itself or
  retry against `us-east-2`. Recovery relies on DNS re-resolution and
  botocore's retries (3 attempts, adaptive), so requests made during the switch
  can fail and a long-running server may need a call or two to pick up the new
  region. Restart the server if calls keep failing after AWS reports the
  Health API has failed over.
- **Passive data can lag.** AWS notes that only the active endpoint has the
  latest data; the passive endpoint is eventually consistent. During an
  incident, treat results as potentially slightly behind.
- **Not verified.** Requests to the global endpoint are signed for `us-east-1`
  (botocore's rule). AWS documents the signing region as that of the *active*
  endpoint, so it is not confirmed that requests signed for `us-east-1` are
  accepted after a failover to `us-east-2`. A real failover could not be tested.
  Calling `health.us-east-2.amazonaws.com` directly requires signing for
  `us-east-2`; a `us-east-1` signature is rejected with
  `InvalidSignatureException`.

Pinning the server to `us-east-2` is not supported. Overriding the endpoint
alone (for example with `AWS_ENDPOINT_URL_HEALTH`) still signs requests for
`us-east-1` and is rejected with `InvalidSignatureException`.

## Errors and partial results

Failures are reported, never turned into an empty answer:

- **Tool errors** (no Health access, API rejection, throttling that stops a
  request) are returned with the MCP `isError` flag set, so clients and agents
  can tell a failure from a result.
- **Partial results:** when one lookup inside a larger answer fails (for example
  the affected accounts of a single event), the rest is still returned with a
  "Warning: partial results" footer naming what is missing.
- **Searches:** `find_events_for_resources` returns an error rather than "no
  event affects it" if some events could not be checked.

## Troubleshooting

**"SubscriptionRequiredException"** — You need AWS Business or Enterprise Support.

**"AccessDeniedException"** — Your IAM user/role needs the permissions in [Step 2](#step-2-grant-read-only-permissions).

**Org tools return access error** — Enable Health service access from your management account (see [Step 7](#step-7-optional-enable-organization-level-tools)).

**`ExpiredToken` / credential errors** — Refresh your credentials, or use a named profile (Step 3). `check_health_access` shows what the server sees.

**Still on an old version with `uvx`** — `uvx` caches packages; use `operational-event-insights-mcp-server@latest` or run `uvx --refresh operational-event-insights-mcp-server` once.

**Server not starting** — Check the MCP client logs. Common issues:
- Wrong Python path in config (use the full `.venv/bin/python` path)
- Missing dependencies (run `pip install -e .` in the venv)

## Cost

The server runs on your machine and creates no AWS resources. The Health API requires a Business, Enterprise On-Ramp or Enterprise Support plan, so the cost is that of your Support plan (see [AWS Support pricing](https://aws.amazon.com/premiumsupport/pricing/)). Token usage with your AI assistant is separate; the summary tools exist to keep it small.

## Development

```bash
git clone https://github.com/awslabs/support-solutions-aws.git
cd support-solutions-aws/Operations/operational-event-insights-mcp-server-on-aws
uv sync --extra dev
uv run pytest tests/ -v
```

The tests run offline and need no AWS credentials.

## Clean up

The server creates no AWS resources, so there is nothing to delete in your account. To remove it:

- Delete the `operational-event-insights` entry from your MCP client configuration.
- If you installed it with `pip`, run `pip uninstall operational-event-insights-mcp-server`. `uvx` runs need no uninstall; `uvx cache clean` frees the cached package.
- Delete the `~/.operational-event-insights-mcp` directory if it exists (the server uses it for optional local configuration).
- If you created a dedicated IAM role or profile for it in [Step 2](#step-2-grant-read-only-permissions), delete that too.

## License

MIT-0
