Commit ff98a81
feat(rum): add RUM to Application Signals MCP server (#3092)
* feat(cloudwatch-applicationsignals-mcp-server): add CloudWatch RUM tools
Add a suite of CloudWatch RUM MCP tools to the cloudwatch-applicationsignals
server, exposing app-monitor discovery, session/page/event exploration,
error and performance correlation with X-Ray, SLO status, and a scoped
raw-query escape hatch.
- rum_tools.py: action-dispatched tool surface with platform-aware
web-schema guards, truncation signals, and normalized error shapes
({error, error_type}).
- rum_queries.py: Logs Insights query builders with escaped user inputs,
length caps, and pagination.
- aws_clients.py: add RUM + CloudWatch Logs clients.
- server.py: register the new tools.
- tests/test_rum_tools.py: coverage for platform validation, limit
parsing, correlate regression paths, and X-Ray partial-failure.
Also includes supporting repo tooling:
- .claude/commands/{review,revise,auto-revise}.md review loop commands.
- CONTRIBUTING.md + PR template touch-ups.
* fix build
* fix(cloudwatch-applicationsignals-mcp-server): address review blockers in RUM tools
Revise-auto loop applied 3 blocker findings in iteration 1 (re-review clean):
- errors_query(group_by='page') produced a duplicate metadata.pageId
column in the Logs Insights `by` clause, rejected by the service.
Skip the group-by splice when the dimension is already present.
- Dispatcher caught only TypeError, letting ValueError from _parse_time
leak as a raw traceback. Broaden to (TypeError, ValueError) so bad
ISO time strings return a structured bad_request error.
- analyze_rum_log_group called _parse_time outside its try/except, so
malformed times also leaked. Move the _parse_time calls into the
existing ValueError guard.
Deferred (user-requested, not applied this run):
- .claude/commands/revise.md: --only / --skip flags declared but not
wired into the Procedure section.
- rum_tools.py: _list_anomalies_for returns truncated=False on exception
(conflates clean completion with mid-pagination failure).
- rum_tools.py: analyze_rum_log_group error branch omits truncated /
page_cap keys, breaking the shape invariant asserted by tests.
- rum_tools.py: _get_account_id STS failure propagates uncaught.
- rum_tools.py: most actions do not wrap _run_logs_insights_query in
try/except, leaking boto3 errors as raw tracebacks.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(cloudwatch-applicationsignals-mcp-server): raise RUM patch coverage above 90%
Adds 26 tests closing the substantive gaps codecov flagged on the RUM
diff (rum_tools.py coverage 87% -> 93%, patch target 92.59%):
- Parametrized cw_log_disabled test across every action handler that
calls _get_rum_app_info, covering the `except ValueError: return
bad_request` defensive branch in health, errors, performance,
sessions, page_views, timeseries, locations, http_requests,
session_detail, resources, page_flows, crashes, app_launches,
analyze, and correlate.
- check_rum_data_access branch tests: missing telemetries (MEDIUM),
sample_rate=0 (HIGH), low sample rate <0.1 (LOW), allowCookies=false
(LOW).
- Unknown-platform early-bail tests for sessions and session_detail.
- Web Vitals `needs-improvement` bucket and malformed-p90 handling in
get_rum_performance.
- Partition resolution for us-gov-* and cn-* regions.
- _get_rum_app_info_confident_cached ValueError when CwLogEnabled=True
but CwLogGroup is missing.
- _parse_time naive datetime -> UTC normalization.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* style(cloudwatch-applicationsignals-mcp-server): capitalize RUM test docstring
Align with ruff D-rule to unblock pre-commit ruff-check on CI.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(cloudwatch-applicationsignals-mcp-server): add local ci-check script
Add scripts/ci-check.sh mirroring .github/workflows/python.yml and
.github/workflows/pre-commit.yml for this package. Supports --only, --skip,
--list, and --no-fail-fast. Uses `uv run --frozen` for tools declared in the
dev group (bandit, pyright, ruff, pytest, pre-commit) and the package venv's
pre-commit for hook orchestration.
Also fix a pyright error in tests/test_rum_tools.py that the script caught
locally: dt.utcoffset() can return None per the datetime stubs.
Ignore generated bandit/coverage/junit artifacts.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* bump pr diff coverage to 97%
* refactor(cloudwatch-applicationsignals-mcp-server): Rename rum tool to query_rum_events
CodingAgent lazily loads MCP tool descriptions based largely on the
tool name. The bare acronym `rum` was the odd one out among siblings
like `query_service_metrics`, `list_slos`, and `audit_services`, which
hurt discoverability for queries like "show me web session errors".
Rename the public MCP tool from `rum` to `query_rum_events`:
- `query_` matches the shape of `query_service_metrics` and
`query_sampled_traces`.
- `events` reflects RUM's underlying data model (sessions, page views,
errors, crashes, and HTTP requests are all events queried via
CloudWatch Logs Insights).
- `rum` is retained because the acronym is unambiguous in this context.
Also rename the internal `query_rum_events` helper (the handler for
`action="query"`) to `run_rum_query` to resolve the name collision and
match the sibling pattern (`get_rum_errors`, `audit_rum_health`).
No behavior change. Function signature, action parameter, and dispatch
logic are unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(cloudwatch-applicationsignals-mcp-server): scope PR to package directory
Remove out-of-scope changes flagged by reviewer on PR #3092:
- Delete .claude/ slash commands, root-level poe symlink, and package
poe wrapper script
- Delete scripts/ci-check.sh (local CI mirror)
- Revert .github/pull_request_template.md and CONTRIBUTING.md to main
- Drop poethepoet dev-dep and [tool.poe.tasks] from pyproject.toml
- Fix typo in boto3-stubs extras: cloudwatchrum (not an extra, produced
uv-lock warning) -> rum
- Regenerate uv.lock (drops poethepoet + pastel, adds mypy-boto3-rum)
All 868 tests pass.
* fix build
---------
Co-authored-by: Syed Ahsan Ishtiaque <176968742+syed-ahsan-ishtiaque@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Min Xia <mxiamxia@gmail.com>1 parent 815c3a1 commit ff98a81
9 files changed
Lines changed: 4572 additions & 43 deletions
File tree
- src/cloudwatch-applicationsignals-mcp-server
- awslabs/cloudwatch_applicationsignals_mcp_server
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
385 | 429 | | |
386 | 430 | | |
387 | 431 | | |
| |||
869 | 913 | | |
870 | 914 | | |
871 | 915 | | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
872 | 938 | | |
873 | 939 | | |
874 | 940 | | |
| |||
937 | 1003 | | |
938 | 1004 | | |
939 | 1005 | | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
940 | 1013 | | |
941 | 1014 | | |
942 | 1015 | | |
| |||
956 | 1029 | | |
957 | 1030 | | |
958 | 1031 | | |
| 1032 | + | |
959 | 1033 | | |
960 | 1034 | | |
961 | 1035 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
92 | | - | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
102 | | - | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
| 121 | + | |
117 | 122 | | |
118 | 123 | | |
119 | 124 | | |
| |||
0 commit comments